diff --git a/src/bqn/si.bqn b/src/bqn/si.bqn index 1803063..fa6a6d7 100644 --- a/src/bqn/si.bqn +++ b/src/bqn/si.bqn @@ -1,38 +1,50 @@ _bool ← {𝔽◶"#f"‿"#t"} env ← ⟨ - "sin", "cos", "tan", "asin", "acos", "atan", + "sin", "cos", "tan", "asin", "acos", "atan" "log", "+", "-", "*", "/", ">", "<", ">=", "<=", "=" "abs", "append", "apply", "begin", "car", "cdr", "cons" "eq?", "expt", "equal?", "length", "list", "list?" "map", "max", "min", "not", "null?", "number?" - "print", "round", "symbol?", "nil" + "print", "round", "symbol?", "nil", "pi" ⟩ •HashMap ⟨ ⋆⁼, +´, -´, ×´, ÷´, >´, <´, ≥´, ≤´, =´ |, ∾´, {𝕎𝕩}´, {𝕩}, ⊑, 1⊸↓, ⋈´ ≡´_bool, ⋆´, =´_bool, ≠, ⋈, 0⊸=_bool{•Type•BQN⎊1𝕩} {𝕎¨𝕩}´, ⌈´, ⌊´, 0⊸≠_bool¬, @⊸=_bool, •BQN⎊1 - •Show, ⌊0.5+⊢, 2⊸=_bool{•Type⊑𝕩}, @ + •Show, ⌊0.5+⊢, 2⊸=_bool{•Type⊑𝕩}, @, π ⟩ ∾˜ •math •ns.Get¨ "sin"‿"cos"‿"tan"‿"asin"‿"acos"‿"atan" Scheme ← { - T ← (-⟜1·+`·¬⊸∧⟜»⊸∨·+˝"( )"=⌜⊢)⊸⊔ + T ← (⊢/˜·∨´¨' '⊸≠)(-⟜1·+`·¬⊸∧⟜»⊸∨·+˝"( )"=⌜⊢)⊸⊔ R ← { 𝕊⟨⟩: "Empty program"!0; 𝕊𝕩: { - "("≡⊑𝕨 ? l ← ⟨⟩ ⋄ l⋈1↓{𝕊t‿ts: l∾↩*u8:c8" -R5RS ← {@+𝕩.Read¨ ↕1⊸+•_while_(0≠𝕩.Read)0}Ch∾@ +R5RS ← {@+𝕩.Read¨ ↕1⊸+•_while_(0≠𝕩.Read)0}Ch -("Not Compliant"⊸!Scheme≡R5RS)¨ "(+ 10 122)"‿"(* 4 2)" +("Not Compliant"⊸!Scheme≡R5RS)¨ ⟨ + "(+ 10 122)" + "(* 4 2)" + "(begin (define r 10) (+ (/ 4 2) (* r r)))" + "(if (> (* 11 11) 120) (* 7 6) oops)" +⟩ diff --git a/src/si.org b/src/si.org index c2ba498..7fb1666 100644 --- a/src/si.org +++ b/src/si.org @@ -1,5 +1,5 @@ # -*- eval: (face-remap-add-relative 'default '(:family "BQN386 Unicode" :height 180)); -*- -#+TITLE: Scheming a mise-en-abîme in BQN (WIP) +#+TITLE: Scheming a mise-en-abîme in BQN #+HTML_HEAD: #+HTML_HEAD: @@ -30,18 +30,18 @@ A global environment: #+begin_src bqn :tangle ./bqn/si.bqn env ← ⟨ - "sin", "cos", "tan", "asin", "acos", "atan", + "sin", "cos", "tan", "asin", "acos", "atan" "log", "+", "-", "*", "/", ">", "<", ">=", "<=", "=" "abs", "append", "apply", "begin", "car", "cdr", "cons" "eq?", "expt", "equal?", "length", "list", "list?" "map", "max", "min", "not", "null?", "number?" - "print", "round", "symbol?", "nil" + "print", "round", "symbol?", "nil", "pi" ⟩ •HashMap ⟨ ⋆⁼, +´, -´, ×´, ÷´, >´, <´, ≥´, ≤´, =´ |, ∾´, {𝕎𝕩}´, {𝕩}, ⊑, 1⊸↓, ⋈´ ≡´_bool, ⋆´, =´_bool, ≠, ⋈, 0⊸=_bool{•Type•BQN⎊1𝕩} {𝕎¨𝕩}´, ⌈´, ⌊´, 0⊸≠_bool¬, @⊸=_bool, •BQN⎊1 - •Show, ⌊0.5+⊢, 2⊸=_bool{•Type⊑𝕩}, @ + •Show, ⌊0.5+⊢, 2⊸=_bool{•Type⊑𝕩}, @, π ⟩ ∾˜ •math •ns.Get¨ "sin"‿"cos"‿"tan"‿"asin"‿"acos"‿"atan" #+end_src @@ -52,27 +52,29 @@ The interpreter: #+begin_src bqn :tangle ./bqn/si.bqn Scheme ← { - T ← (-⟜1·+`·¬⊸∧⟜»⊸∨·+˝"( )"=⌜⊢)⊸⊔ + T ← (⊢/˜·∨´¨' '⊸≠)(-⟜1·+`·¬⊸∧⟜»⊸∨·+˝"( )"=⌜⊢)⊸⊔ R ← { 𝕊⟨⟩: "Empty program"!0; 𝕊𝕩: { - "("≡⊑𝕨 ? l ← ⟨⟩ ⋄ l⋈1↓{𝕊t‿ts: l∾↩*u8:c8" - R5RS ← {@+𝕩.Read¨ ↕1⊸+•_while_(0≠𝕩.Read)0}Ch∾@ + R5RS ← {@+𝕩.Read¨ ↕1⊸+•_while_(0≠𝕩.Read)0}Ch #+end_src But fear not, there’s no room for monotony here. After all, people much prefer dealing with machinery to dealing with bureaucracies[fn:5]: #+begin_src bqn :tangle ./bqn/si.bqn :exports both - ("Not Compliant"⊸!Scheme≡R5RS)¨ "(+ 10 122)"‿"(* 4 2)" + ("Not Compliant"⊸!Scheme≡R5RS)¨ ⟨ + "(+ 10 122)" + "(* 4 2)" + "(begin (define r 10) (+ (/ 4 2) (* r r)))" + "(if (> (* 11 11) 120) (* 7 6) oops)" + ⟩ #+end_src #+RESULTS: -: ⟨ ⟨ "(+ 10 122)" "132" ⟩ ⟨ "(* 4 2)" "8" ⟩ ⟩ +: ⟨ 1 1 1 1 ⟩ -If you manage to find any sneaky corner cases that break the interpreter, do let me know! +If you manage to find any sneaky corner cases (modulo formatting, if you are comparing with Chicken) +that break the interpreter, do let me know! [fn:1] I recommend SICP as further reading. Much like Louis Reasoner, I attempted solving all the problems in the book, but I haven't gotten very far.