CommonLispのreduceと, Schemeのfoldの違い
まあこういう違いです。
引数の適用の仕方なので、方言みたいなものですが。
CommonLisp - reduce
(defun myreverse (lis) (reduce (lambda (x y) (cons y x)) lis :initial-value nil)) (myreverse '(1 2 3 4 5)) ; (5 4 3 2 1)
Scheme - fold
(define (myreverse lis) (fold cons () lis)) (myreverse '(1 2 3 4 5)) ; (5 4 3 2 1)