RosettaCodeData/Task/Array-concatenation/Onyx/array-concatenation.onyx

14 lines
530 B
Plaintext

# With two arrays on the stack, cat pops
# them, concatenates them, and pushes the result back
# on the stack. This works with arrays of integers,
# strings, or whatever. For example,
[1 2 3] [4 5 6] cat # result: [1 2 3 4 5 6]
[`abc' `def'] [`ghi' `jkl'] cat # result: [`abc' `def' `ghi' `jkl']
# To concatenate more than two arrays, push the number of arrays
# to concatenate onto the stack and use ncat. For example,
[1 true `a'] [2 false `b'] [`3rd array'] 3 ncat
# leaves [1 true `a' 2 false `b' `3rd array'] on the stack