От: | Worminator X | #StandWithPalestine 🖤🤍💚 | |
Дата: | 06.07.24 00:26 | ||
Оценка: |
So something like
(((lambda (foo) (lambda (bar) (list foo bar))) 1) 2)
is not valid Common Lisp.
(setq User-counter 0)
(defun User (name)
(let
(
(id (setq User-counter (+ User-counter 1)))
)
(lambda (method)
(cond
((eq method 'getId) (lambda () 1))
((eq method 'getName) (lambda () "Worminator"))
((eq method 'data) (lambda () (list 1 "W")))
((eq method 'format) (lambda (f) (format NIL f 1 "Worminator")))
)
)
)
)
(print ((lambda(id name) (format NIL "id: ~d, name: ~s" id name)) 1 "Worminator"))
(print (((lambda(id name) (lambda (f) (format NIL f id name)) id name) 1 "Worminator") "id: ~d, name: ~s"))
(print (((lambda() (lambda (f) (format NIL f 1 "Worminator")))) "id: ~d, name: ~s"))
(print (((lambda() (lambda () (format NIL "id: ~d, name: ~s" 1 "Worminator"))))))