mirror of
https://github.com/teo3300/rust-mal.git
synced 2026-01-12 01:05:32 +01:00
20 lines
262 B
Plaintext
20 lines
262 B
Plaintext
; atom?
|
|
(assert (atom? (atom 1)))
|
|
(assert (not (atom? 1)))
|
|
|
|
; deref
|
|
(assert-eq (deref (atom 1)) 1)
|
|
|
|
; @ macro
|
|
(assert-eq @(atom 1) 1)
|
|
|
|
(def! ATOM (atom 1))
|
|
|
|
; reset!
|
|
(reset! ATOM 2)
|
|
(assert-eq @ATOM 2)
|
|
|
|
; swap!
|
|
(swap! ATOM (fn* [x] (* x 2)))
|
|
(assert-eq @ATOM 4)
|