Re: def app = apply, problem
- From: pjb@xxxxxxxxxxxxxxxxx (Pascal J. Bourguignon)
- Date: Tue, 29 Apr 2008 19:39:25 +0200
globalrev <skanemupp@xxxxxxxx> writes:
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))
What is def?
(defmacro app (operator arguments) `(,operator ,@arguments))
But then you cannot do the equivalent of:
(let ((op (if (oddp (random 2)) '+ '-)))
(apply op '(29 3)))
(let ((op (if (oddp (random 2)) '+ '-)))
(app op (29 3))) ; breaks.
and on the other hand, if you already know the operator and arguments (app + (1 2 3))
why not just write: (+ 1 2 3) ?
--
__Pascal Bourguignon__
.
- Follow-Ups:
- Re: def app = apply, problem
- From: globalrev
- 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: Re: automatically call functions based on arguments
- Previous by thread: Re: def app = apply, problem
- Next by thread: Re: def app = apply, problem
- Index(es):
Relevant Pages
|
|