Re: def app = apply, problem



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__
.



Relevant Pages

  • Re: def app = apply, problem
    ... (def app (oper expr) ... Evaluating + means get last command.. ... Why do you wish not to quote the operation but wish to quote the list? ...
    (comp.lang.lisp)
  • def app = apply, problem
    ... (def app (oper expr) ... FUNCTION: undefined function OPER ... (funcall #'oper expr)) ...
    (comp.lang.lisp)
  • Re: def app = apply, problem
    ... FUNCTION: undefined function OPER ... (def app (oper expr) ...
    (comp.lang.lisp)