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 / queen-attack / .meta / example.om

33 lines · 814 bytes Raw Blame History
1note Exercism-style exercise "queen-attack": https://exercism.org/tracks/python/exercises/queen-attack
2note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3note Rows and columns run 0 .. 7. create checks one queen's position: 0 valid, 1 row negative,
4note 2 row past the board, 3 column negative, 4 column past the board (row checked first).
5note canattack is true when queens at (wr, wc) and (br, bc) share a row, column or diagonal.
6note Check it with: sh exercise.sh exercises/queen-attack
7om2
8fn create row long col long to int
9if lt row 0
10ret 1
11end
12if gt row 7
13ret 2
14end
15if lt col 0
16ret 3
17end
18if gt col 7
19ret 4
20end
21ret 0
22end
23fn canattack wr long wc long br long bc long to bool
24dr = sub wr br
25dc = sub wc bc
26if lt dr 0
27dr = neg dr
28end
29if lt dc 0
30dc = neg dc
31end
32ret or or eq dr 0 eq dc 0 eq dr dc
33end