Page 1 of 1

slice

PostPosted: Mon Nov 10, 2003 6:02 pm
by eddier
Thanks for the new set-nth function!

It would be nice if slice had a negative offset that started from the end of the list instead of the beginning.

Example

Code: Select all
(setq a '(1 2 3 4 5 6 7))
(slice a -3 2) => (5 6)


This is somewhat nicer than
Code: Select all
(slice a (- (length a) 3) 2)


Eddie

PostPosted: Tue Nov 11, 2003 7:33 pm
by Lutz
>>>>
It would be nice if slice had a negative offset that started from the end of the list instead of the beginning.
>>>>

I was thinking about this too, sounds like a good idea for the next release. (Could also be done in nth and set-nth)

Lutz

PostPosted: Tue Nov 11, 2003 8:52 pm
by eddier
... and push, pop, and char.

Eddie

PostPosted: Wed Nov 12, 2003 12:07 am
by Lutz
... and lookup, swap, collect, select

lets do them all ;), the thing is, if you (as a user) find it in one function, it is intuitive and expected to have it in all primitives, which use and index/offset spec.

I went looking through the code and I think it is doable without sacrifying (measurable) speed for the normal positive offset and with very little code, the mechanism, how to do it, is always the same.

Lutz

PostPosted: Wed Nov 12, 2003 1:41 pm
by eddier
I agree! Consistency is always best :)

Eddie