[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Re: How can I get the "argument list".

William James

7/9/2015 6:24:00 AM

Joel Ray Holveck wrote:

> or if you want allow the user to specify a second function instead of
> always summing:
>
> (defun f (preprocess-fn reduce-fn &rest args)
> (reduce reduce-fn (mapcar preprocess-fn args)))
> ;; call like (f #'(lambda (x) (expt x 2)) #'+ 1 2 3)
>
> (The Scheme version is left as an exercise to the reader.)

Gauche Scheme:

(define (f preprocess-fn reduce-fn . args)
(fold
(^(x accum) (reduce-fn (preprocess-fn x) accum))
(reduce-fn)
args))

gosh> (f (cut expt <> 2) + 1 2 3)
14
gosh> (f (cut expt <> 2) * 1 2 3)
36

--
[V]ersions of the false flag attack have been used ... to direct the force of
the people toward whatever end the ruling class may be seeking.... that end
may be war, or it may be the curtailing of domestic civil liberties and basic
human rights. www.alt-market.com/articles/1808-11-signs-of-a-false-flag