Skip to content

Commit 9399b9a

Browse files
authored
Merge pull request #270 from rwtolbert/examples_delay
add examples for delay
2 parents d5fa463 + dd6d9b7 commit 9399b9a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

examples/delay.janet

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
(def setup-once
2+
(let [setup |(print "running setup")]
3+
(delay
4+
(setup)
5+
"setup complete")))
6+
7+
# first run will print "running setup" followed by "setup complete"
8+
(printf "first run: %s" (setup-once))
9+
10+
# after that, only prints cached value "setup complete"
11+
(printf "second run: %s" (setup-once))

0 commit comments

Comments
 (0)