Code: Select all
(set 'lst '(2 6 9 12))
;-> (2 6 9 12)
(inc (lst 0))
;-> 3
lst
;-> (3 6 9 12)
(map inc lst)
;-> (4 7 10 13)
(map (curry inc 3) lst)
;-> (6 9 12 15) ; === CHECK OUT THIS LINE ===
lst
;-> (3 6 9 12)
Code: Select all
newLISP v.10.3.3 64-bit on Linux IPv4/6 UTF-8, execute 'newlisp -h' for more info.
> (set 'lst '(2 6 9 12))
(2 6 9 12)
> (inc (lst 0))
3
> lst
(3 6 9 12)
> (map inc lst)
(4 7 10 13)
> (map (curry inc 3) lst)
(6 12 21 33) ; === CHECK OUT THIS LINE ===
> lst
(3 6 9 12)
Now I recall reading about a function that takes elements by pairs, can't recall the name right now, but recalling that it exists confuses me on this behaviour. Is it expected? Is map+curry+inc supposed to take the list elements in pairs and operate them with one another? I feel it shouldn't, but I may be wrong.
Doing...
Code: Select all
newLISP v.10.3.3 64-bit on Linux IPv4/6 UTF-8, execute 'newlisp -h' for more info.
> (set 'lst '(2 6 9 12))
(2 6 9 12)
> (map (curry inc 3) lst)
(5 11 20 32)
> lst
(2 6 9 12)
> (map (lambda (x) (+ x 3)) lst)
(5 9 12 15)
> (map (lambda (x) (inc x 3)) lst)
(5 9 12 15)
> (map (curry + 3) lst)
(5 9 12 15)
What's going on? Should I update ITN book and denote the pitfall as expected behavior or should this behavior be modified?