Re: def app = apply, problem



On 29 Apr, 19:39, p...@xxxxxxxxxxxxxxxxx (Pascal J. Bourguignon)
wrote:
globalrev <skanem...@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__

i dont know the operator and its merely educational anyway.

.



Relevant Pages

  • Re: def app = apply, problem
    ... (def app (oper expr) ... FUNCTION: undefined function OPER ... (funcall #'oper expr)) ...
    (comp.lang.lisp)
  • def app = apply, problem
    ... (def app (oper expr) ... FUNCTION: undefined function OPER ... (funcall #'oper expr)) ...
    (comp.lang.lisp)