Documentation
uses fn-comb to a list of values returned by fns, where
every fn in fns is called with x
e.g. (fchain (lambda (x y) (and x y)) f1 f2 ... fn)
creates a function like:
(lambda (x)
(and (f1 x)
(f2 x)
...
(fn x)))
in truth it is more like:
(lambda (x)
(and (f1 x)
((lambda (y) (and (f2 y)
(...) y))
x)))
works similiar to
(defun freduce (fn-comb fn &rest fns)
(lambda (arg)
(reduce (lambda (x fn-y)
(funcall fn-comb
x
(funcall fn-y arg)))
fns :initial-value (funcall fn arg))))
but builds one in comparison to freduce, fchain builds
up a big function when called first instead of reducing on the list
of functions.
Source
(defun fchain (fn-comb fn &rest fns)
"uses fn-comb to a list of values returned by fns, where
every fn in fns is called with x
e.g. (fchain (lambda (x y) (and x y)) f1 f2 ... fn)
creates a function like:
(lambda (x)
(and (f1 x)
(f2 x)
...
(fn x)))
in truth it is more like:
(lambda (x)
(and (f1 x)
((lambda (y) (and (f2 y)
(...) y))
x)))
works similiar to
(defun freduce (fn-comb fn &rest fns)
(lambda (arg)
(reduce (lambda (x fn-y)
(funcall fn-comb
x
(funcall fn-y arg)))
fns :initial-value (funcall fn arg))))
but builds one in comparison to freduce, fchain builds
up a big function when called first instead of reducing on the list
of functions.
"
(if (null fns)
fn
(let ((chain (apply #'fchain fn-comb fns)))
(lambda (x)
(funcall fn-comb
(funcall fn x)
(funcall chain x))))))
Source Context