newLISP Fan Club

Forum => Anything else we might add? => Topic started by: Jeremy Dunn on April 21, 2007, 02:23:20 PM

Title: Extra argument for list accessors
Post by: Jeremy Dunn on April 21, 2007, 02:23:20 PM
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.
Title:
Post by: Lutz on April 21, 2007, 03:58:26 PM
thats what 'set-nth' is for:


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

Lutz