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 / si / rosetta / exercises / pascals-triangle / .meta / example.om
| 1 | note Exercism-style exercise "pascals-triangle": https://exercism.org/tracks/python/exercises/pascals-triangle |
| 2 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | note rows writes the first count rows of Pascal's triangle into o, row after row (1, 1 1, 1 2 1, ...), |
| 4 | note and returns how many numbers it wrote. |
| 5 | note Check it with: sh exercise.sh exercises/pascals-triangle |
| 6 | om2 |
| 7 | fn rows count ulong o edit ulong * to ulong |
| 8 | for r ulong count |
| 9 | s = div mul r add r 1 2 |
| 10 | for c ulong add r 1 |
| 11 | v = ulong 1 |
| 12 | if and gt c 0 lt c r |
| 13 | b = sub sub add s c r 1 |
| 14 | v = add get o b get o add b 1 |
| 15 | end |
| 16 | put o add s c v |
| 17 | end |
| 18 | end |
| 19 | ret div mul count add count 1 2 |
| 20 | end |