interplane.Get Omega
Read in your language

omega-projects

aien-dev/omega-projects

Brought by drakestapleton

Project: Calculator

closed 1710e028518ebc34 #7 · opened 2026-10-26 17:08 UTC · closed 2026-10-31 11:42 UTC

Imported from GitHub aien-dev/omega-projects#7, by drakestapleton

Labels: test, from-aien, built-with-aien

Base 4f405e1093b923d8252cead889c4669b7e0c3cdf · Head c4db98928e79197251c425acd9df605dfe2d0657

drakestapleton wrote on 2026-10-26 17:08 UTC

Calculator

A four-function calculator: Omega arithmetic compiled to WebAssembly.

Built with Allen by calc-tester-60d8065f. Files:

  • projects/calc-tester-60d8065f/calculator/README.md
  • projects/calc-tester-60d8065f/calculator/calc.om
  • projects/calc-tester-60d8065f/calculator/index.html
  • projects/calc-tester-60d8065f/calculator/meta.json

Drake reviews this project before it goes live; merging publishes it at https://aien-dev.github.io/omega-projects/projects/calc-tester-60d8065f/calculator/


Filed by Allen from aienos.com/allen/ after the visitor confirmed this exact text.

Apply it

git checkout -b patch-1710e028518ebc34 4f405e1093b923d8252cead889c4669b7e0c3cdf
curl -fsSL https://interplane.io/drakestapleton/omega-projects/patches/1710e028518ebc34.patch | git am

Raw patch (mbox) · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/omega-projects
7
c4db98928e79197251c425acd9df605dfe2d0657
{"kind":"github-import","owner":"aien-dev","repo":"omega-projects","number":7,"url":"https://github.com/aien-dev/omega-projects/pull/7","export_sha256":"5fcc101474e8e28d3abd3c72e36b4786bb347ff52ceb64106150ef29ac69ae73","imported_utc":"2026-11-18T16:39:53Z"}

Changes

diff --git a/projects/calc-tester-60d8065f/calculator/README.md b/projects/calc-tester-60d8065f/calculator/README.md
new file mode 100644
index 0000000..c7dc812
--- /dev/null
+++ b/projects/calc-tester-60d8065f/calculator/README.md
@@ -0,0 +1,10 @@
+# Calculator
+
+A four-function calculator for whole numbers. The arithmetic is written in Omega (`calc.om`),
+compiled to WebAssembly by Allen's Omega compiler, and run by `index.html` in the browser with
+nothing loaded from elsewhere.
+
+Who it helps: anyone who wants a tiny, readable example of an Omega program running on a web
+page, and students checking quick sums. Division by zero returns 0.
+
+Built with Allen at https://www.aienos.com/allen/ (end-to-end test of the build loop).
diff --git a/projects/calc-tester-60d8065f/calculator/calc.om b/projects/calc-tester-60d8065f/calculator/calc.om
new file mode 100644
index 0000000..efd2fe0
--- /dev/null
+++ b/projects/calc-tester-60d8065f/calculator/calc.om
@@ -0,0 +1,16 @@
+fn plus a long b long to long
+ret add a b
+end
+fn minus a long b long to long
+ret sub a b
+end
+fn times a long b long to long
+ret mul a b
+end
+fn quot a long b long to long
+q = long 0
+if ne b 0
+q = div a b
+end
+ret q
+end
diff --git a/projects/calc-tester-60d8065f/calculator/index.html b/projects/calc-tester-60d8065f/calculator/index.html
new file mode 100644
index 0000000..f3c892a
--- /dev/null
+++ b/projects/calc-tester-60d8065f/calculator/index.html
@@ -0,0 +1,23 @@
+<!doctype html>
+<html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
+<title>Calculator</title>
+<style>body{font:18px/1.5 system-ui,sans-serif;max-width:28rem;margin:2rem auto;padding:0 1rem}
+input,select,button{font:inherit;padding:.3rem}</style>
+<h1>Calculator</h1>
+<p>Whole numbers, computed by Omega compiled to WebAssembly.</p>
+<p><input id=a type=number value=12> <select id=op><option value=plus>+</option><option value=minus>-</option>
+<option value=times>&times;</option><option value=quot>&divide;</option></select> <input id=b type=number value=3>
+<button id=go>=</button> <output id=out></output></p>
+<script>
+const bytes = Uint8Array.from(atob("AGFzbQEAAAABmYCAgAAEYAJ+fgF+YAJ+fgF+YAJ+fgF+YAJ+fgF+A4WAgIAABAABAgMHn4CAgAAEBHBsdXMAAAVtaW51cwABBXRpbWVzAAIEcXVvdAADCsqCgIAABMSAgIAAAwN+AX8BfiAAIQIgASEDAkADQCAFQQBGBEAgAiADfCEGIAIgBoUgAyAGhYNCAFMEQAALIAYiBiAGIQQgBA8LAAsLAAvEgICAAAMDfgF/AX4gACECIAEhAwJAA0AgBUEARgRAIAIgA30hBiACIAaFIAIgA4WDQgBTBEAACyAGIgYgBiEEIAQPCwALCwALxYCAgAADA34BfwF+IAAhAiABIQMCQANAIAVBAEYEQCACIAN+IQYgAlBFBEAgBiACfyADUgRAAAsLIAYiBiAGIQQgBA8LAAsLAAvogICAAAMFfgF/AX4gACECIAEhAwJAA0AgB0EARgRAQgAhBCAEIQUgAyAEUq0hBkECIQcgBqdFDQFBASEHDAELIAdBAUYEQCACIAN/IQggCCIIIAghBUECIQcMAQsgB0ECRgRAIAUPCwALCwAL"), c => c.charCodeAt(0));
+WebAssembly.instantiate(bytes, {}).then(({ instance }) => {
+  const run = () => {
+    const f = instance.exports[document.getElementById('op').value];
+    const a = BigInt(document.getElementById('a').value || 0), b = BigInt(document.getElementById('b').value || 0);
+    document.getElementById('out').textContent = String(f(a, b));
+  };
+  document.getElementById('go').addEventListener('click', run);
+  run();
+});
+</script>
+</html>
diff --git a/projects/calc-tester-60d8065f/calculator/meta.json b/projects/calc-tester-60d8065f/calculator/meta.json
new file mode 100644
index 0000000..a8722e8
--- /dev/null
+++ b/projects/calc-tester-60d8065f/calculator/meta.json
@@ -0,0 +1,15 @@
+{
+  "built_with": "Allen",
+  "description": "A four-function calculator: Omega arithmetic compiled to WebAssembly.",
+  "files": [
+    "README.md",
+    "calc.om",
+    "index.html"
+  ],
+  "handle": "calc-tester-60d8065f",
+  "item": "0fc57c8a88dd56f7b589",
+  "project": "calculator",
+  "saved": "2026-10-26",
+  "title": "Calculator",
+  "v": 1
+}