Skip to content

Experiments with native math support #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions bruijn/Circle.bruijn
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
:import std/Combinator .
:import std/Math .

# depth → dist → screen
# upper left quadrant
# split y [[[fixOr [0 (3 ++2 ++(++1)) (3 ++2 ++1) (3 ++2 ++1) (3 ++2 1)]]]]
# fixOr 0 >? (+5) [[1]]

# depth → x → y → screen
# upper right quadrant
split y [[[[fixOr [0 (4 ++3 --(2 ⋅ (+2)) (1 ⋅ (+2))) (4 ++3 (2 ⋅ (+2)) (1 ⋅ (+2))) (4 ++3 --(2 ⋅ (+2)) --(1 ⋅ (+2))) (4 ++3 (2 ⋅ (+2)) --(1 ⋅ (+2)))]]]]]
fixOr (sqrt ((1 ** (+2)) + (0 ** (+2)))) >? ((+4) ** 2) [[0]]

main [split (+0) (+1) (+1)]

# WORKING half-circle
y = \(\(0 0) \(1 (0 0)))
split = (y \\\\(gt (dec (pow <2> 2)) (sqrt (add (pow 1 <2>) (pow 0 <2>))) \\1 \(0 (4 (inc 3) (dec (mul 2 <2>)) (mul 1 <2>)) (4 (inc 3) (mul 2 <2>) (mul 1 <2>)) (4 (inc 3) (dec (mul 2 <2>)) (dec (mul 1 <2>))) (4 (inc 3) (mul 2 <2>) (dec (mul 1 <2>))))))
\(split <0> <1> <1>)

# y = \(\(0 0) \(1 (0 0)))
# split = (y \\\(eq (mod (log (add 1 0)) <2>) <1> \\1 \(0 (3 (dec 2) (dec 1)) (3 (dec 2) (inc 1)) (3 (inc 2) (dec 1)) (3 (inc 2) (inc 1)))))
# \(split <1> <1>)
7 changes: 7 additions & 0 deletions bruijn/Experiments.bruijn
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,10 @@ cantor-dust [y [build tl tr bl br]]
tr [[0 1 1 1 1]] (build b 0 b b)
bl [[0 1 1 1 1]] (build b b 0 b)
br [[0 1 1 1 1]] (build b b b 0)

# WEIRD sierpinski
# x → y → screen
weird [split (+0) (+0)]
split y [[[fixOr1 [0 (3 --2 --1) (3 ++2 --1) (3 --2 ++1) (3 ++2 ++1)]]]]
fixOr1 |(1 + 0) >? (+5) [[1]]
fixOr2 (|1 + |0) >? (+5) [[1]]
19 changes: 14 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,14 @@
>
Recursive Nonsense
</option>
<option
value="y = \(\(0 0) \(1 (0 0)))
c = \\\(2 0 1)
split = (y \\\\(eq (mod (max 1 0) <3>) <0> 2 \(0 (4 3 (dec (mul 2 <2>)) (mul 1 <2>)) (4 (c 3) (mul 2 <2>) (mul 1 <2>)) (4 (c 3) (dec (mul 2 <2>)) (dec (mul 1 <2>))) (4 3 (mul 2 <2>) (dec (mul 1 <2>))))))
\(split \\0 <1> <1>)"
>
Chebyshev Modulo
</option>
<option
value="-- some common definitions for copy-pasting
w = \\1
Expand Down Expand Up @@ -389,11 +397,11 @@
}, 0);
};

if (params.searchParams.has("term")) {
const t = parseBLC(decodeBase64(params.searchParams.get("term")))[0];
window.term.innerText = show(t);
render(t);
}
// if (params.searchParams.has("term")) {
// const t = parseBLC(decodeBase64(params.searchParams.get("term")))[0];
// window.term.innerText = show(t);
// render(t);
// }

window.examples.addEventListener("change", () => {
clearScreen(worker);
Expand All @@ -402,6 +410,7 @@

window.render.addEventListener("click", () => {
const t = parse(window.term.value);
console.log(show(t));
render(t);
params.searchParams.set("term", encodeBase64(t));
window.history.pushState({ path: params.href }, "", params.href);
Expand Down
Loading