2023-09-22 20:04:57 +00:00
|
|
|
($ mk-counter
|
|
|
|
(-> (init)
|
|
|
|
($ counter (- init 1))
|
|
|
|
(-> ()
|
|
|
|
(! counter (+ counter 1))
|
|
|
|
counter)))
|
|
|
|
|
|
|
|
($ a (mk-counter 5))
|
|
|
|
($ b (mk-counter 32))
|
|
|
|
|
|
|
|
(assert= 5 (a))
|
|
|
|
(assert= 32 (b))
|
|
|
|
(assert= 33 (b))
|
|
|
|
(assert= 6 (a))
|
|
|
|
(assert= 7 (a))
|
2023-09-25 19:28:57 +00:00
|
|
|
(assert= 34 (b))
|
|
|
|
|
|
|
|
($ (c) 42)
|
|
|
|
|
|
|
|
($ (d)
|
|
|
|
(+ (c) 1))
|
|
|
|
|
|
|
|
(assert= 43 (d))
|
|
|
|
|
|
|
|
|
|
|
|
($ hello 34)
|
|
|
|
|
|
|
|
($ (i)
|
|
|
|
($ (j)
|
|
|
|
($ (k)
|
|
|
|
(println hello))))
|
|
|
|
|
|
|
|
(((i)))
|
|
|
|
|
|
|
|
($ @m './mod2')
|
|
|
|
|
|
|
|
($ (u)
|
|
|
|
($ (v)
|
|
|
|
($ (w)
|
|
|
|
(assert= 42 m::var)
|
|
|
|
(assert= 14 (m::fun 7))
|
|
|
|
259 )))
|
|
|
|
|
|
|
|
(assert= 42 ((-> () m::var)))
|
|
|
|
(assert= 259 (((u))))
|