Array concatenation: Difference between revisions

Content added Content deleted
(Add LDPL)
imported>Belowdecent
({{header|Odin}})
Line 3,197: Line 3,197:
# let array1and2 = Array.append array1 array2;;
# let array1and2 = Array.append array1 array2;;
val array1and2 : int array = [|1; 2; 3; 4; 5; 6|]</syntaxhighlight>
val array1and2 : int array = [|1; 2; 3; 4; 5; 6|]</syntaxhighlight>

=={{header|Odin}}==
<syntaxhighlight lang="odin">package main

import "core:fmt"
import "core:slice"

main :: proc() {
x: [3]int = {1, 2, 3}
y: [3]int = {4, 5, 6}

xy: [len(x) + len(y)]int
copy(xy[:], x[:])
copy(xy[len(x):], y[:])

fmt.println(xy)
}</syntaxhighlight>
===Using slices===
<syntaxhighlight lang="odin">package main

import "core:fmt"
import "core:slice"

main :: proc() {
x: [3]int = {1, 2, 3}
y: [3]int = {4, 5, 6}

fmt.println(slice.concatenate([][]int{x[:], y[:]}))
}</syntaxhighlight>


=={{header|Oforth}}==
=={{header|Oforth}}==