~garritfra/antimony

ref: 5e8aad974f24e782bf8ee9319a238ee1aa0892a0 antimony/lib/array.sb -rw-r--r-- 402 bytes
5e8aad97Garrit Franke fix(ci): deploy action 1 year, 1 month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Prints the size of an array
fn len(arr: int[]): int {
    let c: int = 0
    while arr[c] {
        c += 1
    }

    return c
}

// Reverses an array
// TODO: fix me!
fn rev(arr: int[]): int[] {

    let l: int = len(arr)
    let new_arr: int[] = []

    let i: int = 0
    let j: int = l
    while i < l {
        new_arr[i] = arr[j]
        i = i - 1
        j = j - 1
    }

    return new_arr
}