diff options
Diffstat (limited to 'src')
| -rwxr-xr-x | src/cjs.bqn | 6 | ||||
| -rw-r--r-- | src/p.bqn | 19 |
2 files changed, 23 insertions, 2 deletions
diff --git a/src/cjs.bqn b/src/cjs.bqn index 30d94098..2a282b84 100755 --- a/src/cjs.bqn +++ b/src/cjs.bqn @@ -27,10 +27,12 @@ Fconst ← ≡◶⟨@⊸≤◶Num‿Char, Str, ⊑⟩ Fout ← (≠↑⟨F,Fconst,L F¨,F⟩˙) {L𝕎¨𝕩}¨ ⊢ Frun ← "provide"⊸Cat⌾(1⊸⊑) Fout Long ← ∾ (≠↑1‿3/⟨" "⊸∾⋄((@+10)∾" ,")⊸∾⟩˙) {𝕎𝕩}¨ ⊢ -•Out (⊑"r"‿"c"‿"f"‿"e"⊐⊏)◶⟨ +SVG ← {∾⟨"Modify←GetHighlights←⊢⋄"⟩∾ •FChars∘∾⟜".bqn"¨ "../svg"‿𝕩} +•Out (⊑"r"‿"c"‿"f"‿"e"‿"p"⊐⊏)◶⟨ {𝕩⋄ref‿len←•Import"pr.bqn"⋄Long Frun len⊸↓⌾(1⊸⊑)Comp ref} {𝕩⋄Long Fout Comp •FChars "c.bqn"} {𝕩⋄Long Fout Comp •FChars "f.bqn"} - {𝕩⋄Long Fout Comp ∾⟨"Modify←GetHighlights←⊢⋄"⟩∾ •FChars∘∾⟜".bqn"¨ "../svg"‿"e"} + {𝕩⋄Long Fout Comp SVG "e"} + {𝕩⋄Long Fout Comp SVG "p"} ¯1 ↓ · J L∘Fout∘Comp¨ ⟩ args diff --git a/src/p.bqn b/src/p.bqn new file mode 100644 index 00000000..bbff5417 --- /dev/null +++ b/src/p.bqn @@ -0,0 +1,19 @@ +# Plot + +dim← 2⥊384 +pad← 2⥊10 + +ps ← At "class=red|style=fill:none|stroke-width=1" +rc ← At "class=code|stroke-width=1|rx=5" +gr ← "g" At "font-family=BQN,monospace|font-size=18px" + +Plot ← { + "•Plot: 𝕨 and 𝕩 must be lists of numbers" ! 𝕨 ⊢⊘∧○((1==)◶⟨0,∧´@⊸>⟩) 𝕩 + "•Plot: 𝕨 and 𝕩 must have the same length" ! 𝕨 1⊘≡○≠ 𝕩 + Norm ← ÷⟜(⌈´)·-⟜(⌊´)1e300(⊣-⊸⌈⌊)⊢ + path ← 'M'⌾⊑ ∾⥊⍉ "L " ∾¨ FmtNum dim × (𝕨 ↕∘≠⊘⊣ 𝕩) ≍⟜¬○Norm 𝕩 + ((-pad)∾dim+2×pad) SVG gr Enc ⟨ + "rect" Elt rc∾(Pos-pad÷2)∾"width"‿"height"≍˘FmtNum dim+pad + ("path" Elt ps∾"d"≍○<⊢) path + ⟩ +} |
