Apply a callback to an array: Difference between revisions

Content added Content deleted
Line 130: Line 130:
(defun square (x) (* x x))
(defun square (x) (* x x))
(map 'vector #'square #(1 2 3 4 5))
(map 'vector #'square #(1 2 3 4 5))

;; destructive, like the Java example:
;; add 1 to every slot of vector *a*
(defvar *a* (vector 1 2 3))
(map-into *a* #'1+ *a*)


== [[FP]] ==
== [[FP]] ==