Skip to content

Commit d97afda

Browse files
authored
Merge pull request #285 from rwtolbert/example_eachk
add examples for eachk
2 parents bc44c63 + eda9bed commit d97afda

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 [:a :b :c :d :e] (prin i " ")) # -> nil
4+
5+
# prints 0 1 2 3 4
6+
(eachk i @["a" "b" "c" "d" "e"] (prin i " ")) # -> nil
7+
8+
# prints keys in table/struct in an unspecified order
9+
# prints :b :a
10+
(eachk k {:a 1 :b 2} (prinf "%v " k)) # -> nil
11+
12+
# prints :foo :bar
13+
(eachk k @{:foo "A" :bar "B"} (prinf "%v " k)) # -> nil

0 commit comments

Comments
 (0)