JanetDocsSourcePlaygroundTutorialsI'm Feeling luckyCommunityGitHub sign in

mapcat

core-api


    function
    boot.janet on line 1230, column 1

    (mapcat f x & xs)

    Map a function `f` over every value in `x` and use `array/concat` 
    to concatenate the results.

    Also functions variadically, i.e. takes additional arguments, with 
    suitable changes to the arity of `f`. `f` is called with both 
    values from `x` and additional arguments, and only as many times as 
    the length of the shortest of `x` and each element of `xs`. If `x` 
    or any element of `xs` is empty, returns an empty array.

    `x` and elements of `xs` can be values of type bytes, indexed, 
    dictionary, fiber, or abstract with suitable `get` and `next` 
    methods.


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