Created
September 12, 2012 00:44
-
-
Save ichimal/3703328 to your computer and use it in GitHub Desktop.
self update map
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun map-update (fun src &rest lists) | |
(funcall | |
(reduce (lambda (cont list-elms) | |
(lambda () | |
(apply fun (funcall cont) list-elms) )) | |
(apply #'mapcar #'list lists) | |
:initial-value (constantly src) ))) | |
(defun subst-all (to-list from-list src) | |
(map-update | |
(lambda (src from to) (subst to from src)) | |
src from-list to-list )) | |
(subst-all '(1 2 3) '(a b c) '(a b c d c b a)) ; => '(1 2 3 d 3 2 1) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment