Skip to content

Commit

Permalink
Merge pull request #285 from rwtolbert/example_eachk
Browse files Browse the repository at this point in the history
add examples for eachk
  • Loading branch information
sogaiu authored Feb 5, 2025
2 parents bc44c63 + eda9bed commit d97afda
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions examples/eachk.janet
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# keys for tuple/array are 0-based index
# prints 0 1 2 3 4
(eachk i [:a :b :c :d :e] (prin i " ")) # -> nil

# prints 0 1 2 3 4
(eachk i @["a" "b" "c" "d" "e"] (prin i " ")) # -> nil

# prints keys in table/struct in an unspecified order
# prints :b :a
(eachk k {:a 1 :b 2} (prinf "%v " k)) # -> nil

# prints :foo :bar
(eachk k @{:foo "A" :bar "B"} (prinf "%v " k)) # -> nil

0 comments on commit d97afda

Please sign in to comment.