JanetDocsPlaygroundI'm feeling luckyGitHub sign in

map



    function
    boot.janet on line 869, column 1

    (map f & inds)

    Map a function over every value in a data structure and return an 
    array of the results.


3 examplesSign in to add an example
Loading...
# build own map-indexed with map

(defn map-indexed [f ds]
    (map f (range 0 (length ds)) ds))

(map-indexed (fn [i v] [i v] ) ["a" "b" "c" "d"])

# => @[(0 "a") (1 "b") (2 "c") (3 "d")]
leobmPlayground
(map |(+ $0 $1) [1 2 3] [4 5 6]) # @[5 7 9] - uses the fn shorthand
ahungryPlayground
(map string/from-bytes "Hello, world!")  # => @["H" "e" "l" "l" "o" "," " " "w" "o" "r" "l" "d" "!"]
GrayJackPlayground