From 776a77f033a2c93b740f86ae8f9426d9d7cf981a Mon Sep 17 00:00:00 2001 From: dzaima Date: Mon, 26 Apr 2021 10:04:32 +0300 Subject: [PATCH] new cc.bqn --- cc.bqn | 14 +++++++++----- src/h.h | 1 + src/sfns.c | 6 +++--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/cc.bqn b/cc.bqn index 426bf104..f6751bca 100755 --- a/cc.bqn +++ b/cc.bqn @@ -28,9 +28,9 @@ FChars ← {𝕨•FChars path∾𝕩} FLines ← {𝕨•FLines path∾𝕩} glyphs ← Import "glyphs.bqn" -compile ← glyphs Import "c.bqn" +_getComp ← { (3+useInd) ↑ (𝕗 Import "c.bqn"){𝔽} } useInd ← "-i"≡⊑args ⋄ args↓˜↩useInd -Comp ← (3+useInd) ↑ ((<"inc(runtime["∾⍕∾"])"˙)¨↕62)⊸Compile +Comp ← ((<"inc(runtime["∾⍕∾"])"˙)¨↕62) glyphs _getComp ⊢ J ← ∾∾⟜\n¨ Fconst ← ≡◶⟨@⊸≤◶Num‿Char, Str, ⊑⟩ prov ← {"inc("∾𝕩∾")"}¨"bi_type"‿"bi_fill"‿"bi_log"‿"bi_grLen"‿"bi_grOrd"‿"bi_asrt"‿"bi_add"‿"bi_sub"‿"bi_mul"‿"bi_div"‿"bi_pow"‿"bi_floor"‿"bi_eq"‿"bi_le"‿"bi_fne"‿"bi_shape"‿"bi_pick"‿"bi_ud"‿"bi_tbl"‿"bi_scan"‿"bi_fillBy"‿"bi_val"‿"bi_catch" @@ -38,15 +38,19 @@ Fout ← {((≠𝕩)↑⟨LI F¨,L ·prov⊸∾⍟(𝕨⊣0) Fconst¨,L (LI F¨) Frun ← 1⊸Fout Long ← {¯2↓∾𝕩∾¨<","∾\n} -LFC ← Long∘Fout∘Comp +RT ← {𝕩 + prims‿ref←Import"pr.bqn" ⋄ l←≠∾prims + Long Frun l⊸↓⌾(1⊸⊑) (↕l) prims _getComp ref +} CArg ← {J (¯5⊸↓∾𝕩˙)⌾⊑ FLines "c.bqn"} +LFC ← Long∘Fout∘Comp •Out⍟(¬return) (⊑"r"‿"c"‿"cc"‿"f"‿"e"‿"p"⊐⊏)◶⟨ - {𝕩⋄ref‿len←Import "pr.bqn"⋄Long Frun len⊸↓⌾(1⊸⊑)Comp ref} + RT {𝕩⋄LFC CArg "⟨"∾"⟩"«∾","⊸∾¨'"'(⊣∾∾˜)¨glyphs} {𝕩⋄LFC "{"∾"}"∾˜CArg"𝕩"} {𝕩⋄LFC FChars "f.bqn"} {𝕩⋄LFC SVG "e"} {𝕩⋄LFC SVG "p"} ¯1 ↓ · J L∘Fout∘Comp¨ -⟩ args +⟩ args \ No newline at end of file diff --git a/src/h.h b/src/h.h index 227c6b0a..eec1f839 100644 --- a/src/h.h +++ b/src/h.h @@ -346,6 +346,7 @@ usz o2s (B x) { if ((usz)x.f!=x.f) thrM("Expected integer"); return (usz)x.f; i64 o2i64 (B x) { if ((i64)x.f!=x.f) thrM("Expected integer"); return (i64)x.f; } f64 o2f (B x) { if (!isNum(x)) thrM("Expected integer"); return x.f; } i32 o2iu (B x) { return isI32(x)? (i32)(u32)x.u : (i32)x.f; } +usz o2su (B x) { return (usz)x.f; } i64 o2i64u(B x) { return (i64)x.f; } bool q_i32(B x) { return isI32(x) || isF64(x)&(x.f==(i32)x.f); } diff --git a/src/sfns.c b/src/sfns.c index fcfb09d6..f8293dbe 100644 --- a/src/sfns.c +++ b/src/sfns.c @@ -171,10 +171,10 @@ B pick_c1(B t, B x) { return r; } B pick_c2(B t, B w, B x) { - usz wu = o2s(w); - if (!isArr(x)) { dec(x); dec(w); thrM("⊑: 𝕩 wasn't an array"); } + // usz wu = o2s(w); + // if (!isArr(x)) { dec(x); dec(w); thrM("⊑: 𝕩 wasn't an array"); } // if (wu >= a(x)->ia) err("⊑: 𝕨 is greater than length of 𝕩"); // no bounds check for now - B r = TI(x).get(x, wu); + B r = TI(x).get(x, o2su(w)); dec(x); return r; }