Contents    Page-10    Prev    Next    Page+10    Index   

Mapping in Lisp

Clojure and Lisp have functions that compute mappings from a linked list. map makes a new list whose elements are obtained by applying a specified function to each element ( first) of the input list(s).


>(defn square [x] (* x x))

>(map square '(1 2 3 17))

(1 4 9 289)

>(map + '(1 2 3 17) '(2 4 6 8))

(3 6 9 25)

>(map > '(1 2 3 17) '(2 4 6 8))

(false false false true)