[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: fif function from On Lisp
From: |
weber |
Subject: |
Re: fif function from On Lisp |
Date: |
Tue, 4 Mar 2008 05:59:59 -0800 (PST) |
User-agent: |
G2/1.0 |
On Mar 4, 9:53 am, bojohan+n...@dd.chalmers.se (Johan Bockgård) wrote:
> weber <hug...@gmail.com> writes:
> > Hi folks.
> > For some reason this function from On Lisp doesn't work:
>
> > (defun fif (a b &optional c)
> > '(lambda (x)
> > (if (funcall a x)
> > (funcall b x)
> > (unless (null c) (funcall c x)))))
>
> > I should be able to call it like this:
>
> > (mapcar (fif 'zerop '1+ 1-) '(0 1 2 3) => (1 0 1 2)
>
> > but i'm probably missing something that is differs from Common Lisp to
> > Elisp.
>
> The code above doesn't work in Common Lisp either, but anyway, Emacs
> Lisp doesn't have lexical closures (yet).
>
> (info "(elisp) Extent")
>
> --
> Johan Bockgård
Hm. Does that snippet really depends on lexical closures?
I just need that function to expand to this:
(mapcar (lambda (x) (if (funcall 'zerop x) (funcall '1+ x) (funcall
'1- x)))
'(0 1 2 3))
... maybe I can solve it with a macro then?
-weber