TomSW·17 years ago·discussFor the simpler cases you can just use curry or rcurry, eg:(mapcar (rcurry #'parse-integer :junk-allowed t) '(" 1" "2xx" "3" "foo")) (1 2 3 NIL)... whereas your more complex example doesn't strike me as an improvement over lambda + backquote:(mapcar (fmask #'list ? (? (1+ (length ?)))))) vs.(mapcar (lambda (n list) `(,n (1+ (length ,list)))) numbers lists)... which might be longer than the fmask version but has the advantage of being immediately readable to any Lisp programmer, and of allowing arguments to be reused, or used in a different order than they appear.Doug Hoyte has a nice read macro called #`:(mapcar #2`(,a1 (1+ (length ,a2))) numbers lists)
(mapcar (rcurry #'parse-integer :junk-allowed t) '(" 1" "2xx" "3" "foo")) (1 2 3 NIL)
... whereas your more complex example doesn't strike me as an improvement over lambda + backquote:
(mapcar (fmask #'list ? (? (1+ (length ?)))))) vs.
(mapcar (lambda (n list) `(,n (1+ (length ,list)))) numbers lists)
... which might be longer than the fmask version but has the advantage of being immediately readable to any Lisp programmer, and of allowing arguments to be reused, or used in a different order than they appear.
Doug Hoyte has a nice read macro called #`:
(mapcar #2`(,a1 (1+ (length ,a2))) numbers lists)