omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / tests / compiler / slices / zz_misc.osc
| 1 | // Slice value as another slice's index, empty slices, recursion passing a slice down. |
| 2 | // slice-run: pick bytes:0305 cells:4 -> 5 cells=0,0,0,5 |
| 3 | // slice-run: pick bytes:0905 cells:4 -> trap=BOUNDS |
| 4 | // slice-run: pick bytes:09 cells:4 -> trap=BOUNDS |
| 5 | // slice-run: pick bytes: cells:NULL -> trap=BOUNDS |
| 6 | // slice-run: sumc cells:3=1,2,3 -> 6 |
| 7 | // slice-run: sumc cells:0 -> 0 |
| 8 | fn pick(b: bytes, c: cells) -> u64 { |
| 9 | c[b[0]] = b[1]; |
| 10 | return c[3]; |
| 11 | } |
| 12 | fn sumc(c: cells) -> u64 { |
| 13 | let mut s: u64 = 0; |
| 14 | let mut i: u64 = 0; |
| 15 | while i < c.len bound 64 { s = s + c[i]; i = i + 1; } |
| 16 | return s; |
| 17 | } |