slice

Q&A's, tips, howto's

slice

Postby eddier » Mon Nov 10, 2003 6:02 pm

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
eddier
 
Posts: 289
Joined: Mon Oct 07, 2002 2:48 pm
Location: Blue Mountain College, MS US

Postby Lutz » Tue Nov 11, 2003 7:33 pm

>>>>
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
Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Postby eddier » Tue Nov 11, 2003 8:52 pm

... and push, pop, and char.

Eddie
eddier
 
Posts: 289
Joined: Mon Oct 07, 2002 2:48 pm
Location: Blue Mountain College, MS US

Postby Lutz » Wed Nov 12, 2003 12:07 am

... 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
Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Postby eddier » Wed Nov 12, 2003 1:41 pm

I agree! Consistency is always best :)

Eddie
eddier
 
Posts: 289
Joined: Mon Oct 07, 2002 2:48 pm
Location: Blue Mountain College, MS US


Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 1 guest

cron