All pastes #273813 Raw Edit

Miscellany

public text v1 · immutable
·published 2006-12-10 04:12 UTC
rendered paste body
CL-USER > (defun generator (start)
  (let ((x start))
    (lambda ()
      (incf x))))
GENERATOR

CL-USER > (defparameter g (generator 10))
G

CL-USER > (funcall g)
11

CL-USER > (funcall g)
12

CL-USER > (defparameter h (generator 20))
H

CL-USER > (funcall h)
21

CL-USER > (funcall h)
22

CL-USER > (funcall g)
13