lumbda/wasm/app
russell@unturf.com c50a9da7e8
wat tier: rationals — (/ 67 7) → 67/7 + arithmetic + reader + printer
Adds tag-9 rational type to the asm tier. Layout [tag=9, num:i32, den:i32].
make_rational normalizes via gcd and collapses to a fixnum when den
reduces to 1, so 14/2 stays as 7.

Arithmetic (+, -, *, /, =, <, >, <=, >=) now promotes to rational when
any argument is rational. Mixed fixnum/rational lifts the fixnum
accumulator into a rational mid-loop so (+ 1 1/2) returns 3/2, not 1/2.

Reader parses "67/7" literals via the existing atom path: after the
numerator's digits, if '/' follows we keep reading the denominator and
hand back a normalized rational. Falls through to symbol if either side
isn't all digits.

Printer renders rationals as "n/d". equal_p compares numbers by value
(1/2 = 2/4, 3 = 6/2). is_number / number? cover both fixnums and
rationals.

eval now treats rationals as self-evaluating — without this, '1/3'
parsed correctly but evaluated to VOID.

Mandelbrot demo: switched from (/ a b) to (quotient a b) for the
fixed-point math. The demo had been relying on integer truncation
that '/' no longer provides on tiers with R7RS-correct rationals.

Bignums still pending: 31-bit num/den overflows with huge denominators.
Real lift comes with the bignum task in the C tier (which has them) or
a new bignum module in the WAT.

Cross-tier check still hangs on the bigger TCO-heavy sections of
functional.lsp — separate from rationals. Will keep grinding.

Tests: unit 20/20, integration 8/8, functional 11/11.
2026-06-14 15:11:36 -04:00
..
demos wat tier: rationals — (/ 67 7) → 67/7 + arithmetic + reader + printer 2026-06-14 15:11:36 -04:00
fonts/chunkfive wasm/playground: cancel button, asm state-leak fix, restyle to match homepage 2026-06-14 12:13:20 -04:00
app.js wat iter-5: TCO via return_call + dotted pairs + bend gpu demo 2026-06-14 14:18:41 -04:00
crypto.js playground: free-form code option + encrypted vault, single-scroll layout 2026-06-14 12:56:25 -04:00
index.html wat iter-5: TCO via return_call + dotted pairs + bend gpu demo 2026-06-14 14:18:41 -04:00
lumbda-logo-green.png wasm/playground: cancel button, asm state-leak fix, restyle to match homepage 2026-06-14 12:13:20 -04:00
repl.html wat iter-1: special forms + 35 primitives toward asm/lumbda.s parity 2026-06-14 12:30:01 -04:00
runner.js playground+repl: bend dispatch from WASM + 1.33 zoom + free-form runner 2026-06-14 13:05:06 -04:00
style.css playground+repl: bend+vault on one line, grid-only layout, hidden fix 2026-06-14 13:11:09 -04:00
worker.mjs playground+repl: bend dispatch from WASM + 1.33 zoom + free-form runner 2026-06-14 13:05:06 -04:00