Function (operator) as function parameter: how?
Posted: Wed Dec 26, 2012 5:59 am
Hello,
This newbie is stuck on a problem and hopes any one can give him a hint.
Having used Scheme somewhere in history, I am trying to use Lisp now.
I am stuck on how to do the following Scheme statement in Lisp:
( (lambda (FN) ( FN '( PB PC )))
(lambda (varx) (cons 'PA varx)))
The result is:
(pa pb pc)
the first function takes a function as parameter, which it invokes with a list as argument.
In Lisp I should, I think, quote the second function, like
( (lambda (FN) ( FN '( PB PC ))) '(lambda (varx) (cons 'PA varx)))
But this does not work. I have tried variations with funcall, function # etc, but nothing seems to help.
What is the way to do this in Common Lisp (emacs+cl or CMUcl)?
Greets
JW
This newbie is stuck on a problem and hopes any one can give him a hint.
Having used Scheme somewhere in history, I am trying to use Lisp now.
I am stuck on how to do the following Scheme statement in Lisp:
( (lambda (FN) ( FN '( PB PC )))
(lambda (varx) (cons 'PA varx)))
The result is:
(pa pb pc)
the first function takes a function as parameter, which it invokes with a list as argument.
In Lisp I should, I think, quote the second function, like
( (lambda (FN) ( FN '( PB PC ))) '(lambda (varx) (cons 'PA varx)))
But this does not work. I have tried variations with funcall, function # etc, but nothing seems to help.
What is the way to do this in Common Lisp (emacs+cl or CMUcl)?
Greets
JW