aboutsummaryrefslogtreecommitdiff
path: root/c.bqn
blob: 88f757393fd8072538c2331b3fe45f667d4e7cb0 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env bqn
Parse{
  x𝕩
  ax='←'at1avarsat/xx(/˜)¬aa(/˜)¬at
  lxox='('cx=')'sepx='⋄'va-˜x∊•d∾varsf¬ocvsep
  na(2×sep)+f×1+l0cv
  e/cd+`o-c
  ededb(⍋⍋ed)(⍋⊏d)⊏/o
  se-(el)˜{u(e)¨𝕩{(𝕩u)𝕨˜𝕨𝕩}¨´˘2(⊏⊔)𝕩u}(0<≠)ed
  fef×(l-1)++`(-s)((eb))l0
  fe(l-1)-l(`×)1˜sep
  ia+`l0f-l↑/f/fe
  sel¬(oc)/⍋(fe⌈↕l)-ia
  sel¨xna,vars
}

d64127-3
GenFn{
  xna,vars𝕩
  D16(•d∾"ABCDEF")
  fns{
    n•d⊐<𝕩
    n=≠•d:(D"20")vars⊐<𝕩
    n=0:80
    l2(⌊⋆)n
    (D"44")2˘88(⊣⥊×´)0,(112)1023+l,(2˜0l)n
  }{
    vvars⊐<𝕩v<≠vars:(D"22")v
    (¨(D"99")+((4)6))˜"|-⌈⌊√"⊐<𝕩
  }{
    (¨(D"1A")(D"A0")+↕6)˜"⋄+-×÷⌊⌈"⊐<𝕩
  }
  ((≠∾∾)varsd64)(D"0B")˜nafns{𝕎𝕩}¨x
}

Gen{
  LEB{0𝕩:0128+(¯1) 2⌽⍉ (`⌽∨´˘)/ 107(⊣⥊×´) ⍉⌽(82)𝕩}
  CLEB
  SC
  V≠∾∾
  IC•UCS
  tnb𝕩
  
   0(•UCS"asm")41
   1 S V (96∾C¨)¨t
   3 S V ¨↕≠n
   7 S V I(⊣∾0∾⊢)¨()n
  10 S V C¨ b
  
}

Compile{
  bodyGenFn Parse 𝕩
  (1↓∾)(","∾⥊)¨ Gen ⟨⟨01/¨¨d64  ⥊<"fn"  ⥊<body
}
Compile "b←3⋄d←(b×b)-4×2×1⋄((-b)+√d)÷2×2"