Skip to content

Commit 60c1305

Browse files
authored
Merge pull request #292 from sogaiu/add-mapcat-examples
Add examples for mapcat
2 parents a6d3ecf + 554bed7 commit 60c1305

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

examples/mapcat.janet

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# consolidate with array/concat after applying identity to each
2+
(mapcat identity [[-2 -1] [0 1 2] [7 8]]) # -> @[-2 -1 0 1 2 7 8]
3+
4+
# multiple data structures can be handled
5+
(mapcat tuple [:x :y] [-1 1]) # -> @[:x -1 :y 1]
6+
7+
# function may not be applied to all values (e.g. :z)
8+
(mapcat |(tuple $0 $1 $2) [:a :b] [:x :y :z] [0 1]) # -> @[:a :x 0 :b :y 1]
9+

0 commit comments

Comments
 (0)