Advertisement
joshuataylor

implementation of CL:MAP-INTO

Dec 30th, 2014
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.49 KB | None | 0 0
  1. ; See http://stackoverflow.com/a/27670789/1281433
  2.  
  3. (defun %map-into (result-list function list &rest lists)
  4.   "Like CL:MAP-INTO, but only accepts lists (as opposed
  5. to sequences)."
  6.   (apply 'mapl
  7.          (lambda (result-tail &rest args)
  8.            (setf (first result-tail)
  9.                  (apply function (mapcar 'first args))))
  10.          result-list
  11.          list
  12.          lists))
  13.  
  14. (let ((a '(1 2 3 4))
  15.       (b '(5 6 7 8)))
  16.   (%map-into a '+ a b)
  17.   a)
  18. ;=> (6 8 10 12)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement