Skip to content

Commit 255547e

Browse files
committed
add examples for eachk
1 parent 8aed1b1 commit 255547e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

examples/eachk.janet

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# keys for tuple/array are 0-based index
2+
# prints 0 1 2 3 4
3+
(eachk i [1 2 3 4 5] (prin i " "))
4+
5+
# prints 0 1 2 3 4
6+
(eachk i @[1 2 3 4 5] (prin i " "))
7+
8+
# keys table/struct, but maybe not in order
9+
# prints :b :a
10+
(eachk k {:a 1 :b 2} (prinf "%v " k))
11+
12+
# prints :foo :bar
13+
(eachk k @{:foo "A" :bar "B"} (prinf "%v " k))

0 commit comments

Comments
 (0)