Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-kernel-template/blob/main/reference.py # omega-kernel-template aien-dev/omega-kernel-template Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-kernel-template / reference.py` 22 lines ยท 538 bytes Raw Blame History 1 """CPU reference for kernel.om, in plain Python. 2 3 Every fn in kernel.om needs a function here with the same name and parameters. 4 Return the exact mathematical answer; the check fails if the kernel disagrees. 5 Raise Trap(n) where the kernel executes `trap n` (Trap is provided by the check). 6 """ 7 8 9 def avg(a, b): 10 return (a + b) // 2 11 12 13 def gcd(a, b): 14 while b: 15 a, b = b, a % b 16 return a 17 18 19 def clamp(x, lo, hi): 20 if lo > hi: 21 raise Trap(3) # noqa: F821 - provided by tools/cases.py 22 return min(max(x, lo), hi)