On Wed, Apr 09, 2008 at 03:07:00PM +0200, Duncan Mac-Vicar Prett wrote:
> Arvin Schnell wrote:
> >     * @usage sublist ([ "a", "b", "c"], 0) -> [ "a", "b", "c" ]
> >     * @usage sublist ([ "a", "b", "c"], 2) -> [ "c" ]
> >  
> It does not beat ruby's elegance. ;-)

Neither does it beat python's slice syntax elegance ;-)

s = "hello world"

s[6:] -> 'world'     from 6th on
s[:5] -> 'hello'     upto 5th

s[-5:] -> 'world'    from 5th backwards on
s[:-6] -> 'hello'    upto 6th backwards

s[2:8] -> 'llo wo'   from 2nd to 8th
s[2:8:2] -> 'low'    from 2nd to 8th but only every second
s[9:2:-2] -> 'lo l'  :)

But having to write "sublist(s, nil, -2, nil)" doesn't look so
cool.

cu Arvin
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to