my-test-2   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/examples/core/extempore_lang.xtm

Implementation

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Because we are working with closures
;; we can "close" over free variables
;; in this example we close over power
;; to maintain state between calls
;;
;; increment power each call
(bind-func my-test-2
  (let ((power 0))
    (lambda (x)
      (set! power (+ power 1)) ;; set! for closure mutation as per scheme
      (* x power))))


Back to Index