B. Pym
2024-09-21 14:58:42 UTC
(let* ((temp1 (mapcar #'f1 some-list))
(temp2 (mapcar #'f2 temp1))
(temp3 (mapcar #'f3 temp2)))
(mapcar #'f4 temp3))
(loop for elem in some-list
collect (f4 (f3 (f2 (f1 elem)))))
(map (~> abs sqrt list) '(-4 -9 25))(temp2 (mapcar #'f2 temp1))
(temp3 (mapcar #'f3 temp2)))
(mapcar #'f4 temp3))
(loop for elem in some-list
collect (f4 (f3 (f2 (f1 elem)))))
===>
((2) (3) (5))
Given:
(define-syntax ->>
(syntax-rules ()
[(_ x) x]
[(_ x (y ...) z ...)
(->> (y ... x) z ...)]
[(_ x y z ...)
(->> (y x) z ...)]))
(define-syntax ->
(syntax-rules ()
[(_ x) x]
[(_ x (y more ...) z ...)
(-> (y x more ...) z ...)]
[(_ x y z ...)
(-> (y x) z ...)]))
;; currying
(define-syntax ~>
(syntax-rules ()
[(_ func0 func ...)
(lambda xs (-> (apply func0 xs) func ...))]))