GoLisp's map now takes multiple lists

22 Dec 2014

by Dave Astels

Since GoLisp powers our software it’s evolution is largely driven by our needs. This is a case in point.

I’ve updated the map special form to take any number of list arguments.

Previously map took a function of one argument and a single list to iterate over:

(map (lambda (x) (* x x)) '(1 2 3 4 5)) ⇒ (1 4 9 16 25)

With this change map will accept any number of lists, with the cavaet that the function accepts that number of arguments:

(map + '(1 2 3) '(4 5 6)) ⇒ (5 7 9)
(map list '(1 2 3) '(a b c) '("x", "y", "z") ⇒ ((1 a "x") (2 b "y") (3 c "z"))

If the list arguments are not the same length, map only iterates to the end of the shortest:

(map list '(1 2 3) '(a b c d) '("hi", "there") ⇒ ((1 a "hi") (2 b "there"))