omega-mcp
aien-dev/omega-mcp
Brought by drakestapleton
omega-mcp / data / examples / arith.om
| 1 | note signed and unsigned arithmetic, bit operations, comparisons and not |
| 2 | fn main to int |
| 3 | a = int 17 |
| 4 | b = int 5 |
| 5 | s = add a b |
| 6 | s = sub s mul a b |
| 7 | s = add s div a b |
| 8 | s = add s rem a b |
| 9 | x = uint 12 |
| 10 | x = and x 10 |
| 11 | x = or x 3 |
| 12 | x = xor x 6 |
| 13 | x = shl x 2 |
| 14 | x = shr x 1 |
| 15 | n = neg s |
| 16 | k = int 0 |
| 17 | if eq n 58 |
| 18 | k = add k 1 |
| 19 | end |
| 20 | if ne a b |
| 21 | k = add k 1 |
| 22 | end |
| 23 | if lt b a |
| 24 | k = add k 1 |
| 25 | end |
| 26 | if le a 17 |
| 27 | k = add k 1 |
| 28 | end |
| 29 | if gt a b |
| 30 | k = add k 1 |
| 31 | end |
| 32 | if ge b 5 |
| 33 | k = add k 1 |
| 34 | end |
| 35 | if not lt a b |
| 36 | k = add k 1 |
| 37 | end |
| 38 | ret add add n int x k |
| 39 | end |