[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.lisp

Re: Functional programming

William James

5/22/2015 7:23:00 AM

Erik Naggum wrote:

> * Tord Kallqvist Romstad
> | This works, of course, but I thought matt meant that all the functions in
> | list-of-functions should be used on the same argument (in his example, a
> | news article). Having to construct a list of copies of this single
> | argument of the same length as the list of functions seems very
> | inconvenient.
>
> it would indeed, so we don't. given this very useful function:
>
> (defun circular-list (arg &rest args)
> (let ((car (list arg)))
> (nconc car args car)))
>
> for a single argument, the answer is simply this:
>
> (mapcar #'funcall <list-of-functions> (circular-list <arg>))

Gauche Scheme:

(map (cut <> 9) (list + - * /))
===>
(9 -9 9 1/9)

--
How does the Swedish political elite respond to their largest cities breaking
down? By pretending there is no problem. The media elite shares the same
contempt for and fear of the common people, and has largely played along.
fjordman.blogspot.ca/2005/05/is-swedish-democracy-collapsing.html