Re: def app = apply, problem
- From: "John Thingstad" <jpthing@xxxxxxxxx>
- Date: Tue, 29 Apr 2008 19:14:03 +0200
På Tue, 29 Apr 2008 18:34:31 +0200, skrev globalrev <skanemupp@xxxxxxxx>:
instead of:
CL-USER> (apply #'+ '(1 2 3))
6
i want to do:
(app + (1 2 3))
(def app (oper expr)
(apply #'oper 'expr))
doesnt work though, i get
CL-USER> (app + (3 4)) 3 is not a function name
(app + '(3 4))
FUNCTION: undefined function OPER
[Condition of type SYSTEM::SIMPLE-UNDEFINED-FUNCTION]
(app + (3 4)) gives 3 not a function name if:
(def app (oper expr)
(funcall #'oper expr))
#'<> really is just short for (function <>)
You need that in the original expression or + will be evaluated.
Evaluating + means get last command..
So you would need a defmacro to make sure app doesn't get evaluated before the substitution takes place.
(defmacro app (operation argument-list)
`(apply ',operation ,argument-list))
Why do you wish not to quote the operation but wish to quote the list?
You don't really need a new function for this as it does the same thing.
(setf (symbol-macro (intern "APP")) #'apply)
(app #'+ '(1 2 3))6
or
(defun alias (name function &optional (package *package*))
(setf (symbol-macro (intern (string-upcase name) package)) function))
--------------
John Thingstad
.
- Follow-Ups:
- Re: def app = apply, problem
- From: globalrev
- Re: def app = apply, problem
- From: John Thingstad
- Re: def app = apply, problem
- References:
- def app = apply, problem
- From: globalrev
- def app = apply, problem
- Prev by Date: Re: def app = apply, problem
- Next by Date: found .emacs, but doesnt work running lisp
- Previous by thread: Re: def app = apply, problem
- Next by thread: Re: def app = apply, problem
- Index(es):
Relevant Pages
|
|