make a function like lambda

Q&A's, tips, howto's
Post Reply
ssqq
Posts: 88
Joined: Sun May 04, 2014 12:49 pm

make a function like lambda

Post by ssqq »

I want design a function:

Code: Select all

(context 'extend-env)
(extend-env:filter 1 2 3) --> (extend-env:filter 1 2 3)
In this context, some primitive function call would not evalute anything.

How to design this function?

ralph.ronnquist
Posts: 216
Joined: Mon Jun 02, 2014 1:40 am
Location: Melbourne, Australia

Re: make a function like lambda

Post by ralph.ronnquist »

What about:

Code: Select all

(define (extend-env:filter) (cons 'extend-env:filter (args))
or, if you don't want its arguments to be evaluated:

Code: Select all

(define-macro (extend-env:filter) (cons 'extend-env:filter (args))

ssqq
Posts: 88
Joined: Sun May 04, 2014 12:49 pm

Re: make a function like lambda

Post by ssqq »

Thanks ralph.ronnquist!

I want make a extend enviroment (context) to prevent all primitive function to evualte.

Code: Select all

(new Class 'extend-env)

(define (create-funcs f)
  (set (eval f) (append (lambda ()) (list (list 'cons f '(args))))))

(setq built-in (difference
                 (filter eval (symbols))
                 '(define context MAIN Class Tree create-funcs)))

(map create-funcs (map quote (map (fn (x) (sym x 'extend-env)) built-in)))

(save "extend-env.lsp" 'extend-env)

Post Reply