JanetDocsSourcePlaygroundTutorialsI'm Feeling luckyCommunityGitHub sign in

mapcat

core-api


    function
    boot.janet on line 1112, column 1

    (mapcat f ind & inds)

    Map a function `f` over every value in a data structure `ind` and 
    use `array/concat` to concatenate the results, but only if no 
    `inds` are provided. Multiple data structures can be handled if 
    each `inds` is a data structure and `f` is a function of arity one 
    more than the number of `inds`. Note that `f` is only applied to 
    values at indeces up to the largest index of the shortest of `ind` 
    and each of `inds`.


2 examplesSign in to add an example
Loading...
(mapcat
  |[$0 $1 (* $0 $1)]
  [1 2 3]
  [100 200 300])
# => @[1 100 100 2 200 400 3 300 900]
taoeffectPlayground
# Convert an array of k/v pairs into a table

(def kvp @[[:foo 1] [:bar 2]])
(table ;(mapcat identity kvp))  # => @{:foo 1 :bar 2}
MikeBellerPlayground