Skip to content

Commit f849f73

Browse files
authored
Merge pull request #291 from sogaiu/add-map-examples
Add examples for map
2 parents 3c81fce + a84a0fc commit f849f73

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

examples/map.janet

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# inc is applied to every value of the input data structure
2+
(map inc [7 8 9]) # -> @[8 9 10]
3+
4+
# multiple data structures can be handled
5+
(map array [:x :y] [-1 1]) # -> @[@[:x -1] @[:y 1]]
6+
7+
# result array has length of the shortest input data structure
8+
(map |(pos? (+ ;$&)) [1 2 3] [-1 -2 -3] [0 1]) # -> @[false true]
9+

0 commit comments

Comments
 (0)