interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / si / rosetta / exercises / series / .meta / example.om

35 lines · 751 bytes Raw Blame History
1note Exercism-style exercise "series": https://exercism.org/tracks/python/exercises/series
2note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3note slices writes every contiguous run of k bytes of s, in order, joined by commas, into o and
4note returns the number of bytes written; or -1 when s is empty, -2 when k is negative, -3 when k is
5note zero, -4 when k is longer than s.
6note Check it with: sh exercise.sh exercises/series
7om2
8fn slices s view uchar * k long o edit uchar * to long
9n = len s
10if eq n 0
11ret -1
12end
13if lt k 0
14ret -2
15end
16if eq k 0
17ret -3
18end
19w = ulong k
20if gt w n
21ret -4
22end
23p = ulong 0
24for i ulong add sub n w 1
25if gt i 0
26put o p 44
27p = add p 1
28end
29for j ulong w
30put o p get s add i j
31p = add p 1
32end
33end
34ret long p
35end