aboutsummaryrefslogtreecommitdiffstats
path: root/examples/atom.milch
diff options
context:
space:
mode:
Diffstat (limited to 'examples/atom.milch')
-rw-r--r--examples/atom.milch14
1 files changed, 14 insertions, 0 deletions
diff --git a/examples/atom.milch b/examples/atom.milch
new file mode 100644
index 0000000..0ee6f8f
--- /dev/null
+++ b/examples/atom.milch
@@ -0,0 +1,14 @@
+(import "core/common")
+
+(let state (atom! 10))
+
+(let do-loop! (\![i n]
+ (match true
+ (lt? i n) (do (atom-update! inc state)
+ (do-loop! (inc i) n))
+ otherwise unit)))
+
+(do-loop! 0 5)
+
+(atom-get! state)
+; => 15