Add a dynamic data structure example
This commit is contained in:
parent
d423fe9958
commit
8aa00fea27
|
@ -0,0 +1,22 @@
|
|||
(load "../lang/dlambda.lisp")
|
||||
(load "../lang/functions.lisp")
|
||||
|
||||
(define-special keys (&rest fields)
|
||||
(eval
|
||||
(list 'let (mapcar 'list fields)
|
||||
'(eval
|
||||
(dlambda
|
||||
(:get (field) (eval field))
|
||||
(:set (field value) (set field value)))))))
|
||||
|
||||
(defun process-data (data)
|
||||
(let ((one (call data :get 'one))
|
||||
(two (call data :get 'two))
|
||||
(three (call data :get 'three)))
|
||||
(list one two three)))
|
||||
|
||||
(setq data (keys one two three))
|
||||
(call data :set 'one "goodbye")
|
||||
(call data :set 'two "key")
|
||||
(call data :set 'three "!")
|
||||
(process-data data)
|
Loading…
Reference in New Issue