| Paste number 71402: | trying to make a function that generates functions |
| Pasted by: | ebil |
| When: | 7 months, 1 day ago |
| Share: | Tweet this! | http://paste.lisp.org/+1J3E |
| Channel: | #lisp |
| Paste contents: |
(defun maketemp ()
(let ((num 0))
(lambda (x)
(setq num (+ x num)))))
then try:
(setf blah (maketemp))
and:
(funcall blah 0)
and I get an error.Annotations for this paste:
| Annotation number 1: | re: |
| Pasted by: | v |
| When: | 7 months, 1 day ago |
| Share: | Tweet this! | http://paste.lisp.org/+1J3E#1 |
| Paste contents: |
(defun maketemp ()
(let ((num 0))
(lambda (x)
(setq num (+ x num)))))
then try:
(setf blah (maketemp))
and:
(funcall blah 0)
---------------------------
;;this would evaluate to
(lambda (x)
(setq 0 (+ x 0))
also it seems you are in common lisp, which has separate name spaces for functions and variables.
You may have to play around with the 'function' function to make it work...