Re: [Pharo-users] Is there a way to stop arrays sorting automatically?

2018-01-06 Thread Andrew Black
+1 for what Richard says.

Moreover, if you know that n is small, and you really want copies of all th
permutations, then adding a copy message to your block is really simple.
But if the permutationsDo: method made the copy, then it would be useless
except for very small values of n.

The comment that Richard quotes is in Pharo too.   There is a good reason
for the current behaviour, and it is documented.


Re: [Pharo-users] Grafoscopio (Initial) Feedback

2018-01-06 Thread Paul DeBruicker
Hi Offray,

I think the docs you want are here:

https://github.com/Metacello/metacello/blob/master/docs/MetacelloUserGuide.md

and

https://github.com/Metacello/metacello/blob/master/docs/MetacelloScriptingAPI.md


Hope this helps,

Paul



Offray Vladimir Luna Cárdenas-2 wrote
> Hi Sean,
> 
> I would like to use the Metacello script you advised to me for loading
> Grafoscopio. The Gopher scripts were created following documentation in
> PBE2.
> 
> Does any has pointers to documentation on how to create Metacello
> installing scripts?
> 
> Thanks,
> 
> Offray
> 
> 
> On 31/12/17 11:08, Sean P. DeNigris wrote:
>> Offray Vladimir Luna Cárdenas-2 wrote
>>> Now they're in the SThub and also in the PDF Manual linked there.
>> Ah, okay I see they are updated for 6.1, but they still use Gofer. Also,
>> IIRC (I moved all my development to git a while ago now) the best
>> practice
>> is to always keep the most up-to-date ConfigurationOf in the canonical
>> repo
>> (i.e. yours) and then /copy/ it to the relevant platform
>> metaRepoForXyz's.
>> Otherwise, in my experience one invites chaos because people are
>> downloading
>> variously out-of-date configs from multiple sources (like me last night
>> spending time reporting already-fixed bugs; don't worry I'm not upset!).
>> See
>> my previous post for the preferred script that should be expected to work
>> on
>> /any/ supported platform.
>>
>>
>>
>> -
>> Cheers,
>> Sean
>> --
>> Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
>>
>>





--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html



Re: [Pharo-users] Is there a way to stop arrays sorting automatically?

2018-01-06 Thread Richard O'Keefe
I would check this in Pharo, but have so far failed to get it running under
Ubuntu 17.10.
Squeak _is_ running there, sort of, and the definition of #permutationsDo:
in Interval
is this code:

permutationsDo: aBlock
"Repeatly value aBlock with a single copy of the receiver. Reorder the copy
so that aBlock is presented all (self size factorial) possible
permutations."
"(1 to: 4) permutationsDo: [:each | Transcript cr; show: each printString]"

self asArray permutationsDo: aBlock

Exactly the same comment is found in SequenceableCollections.

Are you sure that Pharo has something different?  "with a SINGLE COPY of
the receiver" is pretty important.  The thing is that the number of
permutations
is so astronomically large that it really never makes sense to retain all
of them
in memory.  Suppose an array of n elements takes n+2 words, then holding
all of the permutations of 1..k would take (k+2)*k! + k! + 2 = k!(k+3)+2
words.
For k = 5 10 15 20 that's 962 47174402 23538138624002 55956746188062720002
words.  If we assume a 64-bit laptop with 16 GiB of memory, k=12 is already
too big.
Yet it is perfectly reasonable to iterate over all 12! permutations.

Another thing about iterating over permutations is that straightforward
algorithms
take O(1) time per permutation, but not if you copy every time.

I don't think I've ever found a use for #permutationsDo: that didn't need
to be
turned into a specialised backtracking algorithm with cutoffs pushed as
early
as possible.