aboutsummaryrefslogtreecommitdiff
path: root/tutorial/evalexp.bqn
blob: 17c8c0db14e74e17823a5ef4e5d23d8ac1022900 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
wh  10.7524
pad wh×21
to  1+wh÷23
t   10

ps  At "class=Paren|stroke=currentColor|fill=none|stroke-width=1"
rc  At "class=code|stroke-width=1|rx=10"
gr  "g" At "font-family=BQN,monospace|font-size=18px"
gt  "g" At "text-anchor=middle"
gb  "g" At "class=codeCover|stroke-width=6|stroke-linejoin=round"
gf  "g" At "font-size=15px|opacity=0.9"
Shadow  {
  t  (0,0¯2+𝕨) ("text" Attr Pos)Enc¨ (⊢≍Highlight¨) ¨𝕩
  gt Enc gb,gf Enc¨<˘ t
}

DrawEval{
  ix𝕩˜i/𝕩' '
  f0=b(op'('=ix)-')'=ix
  lop<<«fnix"+-×÷⋆√"
  g⍋+`b
  ei¯1˜b{((𝕨<0)/𝕩)((𝕨>0)/)𝕩}(g)»+`f
  oei˜f/↕-(g)(1l)(⊢+fn×-)1-2×l
  g˜gl
  rev⍋+`¯1(¯1g)(⊣⍋⊏⊏˜⍋¬⊏˜)⍋+`+1glop
  m1+⌈´d+`×(rev)fn

  pt  f/⍉> wh×i,d
  off (o  (whׯ1.25m))- pt
  pd  pt (<(wh×0.60.1)+)˘ off
  dim (wh×𝕩,2+m)+20×pad
  tp  <˘pt+to+1(01×⌜˜ffn)×off
  (5120(⊣∾˜(t+pad)-˜-˜÷2˙)dim+2×t) SVG gr Enc ∾⥊¨
    <"rect" Elt rc(Pos-pad)"width""height"˘FmtNum¨dim
    <"text" Enc Highlight 𝕩
    (<"path" Elt ps"d"<·"Mvh"Fmt¨)˘ pd
    <tp Shadow f/ix
  
}