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