JanetDocsSourcePlaygroundTutorialsI'm Feeling luckyCommunityGitHub sign in

array/concat

core-api


    cfunction
    src/core/array.c on line 250, column 1

    (array/concat arr & parts)

    Concatenates `parts`, a variable number of arrays and tuples, into 
    the first argument `arr` which must be an array. If any of `parts` 
    are arrays or tuples, their values are inserted into `arr`. 
    Otherwise, each value in `parts` will be appended to `arr` in 
    order. Returns `arr`.


3 examplesSign in to add an example
Loading...
# Flatten single level of nested collections

(def foo [ [[1 2] [3 4]]   
           [[5 6] [7 8]] ])

(apply array/concat @[] foo) # => @[(1 2) (3 4) (5 6) (7 8)]
maradPlayground
(def a @[1 2])
(def b @[1 2])
(= a b)  # => false

(def a @[1 2])
(def b (array/concat a 3))
a        # => @[1 2 3]
b        # => @[1 2 3]
(= a b)  # => true
cellularmitosisPlayground
(def a @[1 2])
(array/concat a 3 [4 5] @[6 7] [] @[] 8)
a  # => @[1 2 3 4 5 6 7 8]
cellularmitosisPlayground