Extra argument for list accessors

For the Compleat Fan
Locked
Jeremy Dunn
Posts: 95
Joined: Wed Oct 13, 2004 8:02 pm
Location: Bellingham WA

Extra argument for list accessors

Post by Jeremy Dunn »

I was thinking that it might be nice to add an extra optional argument at the end of the functions FIRST, LAST, NTH, REST and SLICE that represent a value that is to be substituted at that position. So for example

(first "cat") -> "c"
(first "cat" "b") -> "bat"

or

(nth 2 '(2 3 7 77 8) 6) -> '(2 3 6 77 8)

and so on.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

thats what 'set-nth' is for:

Code: Select all

(set-nth 2 '(2 3 7 77 8) 6) => (2 3 6 77 8) 
Lutz

Locked