Hi Christophe,

> (decar myfn arg
>   # here arg is the first arg given when calling myfn, unevaluated
> )
> 
> 
> This is my attempt:
> 
> (de decar args
>   (let (fn (car args)
>          arg (cadr args)
>          body (cddr args))
>         (set fn (list (list "arg") (list 'let arg "arg" (list 'run body))))))

You are close :)

I would do this:

   (de decar Lst
      (def (++ Lst)
         (let Var (++ Lst)
            (cons
               Var
               (list 'setq Var (list 'car Var))
               Lst ) ) ) )

Test:

   : (decar foo X
      (msg X)
      (length (eval X)) )
   -> foo

   : (pp 'foo)
   (de foo X
      (setq X (car X))
      (msg X)
      (length (eval X)) )
   -> foo

   : (foo (need 3))
   (need 3)
   -> 3

♪♫ Alex

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to