Tim

Going back to your original question, the answer is there all the time but
buried in the enormous method dictionaries of the Collection subclasses. If
you look at SequenceableCollection>>atWrap: you will see that it does
exactly what you want.

To get the item before the first, i.e. the zeroth:
#(1 2 3 4) atWrap: 0 => 4

To get the item after the last:
#(1 2 3 4) atWrap: 5 => 1

As seen here, the method is inherited by Array, so it should do all you
want.

HTH

Peter


Marcus Denker-4 wrote
>> On 29 Mar 2019, at 14:24, Ben Coman <

> btc@

> > wrote:
>> 
>> 
>> 
>> On Fri, 29 Mar 2019 at 18:57, Tim Mackinnon <

> tim@

> > wrote:
>> Hi Peter - yes of course you are right that its malleable, I guess I’m
>> often suprised about the things we leave out and then discover weird
>> things we’ve put in.
>> 
>> I had a quick look at LinkedList (I should have thought of that) - I
>> might be able to do something with that (and this is now more out of
>> curiosity) - but gosh its an easy way to crash your image. Having linked
>> the first to the last, and then tried a quick: list after: $n - I’m now
>> guessing I’m stuck in an infinite loop that even Cmd . won’t break out
>> of!!!! ouch. 
>> 
>> If you look at Hier(archy) of LinkList you'll see Semaphore underneath
>> it.
>> I'm not sure, but there may be some VM magic around Semaphore and Process
>> management that makes it fragile to changes.
>> I believe there have been some proposals to separate out the Process
>> related LinkedList stuff, but I can't remember the exact arguments.
> 
> Yes, we did that… there is now ProcessList.
> 
> We ran into that problem far too often “hey, LinkedList can be cleaned up
> easily like this!” —> boom, everything broken.
> 
> Now we have ProcessList where it matters if code is changed to introduce a
> message send more and LinkedList where it does not.
> 
>       Marcus





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

Reply via email to