[squeak-dev] Noob question: array slice?

Casey Ransberger casey.obrien.r at gmail.com
Fri Aug 6 07:25:17 UTC 2010


Thanks, man. I can use that for what I'm trying to do. 

What with all the Ruby cats dying to jump ship (guilty!) maybe we should think about doing...

aCollection slice: 2..4 "new binary message?"

slice: anInterval
"don't have Squeak handy to assess what an implementation might look like"

Whacky idea, please forgive if it's over the top, beloved People of Squeak. I know you will, you've done it before:)

On Aug 6, 2010, at 12:08 AM, Travis Griggs <travisgriggs at gmail.com> wrote:

> On Aug 5, 2010, at 11:03 PM, Casey Ransberger wrote:
> 
>> Given that I have a collection like #(foo bar baz 1 2 3), and I want to get elements 2...4, what selector do I use? I'm confused. Argh. Seems like I should be able to figure this out by now without what I think of being a pain. I guess I can just test the bounds, but yuck.
> 
> 
> #(foo bar baz 1 2 3) copyFrom: 2 to: 4
> 
> ? is that what what you mean?
> 
> another way, more general would be
> 
> (2 to: 4) collect: [:n | original at: n]
> 
> In VisualWorks 7.7.1, we added a Subsequence object, that can act as a subrange facade to a sequence. It's very very handy for the Meyer diff algorithm, and doing Text differencing.
> 
> Subsequence sequence: #(foo bar baz 1 2 3) from: 2 to: 4
> 
> You can stack them of course.
> 
> --
> Travis Griggs
> Objologist
> For every adage, there is an equal and contrary un-adage
> 
> 



More information about the Squeak-dev mailing list