Thomas F. Burdick wrote:
Pascal Costanza <pc@p-cos.net> writes:
(loop for x in '(1 2 3)
for y in '(4 5 6)
collect (* 2 (+ x y)))
vs.
(mapcar (lambda (x y)
(* 2 (+ x y)))
'(1 2 3)
'(4 5 6))
Oh, that one's easy:
(mapcar (compose (curry #'* 2) #'+)
'(1 2 3) '(4 5 6))
(map (& * 2 (+ u v)) '(1 2 3) '(4 5 6))
===>
(10 14 18)
Given:
(define-syntax &-aux
(syntax-rules (u v w quote)
[(_ whole shadow (param ...) () original)
(lambda (param ...) original)]
[(_ (u more ...) (x y ...) () ps original)
(&-aux (more ...) (y ...) (x) ps original)]
[(_ (v more ...) (x y ...) (a) ps original)
(&-aux (more ...) (y ...) (a x) ps original)]
[(_ (w more ...) (x y ...) (a b) ps original)
(&-aux (more ...) (y ...) (a b x) ps original)]
[(_ ((quote ...) more ...) (y z ...) params ps original)
(&-aux (more ...) (z ...) params ps original)]
[(_ ('x more ...) (y z ...) params ps original)
(&-aux (more ...) (z ...) params ps original)]
[(_ ((s ...) more ...) (y z ...) params ps original)
(&-aux (s ... more ...) (s ... z ...) params ps original)]
[(_ (x more ...) (y z ...) params ps original)
(&-aux (more ...) (z ...) params ps original)]
[(_ () shadow params (p ps ...) original)
(&-aux original original params (ps ...) original)]))
;; Lambda with anaphoric parameters u, v, and w.
(define-syntax &
(syntax-rules ()
[(& x ...)
(&-aux (x ...) (x ...) () (1 2 3) (x ...))]))
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)