aboutsummaryrefslogtreecommitdiffstats
path: root/examples/atom-concept.milch
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2022-12-09 15:53:16 +0200
committerJan Tuomi <jans.tuomi@gmail.com>2022-12-09 15:53:16 +0200
commit47c2eca7dceae9fb4e6f687f70273fb262fa07a2 (patch)
tree81554c139448a602a4e4126ca53e322c38c06cfa /examples/atom-concept.milch
parentd64c5725d79195fc6ef0472d4efa55737ebc00c3 (diff)
Add try! builtin
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