Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
28
Task/Array-concatenation/Genie/array-concatenation.genie
Normal file
28
Task/Array-concatenation/Genie/array-concatenation.genie
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
[indent=4]
|
||||
/*
|
||||
Array concatenation, in Genie
|
||||
Tectonics: valac array-concat.gs
|
||||
*/
|
||||
|
||||
/* Creates a new array */
|
||||
def int_array_concat(x:array of int, y:array of int):array of int
|
||||
var a = new Array of int(false, true, 0) /* (zero-terminated, clear, size) */
|
||||
a.append_vals (x, x.length)
|
||||
a.append_vals (y, y.length)
|
||||
|
||||
z:array of int = (owned) a.data
|
||||
return z
|
||||
|
||||
def int_show_array(a:array of int)
|
||||
for element in a do stdout.printf("%d ", element)
|
||||
stdout.printf("\n")
|
||||
|
||||
init
|
||||
x: array of int = {1, 2, 3}
|
||||
y: array of int = {3, 2, 1, 0, -1}
|
||||
z: array of int = int_array_concat(x, y)
|
||||
|
||||
stdout.printf("x: "); int_show_array(x)
|
||||
stdout.printf("y: "); int_show_array(y)
|
||||
stdout.printf("z: "); int_show_array(z)
|
||||
print "%d elements in new array", z.length
|
||||
Loading…
Add table
Add a link
Reference in a new issue