Subject: Re: exercise from PAIP
From: rpw3@rpw3.org (Rob Warnock)
Date: Tue, 16 Mar 2004 10:27:21 -0600
Newsgroups: comp.lang.lisp
Message-ID: <84mcnaCN9Md0t8rd3czS-w@speakeasy.net>
Tayssir John Gabbour <tayss_temp2@yahoo.com> wrote:
+---------------
| mikecoxlinux@yahoo.com (Mike Cox) wrote:
| > I certainly don't put "lambda" in my programs. It doesn't benefit me.
| 
| Why not rename the sucker?  fun, new-function, anon...
+---------------

I seem to recall that ML calls it "fn", and that's what I used once for
a scripting language. Lessee here... Certainly easy enough to do in CL:

	> (defmacro fn (&rest rest)
	    `(lambda ,@rest))

	FN
	> (mapcar (fn (x y) (+ y (* x 10))) '(1 2 3) '(4 5 6))

	(14 25 36)
	> 

Yup, seems to work just fine.


-Rob

p.s. I once wrote a reader macro for "#$" [duplicating it is left as an
exercise for the discerning reader] which let me use $1, $2, etc. as args
to anonymous functions, like shell scripts, so you didn't have to bother
defining those pesky argument lists!  ;-}

	> (mapcar #$(+ $2 (* 10 $1)) '(1 2 3) '(4 5 6))

	(14 25 36)
	> 

See how much *shorter* that is than the FN version?!?  ;-}  ;-}

['Course, it doesn't handle >9 args. Or &OPTIONAL, &REST, &KEYS, etc...]

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607