| 16 | u:t_okens := { s -> | {{}^{\mathrm{u}}\mathrm{\underline{t}okens}}\ {\leftarrow}\ {\{}\ {\mathrm{s}}\ {\to} | utokens ← { s → |
| 17 | num := 0 + s m_ember? "0123456789." | \ \ {\mathrm{num}}\ {\leftarrow}\ {0}\ {+}\ {\mathrm{s}}\ {\mathrm{\underline{m}ember}{?}}\ {\text{"0123456789."}} | num ← 0 + s member? "0123456789." |
| 18 | par := 0 + s m_ember? "()" | \ \ {\mathrm{par}}\ {\leftarrow}\ {0}\ {+}\ {\mathrm{s}}\ {\mathrm{\underline{m}ember}{?}}\ {\text{"()"}} | par ← 0 + s member? "()" |
| 19 | c := num + (3 * par) + 2 * (s != f_irst " ") & (num + par) = 0 | \ \ {\mathrm{c}}\ {\leftarrow}\ {\mathrm{num}}\ {+}\ {(}{3}\ {\times}\ {\mathrm{par}}{)}\ {+}\ {2}\ {\times}\ {(}{\mathrm{s}}\ {\neq}\ {\mathrm{\underline{f}irst}}\ {\text{" "}}{)}\ {\wedge}\ {(}{\mathrm{num}}\ {+}\ {\mathrm{par}}{)}\ {=}\ {0} | c ← num + (3 × par) + 2 × (s = first " ") ∧ (num + par) = 0 |
| 20 | starts := (c != 0) & (c = 3) | c != 0 c_at -1 d_rop c | \ \ {\mathrm{starts}}\ {\leftarrow}\ {(}{\mathrm{c}}\ {\neq}\ {0}{)}\ {\wedge}\ {(}{\mathrm{c}}\ {=}\ {3}{)}\ {\vee}\ {\mathrm{c}}\ {\neq}\ {0}\ {\mathrm{\underline{c}at}}\ {-1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{c}} | starts ← (c = 0) ∧ (c = 3) ∨ c = 0 cat −1 drop c |
| 21 | ((c != 0) * '+ s_\ starts) p_artition s | \ \ {(}{(}{\mathrm{c}}\ {\neq}\ {0}{)}\ {\times}\ {\text{'}}{+}\ {\mathrm{\underline{s}}{\backslash}}\ {\mathrm{starts}}{)}\ {\mathrm{\underline{p}artition}}\ {\mathrm{s}} | ((c = 0) × ’+ s\ starts) partition s |
| 22 | } | {\}} | } |
| 23 | t := u:t_okens "2*(3 + 4) - 10" | {\mathrm{t}}\ {\leftarrow}\ {{}^{\mathrm{u}}\mathrm{\underline{t}okens}}\ {\text{"2*(3 + 4) - 10"}} | t ← utokens "2*(3 + 4) - 10" |
| 24 | t | {\mathrm{t}} | t |
| 27 | u:k_ind := { b -> | {{}^{\mathrm{u}}\mathrm{\underline{k}ind}}\ {\leftarrow}\ {\{}\ {\mathrm{b}}\ {\to} | ukind ← { b → |
| 28 | d := d_isclose b | \ \ {\mathrm{d}}\ {\leftarrow}\ {\mathrm{\underline{d}isclose}}\ {\mathrm{b}} | d ← disclose b |
| 29 | f_irst d m_ember? "0123456789." ? 1 | \ \ {\mathrm{\underline{f}irst}}\ {\mathrm{d}}\ {\mathrm{\underline{m}ember}{?}}\ {\text{"0123456789."}}\ {?}\ {1} | first d member? "0123456789." ? 1 |
| 30 | d m_atch "(" ? 3 | \ \ {\mathrm{d}}\ {\mathrm{\underline{m}atch}}\ {\text{"("}}\ {?}\ {3} | d match "(" ? 3 |
| 31 | d m_atch ")" ? 4 | \ \ {\mathrm{d}}\ {\mathrm{\underline{m}atch}}\ {\text{")"}}\ {?}\ {4} | d match ")" ? 4 |
| 32 | 2 | \ \ {2} | 2 |
| 33 | } | {\}} | } |
| 34 | 'u:k_ind e_ach t | {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{k}ind}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{t}} | ’ukind each t |
| 43 | u:e_xt := { a b -> 1 = t_ally a ? (t_ally b) r_eshape a; a } | {{}^{\mathrm{u}}\mathrm{\underline{e}xt}}\ {\leftarrow}\ {\{}\ {\mathrm{a}}\ {\mathrm{b}}\ {\to}\ {1}\ {=}\ {\mathrm{\underline{t}ally}}\ {\mathrm{a}}\ {?}\ {(}{\mathrm{\underline{t}ally}}\ {\mathrm{b}}{)}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{a}}{\diamond}\ {\mathrm{a}}\ {\}} | uext ← { a b → 1 = tally a ? (tally b) reshape a⋄ a } |
| 44 | u:p_ick := { o pv -> | {{}^{\mathrm{u}}\mathrm{\underline{p}ick}}\ {\leftarrow}\ {\{}\ {\mathrm{o}}\ {\mathrm{pv}}\ {\to} | upick ← { o pv → |
| 45 | p := (d_isclose 1 s_elect pv) - o | \ \ {\mathrm{p}}\ {\leftarrow}\ {(}{\mathrm{\underline{d}isclose}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{pv}}{)}\ {-}\ {\mathrm{o}} | p ← (disclose 1 select pv) − o |
| 46 | v := d_isclose 2 s_elect pv | \ \ {\mathrm{v}}\ {\leftarrow}\ {\mathrm{\underline{d}isclose}}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{pv}} | v ← disclose 2 select pv |
| 47 | lo := f_loor p | \ \ {\mathrm{lo}}\ {\leftarrow}\ {\mathrm{\underline{f}loor}}\ {\mathrm{p}} | lo ← floor p |
| 48 | f := p - f_loat lo | \ \ {\mathrm{f}}\ {\leftarrow}\ {\mathrm{p}}\ {-}\ {\mathrm{\underline{f}loat}}\ {\mathrm{lo}} | f ← p − float lo |
| 49 | n := t_ally v | \ \ {\mathrm{n}}\ {\leftarrow}\ {\mathrm{\underline{t}ally}}\ {\mathrm{v}} | n ← tally v |
| 50 | c_lip := { k -> 1 + 0 m_ax (n - 1) m_in k } | \ \ {\mathrm{\underline{c}lip}}\ {\leftarrow}\ {\{}\ {\mathrm{k}}\ {\to}\ {1}\ {+}\ {0}\ {\mathrm{\underline{m}ax}}\ {(}{\mathrm{n}}\ {-}\ {1}{)}\ {\mathrm{\underline{m}in}}\ {\mathrm{k}}\ {\}} | clip ← { k → 1 + 0 max (n − 1) min k } |
| 51 | ((1 - f) * (c_lip lo) s_elect v) + f * (c_lip lo + 1) s_elect v | \ \ {(}{(}{1}\ {-}\ {\mathrm{f}}{)}\ {\times}\ {(}{\mathrm{\underline{c}lip}}\ {\mathrm{lo}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{v}}{)}\ {+}\ {\mathrm{f}}\ {\times}\ {(}{\mathrm{\underline{c}lip}}\ {\mathrm{lo}}\ {+}\ {1}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{v}} | ((1 − f) × (clip lo) select v) + f × (clip lo + 1) select v |
| 52 | } | {\}} | } |
| 53 | u:d_yad := { op olr -> | {{}^{\mathrm{u}}\mathrm{\underline{d}yad}}\ {\leftarrow}\ {\{}\ {\mathrm{op}}\ {\mathrm{olr}}\ {\to} | udyad ← { op olr → |
| 54 | o := f_irst d_isclose 1 s_elect olr | \ \ {\mathrm{o}}\ {\leftarrow}\ {\mathrm{\underline{f}irst}}\ {\mathrm{\underline{d}isclose}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{olr}} | o ← first disclose 1 select olr |
| 55 | a := d_isclose 2 s_elect olr | \ \ {\mathrm{a}}\ {\leftarrow}\ {\mathrm{\underline{d}isclose}}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{olr}} | a ← disclose 2 select olr |
| 56 | b := d_isclose 3 s_elect olr | \ \ {\mathrm{b}}\ {\leftarrow}\ {\mathrm{\underline{d}isclose}}\ {3}\ {\mathrm{\underline{s}elect}}\ {\mathrm{olr}} | b ← disclose 3 select olr |
| 57 | op m_atch "pick" ? o u:p_ick (e_nclose a) c_at e_nclose b | \ \ {\mathrm{op}}\ {\mathrm{\underline{m}atch}}\ {\text{"pick"}}\ {?}\ {\mathrm{o}}\ {{}^{\mathrm{u}}\mathrm{\underline{p}ick}}\ {(}{\mathrm{\underline{e}nclose}}\ {\mathrm{a}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{e}nclose}}\ {\mathrm{b}} | op match "pick" ? o upick (enclose a) cat enclose b |
| 58 | op m_atch "iota" ? o + f_loat (a i_ndexOf b) - 1 | \ \ {\mathrm{op}}\ {\mathrm{\underline{m}atch}}\ {\text{"iota"}}\ {?}\ {\mathrm{o}}\ {+}\ {\mathrm{\underline{f}loat}}\ {(}{\mathrm{a}}\ {\mathrm{\underline{i}ndexOf}}\ {\mathrm{b}}{)}\ {-}\ {1} | op match "iota" ? o + float (a indexOf b) − 1 |
| 59 | l := a u:e_xt b | \ \ {\mathrm{l}}\ {\leftarrow}\ {\mathrm{a}}\ {{}^{\mathrm{u}}\mathrm{\underline{e}xt}}\ {\mathrm{b}} | l ← a uext b |
| 60 | r := b u:e_xt a | \ \ {\mathrm{r}}\ {\leftarrow}\ {\mathrm{b}}\ {{}^{\mathrm{u}}\mathrm{\underline{e}xt}}\ {\mathrm{a}} | r ← b uext a |
| 61 | op m_atch "+" ? l + r | \ \ {\mathrm{op}}\ {\mathrm{\underline{m}atch}}\ {\text{"+"}}\ {?}\ {\mathrm{l}}\ {+}\ {\mathrm{r}} | op match "+" ? l + r |
| 62 | op m_atch "-" ? l - r | \ \ {\mathrm{op}}\ {\mathrm{\underline{m}atch}}\ {\text{"-"}}\ {?}\ {\mathrm{l}}\ {-}\ {\mathrm{r}} | op match "-" ? l − r |
| 63 | op m_atch "*" ? l * r | \ \ {\mathrm{op}}\ {\mathrm{\underline{m}atch}}\ {\text{"*"}}\ {?}\ {\mathrm{l}}\ {\times}\ {\mathrm{r}} | op match "*" ? l × r |
| 64 | op m_atch "%" ? l / r | \ \ {\mathrm{op}}\ {\mathrm{\underline{m}atch}}\ {\text{"\%"}}\ {?}\ {\mathrm{l}}\ {\div}\ {\mathrm{r}} | op match "%" ? l ÷ r |
| 65 | op m_atch "max" ? l 'm_ax e_ach r | \ \ {\mathrm{op}}\ {\mathrm{\underline{m}atch}}\ {\text{"max"}}\ {?}\ {\mathrm{l}}\ {\text{'}}{\mathrm{\underline{m}ax}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{r}} | op match "max" ? l ’max each r |
| 66 | l 'm_in e_ach r | \ \ {\mathrm{l}}\ {\text{'}}{\mathrm{\underline{m}in}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{r}} | l ’min each r |
| 67 | } | {\}} | } |
| 68 | u:m_onad := { op ov -> | {{}^{\mathrm{u}}\mathrm{\underline{m}onad}}\ {\leftarrow}\ {\{}\ {\mathrm{op}}\ {\mathrm{ov}}\ {\to} | umonad ← { op ov → |
| 69 | o := f_irst d_isclose 1 s_elect ov | \ \ {\mathrm{o}}\ {\leftarrow}\ {\mathrm{\underline{f}irst}}\ {\mathrm{\underline{d}isclose}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{ov}} | o ← first disclose 1 select ov |
| 70 | v := d_isclose 2 s_elect ov | \ \ {\mathrm{v}}\ {\leftarrow}\ {\mathrm{\underline{d}isclose}}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{ov}} | v ← disclose 2 select ov |
| 71 | op m_atch "-" ? n_eg v | \ \ {\mathrm{op}}\ {\mathrm{\underline{m}atch}}\ {\text{"-"}}\ {?}\ {\mathrm{\underline{n}eg}}\ {\mathrm{v}} | op match "-" ? neg v |
| 72 | op m_atch "i" ? o + f_loat o_ffsets f_loor f_irst v | \ \ {\mathrm{op}}\ {\mathrm{\underline{m}atch}}\ {\text{"i"}}\ {?}\ {\mathrm{o}}\ {+}\ {\mathrm{\underline{f}loat}}\ {\mathrm{\underline{o}ffsets}}\ {\mathrm{\underline{f}loor}}\ {\mathrm{\underline{f}irst}}\ {\mathrm{v}} | op match "i" ? o + float offsets floor first v |
| 73 | op m_atch "r" ? r_ev v | \ \ {\mathrm{op}}\ {\mathrm{\underline{m}atch}}\ {\text{"r"}}\ {?}\ {\mathrm{\underline{r}ev}}\ {\mathrm{v}} | op match "r" ? rev v |
| 74 | op m_atch "*/" ? 1 r_eshape '* r_/ v | \ \ {\mathrm{op}}\ {\mathrm{\underline{m}atch}}\ {\text{"*/"}}\ {?}\ {1}\ {\mathrm{\underline{r}eshape}}\ {\text{'}}{\times}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{v}} | op match "*/" ? 1 reshape ’× r/ v |
| 75 | op m_atch "-/" ? 1 r_eshape '- r_/ v | \ \ {\mathrm{op}}\ {\mathrm{\underline{m}atch}}\ {\text{"-/"}}\ {?}\ {1}\ {\mathrm{\underline{r}eshape}}\ {\text{'}}{-}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{v}} | op match "-/" ? 1 reshape ’− r/ v |
| 76 | 1 r_eshape '+ r_/ v | \ \ {1}\ {\mathrm{\underline{r}eshape}}\ {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{v}} | 1 reshape ’+ r/ v |
| 77 | } | {\}} | } |
| 83 | u:w_idth := { t -> | {{}^{\mathrm{u}}\mathrm{\underline{w}idth}}\ {\leftarrow}\ {\{}\ {\mathrm{t}}\ {\to} | uwidth ← { t → |
| 84 | k := 'u:k_ind e_ach t | \ \ {\mathrm{k}}\ {\leftarrow}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{k}ind}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{t}} | k ← ’ukind each t |
| 85 | 4 != (t_ally k) s_elect k ? '+ r_/ '& s_\ r_ev k = 1 | \ \ {4}\ {\neq}\ {(}{\mathrm{\underline{t}ally}}\ {\mathrm{k}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{k}}\ {?}\ {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\text{'}}{\wedge}\ {\mathrm{\underline{s}}{\backslash}}\ {\mathrm{\underline{r}ev}}\ {\mathrm{k}}\ {=}\ {1} | 4 = (tally k) select k ? ’+ r/ ’∧ s\ rev k = 1 |
| 86 | depth := '+ s_\ r_ev (k = 4) - k = 3 | \ \ {\mathrm{depth}}\ {\leftarrow}\ {\text{'}}{+}\ {\mathrm{\underline{s}}{\backslash}}\ {\mathrm{\underline{r}ev}}\ {(}{\mathrm{k}}\ {=}\ {4}{)}\ {-}\ {\mathrm{k}}\ {=}\ {3} | depth ← ’+ s\ rev (k = 4) − k = 3 |
| 87 | f_irst w_here depth = 0 | \ \ {\mathrm{\underline{f}irst}}\ {\mathrm{\underline{w}here}}\ {\mathrm{depth}}\ {=}\ {0} | first where depth = 0 |
| 88 | } | {\}} | } |
| 89 | u:o_perand := { o t -> | {{}^{\mathrm{u}}\mathrm{\underline{o}perand}}\ {\leftarrow}\ {\{}\ {\mathrm{o}}\ {\mathrm{t}}\ {\to} | uoperand ← { o t → |
| 90 | w := u:w_idth t | \ \ {\mathrm{w}}\ {\leftarrow}\ {{}^{\mathrm{u}}\mathrm{\underline{w}idth}}\ {\mathrm{t}} | w ← uwidth t |
| 91 | g := (n_eg w) t_ake t | \ \ {\mathrm{g}}\ {\leftarrow}\ {(}{\mathrm{\underline{n}eg}}\ {\mathrm{w}}{)}\ {\mathrm{\underline{t}ake}}\ {\mathrm{t}} | g ← (neg w) take t |
| 92 | 4 = u:k_ind (t_ally g) s_elect g ? o u:e_val -1 d_rop 1 d_rop g | \ \ {4}\ {=}\ {{}^{\mathrm{u}}\mathrm{\underline{k}ind}}\ {(}{\mathrm{\underline{t}ally}}\ {\mathrm{g}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{g}}\ {?}\ {\mathrm{o}}\ {{}^{\mathrm{u}}\mathrm{\underline{e}val}}\ {-1}\ {\mathrm{\underline{d}rop}}\ {1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{g}} | 4 = ukind (tally g) select g ? o ueval −1 drop 1 drop g |
| 93 | '{ f_irst n_umbers d_isclose _r } e_ach g | \ \ {\text{'}}{\{}\ {\mathrm{\underline{f}irst}}\ {\mathrm{\underline{n}umbers}}\ {\mathrm{\underline{d}isclose}}\ {\_\mathrm{r}}\ {\}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{g}} | ’{ first numbers disclose _r } each g |
| 94 | } | {\}} | } |
| 99 | u:r_un := { t ov -> | {{}^{\mathrm{u}}\mathrm{\underline{r}un}}\ {\leftarrow}\ {\{}\ {\mathrm{t}}\ {\mathrm{ov}}\ {\to} | urun ← { t ov → |
| 100 | o := d_isclose 1 s_elect ov | \ \ {\mathrm{o}}\ {\leftarrow}\ {\mathrm{\underline{d}isclose}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{ov}} | o ← disclose 1 select ov |
| 101 | v := d_isclose 2 s_elect ov | \ \ {\mathrm{v}}\ {\leftarrow}\ {\mathrm{\underline{d}isclose}}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{ov}} | v ← disclose 2 select ov |
| 102 | 0 = t_ally t ? v | \ \ {0}\ {=}\ {\mathrm{\underline{t}ally}}\ {\mathrm{t}}\ {?}\ {\mathrm{v}} | 0 = tally t ? v |
| 103 | op := d_isclose (t_ally t) s_elect t | \ \ {\mathrm{op}}\ {\leftarrow}\ {\mathrm{\underline{d}isclose}}\ {(}{\mathrm{\underline{t}ally}}\ {\mathrm{t}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{t}} | op ← disclose (tally t) select t |
| 104 | rest := -1 d_rop t | \ \ {\mathrm{rest}}\ {\leftarrow}\ {-1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{t}} | rest ← −1 drop t |
| 105 | last := 'u:k_ind e_ach rest | \ \ {\mathrm{last}}\ {\leftarrow}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{k}ind}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{rest}} | last ← ’ukind each rest |
| 106 | (0 = t_ally rest) | 2 = f_irst -1 t_ake 0 c_at last ? rest u:r_un (e_nclose o) c_at e_nclose op u:m_onad ov | \ \ {(}{0}\ {=}\ {\mathrm{\underline{t}ally}}\ {\mathrm{rest}}{)}\ {\vee}\ {2}\ {=}\ {\mathrm{\underline{f}irst}}\ {-1}\ {\mathrm{\underline{t}ake}}\ {0}\ {\mathrm{\underline{c}at}}\ {\mathrm{last}}\ {?}\ {\mathrm{rest}}\ {{}^{\mathrm{u}}\mathrm{\underline{r}un}}\ {(}{\mathrm{\underline{e}nclose}}\ {\mathrm{o}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{e}nclose}}\ {\mathrm{op}}\ {{}^{\mathrm{u}}\mathrm{\underline{m}onad}}\ {\mathrm{ov}} | (0 = tally rest) ∨ 2 = first −1 take 0 cat last ? rest urun (enclose o) cat enclose op umonad ov |
| 107 | left := (f_irst o) u:o_perand rest | \ \ {\mathrm{left}}\ {\leftarrow}\ {(}{\mathrm{\underline{f}irst}}\ {\mathrm{o}}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{o}perand}}\ {\mathrm{rest}} | left ← (first o) uoperand rest |
| 108 | w := u:w_idth rest | \ \ {\mathrm{w}}\ {\leftarrow}\ {{}^{\mathrm{u}}\mathrm{\underline{w}idth}}\ {\mathrm{rest}} | w ← uwidth rest |
| 109 | ((n_eg w) d_rop rest) u:r_un (e_nclose o) c_at e_nclose op u:d_yad (e_nclose o) c_at (e_nclose left) c_at e_nclose v | \ \ {(}{(}{\mathrm{\underline{n}eg}}\ {\mathrm{w}}{)}\ {\mathrm{\underline{d}rop}}\ {\mathrm{rest}}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{r}un}}\ {(}{\mathrm{\underline{e}nclose}}\ {\mathrm{o}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{e}nclose}}\ {\mathrm{op}}\ {{}^{\mathrm{u}}\mathrm{\underline{d}yad}}\ {(}{\mathrm{\underline{e}nclose}}\ {\mathrm{o}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{e}nclose}}\ {\mathrm{left}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{e}nclose}}\ {\mathrm{v}} | ((neg w) drop rest) urun (enclose o) cat enclose op udyad (enclose o) cat (enclose left) cat enclose v |
| 110 | } | {\}} | } |
| 111 | u:e_val := { o t -> ((n_eg u:w_idth t) d_rop t) u:r_un (e_nclose 1 r_eshape o) c_at e_nclose o u:o_perand t } | {{}^{\mathrm{u}}\mathrm{\underline{e}val}}\ {\leftarrow}\ {\{}\ {\mathrm{o}}\ {\mathrm{t}}\ {\to}\ {(}{(}{\mathrm{\underline{n}eg}}\ {{}^{\mathrm{u}}\mathrm{\underline{w}idth}}\ {\mathrm{t}}{)}\ {\mathrm{\underline{d}rop}}\ {\mathrm{t}}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{r}un}}\ {(}{\mathrm{\underline{e}nclose}}\ {1}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{o}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{e}nclose}}\ {\mathrm{o}}\ {{}^{\mathrm{u}}\mathrm{\underline{o}perand}}\ {\mathrm{t}}\ {\}} | ueval ← { o t → ((neg uwidth t) drop t) urun (enclose 1 reshape o) cat enclose o uoperand t } |
| 115 | u:i_nterp := { o s -> o u:e_val u:t_okens s } | {{}^{\mathrm{u}}\mathrm{\underline{i}nterp}}\ {\leftarrow}\ {\{}\ {\mathrm{o}}\ {\mathrm{s}}\ {\to}\ {\mathrm{o}}\ {{}^{\mathrm{u}}\mathrm{\underline{e}val}}\ {{}^{\mathrm{u}}\mathrm{\underline{t}okens}}\ {\mathrm{s}}\ {\}} | uinterp ← { o s → o ueval utokens s } |
| 116 | u:a_pl := { s -> 1.0 u:i_nterp s } | {{}^{\mathrm{u}}\mathrm{\underline{a}pl}}\ {\leftarrow}\ {\{}\ {\mathrm{s}}\ {\to}\ {1.0}\ {{}^{\mathrm{u}}\mathrm{\underline{i}nterp}}\ {\mathrm{s}}\ {\}} | uapl ← { s → 1.0 uinterp s } |
| 119 | u:a_pl "1 2 3 + 10" | {{}^{\mathrm{u}}\mathrm{\underline{a}pl}}\ {\text{"1 2 3 + 10"}} | uapl "1 2 3 + 10" |
| 120 | u:a_pl "2 * 3 + 4" # right to left: 2 * 7 | {{}^{\mathrm{u}}\mathrm{\underline{a}pl}}\ {\text{"2 * 3 + 4"}} | uapl "2 * 3 + 4" |
| 121 | u:a_pl "(2 * 3) + 4" | {{}^{\mathrm{u}}\mathrm{\underline{a}pl}}\ {\text{"(2 * 3) + 4"}} | uapl "(2 * 3) + 4" |
| 122 | u:a_pl "2*(3 + 4) - 10" # 2 * ((3 + 4) - 10) | {{}^{\mathrm{u}}\mathrm{\underline{a}pl}}\ {\text{"2*(3 + 4) - 10"}} | uapl "2*(3 + 4) - 10" |
| 123 | u:a_pl "+/ i 10" | {{}^{\mathrm{u}}\mathrm{\underline{a}pl}}\ {\text{"+/ i 10"}} | uapl "+/ i 10" |
| 124 | u:a_pl "2 * i 5" | {{}^{\mathrm{u}}\mathrm{\underline{a}pl}}\ {\text{"2 * i 5"}} | uapl "2 * i 5" |
| 125 | u:a_pl "r i 4" | {{}^{\mathrm{u}}\mathrm{\underline{a}pl}}\ {\text{"r i 4"}} | uapl "r i 4" |
| 126 | u:a_pl "-/ 1 2 3" # 1 - (2 - 3) | {{}^{\mathrm{u}}\mathrm{\underline{a}pl}}\ {\text{"-/ 1 2 3"}} | uapl "-/ 1 2 3" |
| 127 | u:a_pl "1 % 4" | {{}^{\mathrm{u}}\mathrm{\underline{a}pl}}\ {\text{"1 \% 4"}} | uapl "1 % 4" |
| 128 | u:a_pl "(1 2 3 max 3 2 1) * -1" | {{}^{\mathrm{u}}\mathrm{\underline{a}pl}}\ {\text{"(1 2 3 max 3 2 1) * -1"}} | uapl "(1 2 3 max 3 2 1) * -1" |
| 129 | u:a_pl "*/ i 6" # 6 factorial | {{}^{\mathrm{u}}\mathrm{\underline{a}pl}}\ {\text{"*/ i 6"}} | uapl "*/ i 6" |
| 130 | u:a_pl "+/ (i 5) * i 5" # 1 + 4 + 9 + 16 + 25 | {{}^{\mathrm{u}}\mathrm{\underline{a}pl}}\ {\text{"+/ (i 5) * i 5"}} | uapl "+/ (i 5) * i 5" |
| 131 | u:a_pl "2 4 pick 10 20 30 40" | {{}^{\mathrm{u}}\mathrm{\underline{a}pl}}\ {\text{"2 4 pick 10 20 30 40"}} | uapl "2 4 pick 10 20 30 40" |
| 132 | u:a_pl "10 20 30 iota 30 10 99" | {{}^{\mathrm{u}}\mathrm{\underline{a}pl}}\ {\text{"10 20 30 iota 30 10 99"}} | uapl "10 20 30 iota 30 10 99" |
| 141 | u:s_how := { v -> '& r_/ v = f_loat f_loor v ? f_ormat f_loor v; f_ormat v } | {{}^{\mathrm{u}}\mathrm{\underline{s}how}}\ {\leftarrow}\ {\{}\ {\mathrm{v}}\ {\to}\ {\text{'}}{\wedge}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{v}}\ {=}\ {\mathrm{\underline{f}loat}}\ {\mathrm{\underline{f}loor}}\ {\mathrm{v}}\ {?}\ {\mathrm{\underline{f}ormat}}\ {\mathrm{\underline{f}loor}}\ {\mathrm{v}}{\diamond}\ {\mathrm{\underline{f}ormat}}\ {\mathrm{v}}\ {\}} | ushow ← { v → ’∧ r/ v = float floor v ? format floor v⋄ format v } |
| 142 | u:s_ay! := { st text -> _ := p_rint! text; st } | {{}^{\mathrm{u}}\mathrm{\underline{s}ay}{!}}\ {\leftarrow}\ {\{}\ {\mathrm{st}}\ {\mathrm{text}}\ {\to}\ {\_}\ {\leftarrow}\ {\mathrm{\underline{p}rint}{!}}\ {\mathrm{text}}{\diamond}\ {\mathrm{st}}\ {\}} | usay! ← { st text → _ ← print! text⋄ st } |
| 143 | u:o_rigin! := { st line -> | {{}^{\mathrm{u}}\mathrm{\underline{o}rigin}{!}}\ {\leftarrow}\ {\{}\ {\mathrm{st}}\ {\mathrm{line}}\ {\to} | uorigin! ← { st line → |
| 144 | x := 1 s_elect st | \ \ {\mathrm{x}}\ {\leftarrow}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{st}} | x ← 1 select st |
| 145 | o := 2 s_elect st | \ \ {\mathrm{o}}\ {\leftarrow}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{st}} | o ← 2 select st |
| 146 | v := n_umbers 7 d_rop line | \ \ {\mathrm{v}}\ {\leftarrow}\ {\mathrm{\underline{n}umbers}}\ {7}\ {\mathrm{\underline{d}rop}}\ {\mathrm{line}} | v ← numbers 7 drop line |
| 147 | n_ot (7 t_ake line) m_atch ")ORIGIN" ? st u:s_ay! "INCORRECT COMMAND" | \ \ {\mathrm{\underline{n}ot}}\ {(}{7}\ {\mathrm{\underline{t}ake}}\ {\mathrm{line}}{)}\ {\mathrm{\underline{m}atch}}\ {\text{")ORIGIN"}}\ {?}\ {\mathrm{st}}\ {{}^{\mathrm{u}}\mathrm{\underline{s}ay}{!}}\ {\text{"INCORRECT COMMAND"}} | not (7 take line) match ")ORIGIN" ? st usay! "INCORRECT COMMAND" |
| 148 | 0 = t_ally v ? st u:s_ay! "IS " c_at u:s_how o | \ \ {0}\ {=}\ {\mathrm{\underline{t}ally}}\ {\mathrm{v}}\ {?}\ {\mathrm{st}}\ {{}^{\mathrm{u}}\mathrm{\underline{s}ay}{!}}\ {\text{"IS "}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{u}}\mathrm{\underline{s}how}}\ {\mathrm{o}} | 0 = tally v ? st usay! "IS " cat ushow o |
| 149 | ok := (1 = t_ally v) & ((f_irst v) m_ember? 0.0 1.0) | (x = 1) & 0.5 = f_irst v | \ \ {\mathrm{ok}}\ {\leftarrow}\ {(}{1}\ {=}\ {\mathrm{\underline{t}ally}}\ {\mathrm{v}}{)}\ {\wedge}\ {(}{(}{\mathrm{\underline{f}irst}}\ {\mathrm{v}}{)}\ {\mathrm{\underline{m}ember}{?}}\ {0.0}\ {1.0}{)}\ {\vee}\ {(}{\mathrm{x}}\ {=}\ {1}{)}\ {\wedge}\ {0.5}\ {=}\ {\mathrm{\underline{f}irst}}\ {\mathrm{v}} | ok ← (1 = tally v) ∧ ((first v) member? 0.0 1.0) ∨ (x = 1) ∧ 0.5 = first v |
| 150 | n_ot ok ? st u:s_ay! "INCORRECT COMMAND" | \ \ {\mathrm{\underline{n}ot}}\ {\mathrm{ok}}\ {?}\ {\mathrm{st}}\ {{}^{\mathrm{u}}\mathrm{\underline{s}ay}{!}}\ {\text{"INCORRECT COMMAND"}} | not ok ? st usay! "INCORRECT COMMAND" |
| 151 | (x c_at f_irst v) u:s_ay! "WAS " c_at u:s_how o | \ \ {(}{\mathrm{x}}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{f}irst}}\ {\mathrm{v}}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{s}ay}{!}}\ {\text{"WAS "}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{u}}\mathrm{\underline{s}how}}\ {\mathrm{o}} | (x cat first v) usay! "WAS " cat ushow o |
| 152 | } | {\}} | } |
| 153 | u:l_ine! := { st line -> | {{}^{\mathrm{u}}\mathrm{\underline{l}ine}{!}}\ {\leftarrow}\ {\{}\ {\mathrm{st}}\ {\mathrm{line}}\ {\to} | uline! ← { st line → |
| 154 | _ := p_rint! " " c_at line | \ \ {\_}\ {\leftarrow}\ {\mathrm{\underline{p}rint}{!}}\ {\text{" "}}\ {\mathrm{\underline{c}at}}\ {\mathrm{line}} | _ ← print! " " cat line |
| 155 | (f_irst line) = f_irst ")" ? st u:o_rigin! line | \ \ {(}{\mathrm{\underline{f}irst}}\ {\mathrm{line}}{)}\ {=}\ {\mathrm{\underline{f}irst}}\ {\text{")"}}\ {?}\ {\mathrm{st}}\ {{}^{\mathrm{u}}\mathrm{\underline{o}rigin}{!}}\ {\mathrm{line}} | (first line) = first ")" ? st uorigin! line |
| 156 | st u:s_ay! u:s_how (2 s_elect st) u:i_nterp line | \ \ {\mathrm{st}}\ {{}^{\mathrm{u}}\mathrm{\underline{s}ay}{!}}\ {{}^{\mathrm{u}}\mathrm{\underline{s}how}}\ {(}{2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{st}}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{i}nterp}}\ {\mathrm{line}} | st usay! ushow (2 select st) uinterp line |
| 157 | } | {\}} | } |
| 158 | u:s_ession! := { st lines -> | {{}^{\mathrm{u}}\mathrm{\underline{s}ession}{!}}\ {\leftarrow}\ {\{}\ {\mathrm{st}}\ {\mathrm{lines}}\ {\to} | usession! ← { st lines → |
| 159 | 0 = t_ally lines ? st | \ \ {0}\ {=}\ {\mathrm{\underline{t}ally}}\ {\mathrm{lines}}\ {?}\ {\mathrm{st}} | 0 = tally lines ? st |
| 160 | next := st u:l_ine! d_isclose 1 s_elect lines | \ \ {\mathrm{next}}\ {\leftarrow}\ {\mathrm{st}}\ {{}^{\mathrm{u}}\mathrm{\underline{l}ine}{!}}\ {\mathrm{\underline{d}isclose}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{lines}} | next ← st uline! disclose 1 select lines |
| 161 | next u:s_ession! 1 d_rop lines | \ \ {\mathrm{next}}\ {{}^{\mathrm{u}}\mathrm{\underline{s}ession}{!}}\ {1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{lines}} | next usession! 1 drop lines |
| 162 | } | {\}} | } |
| 165 | off := 0 1 u:s_ession! "i 4" ")ORIGIN 0" "i 4" "1 pick 10 20 30" "10 20 30 iota 20" ")ORIGIN 0.5" ")ORIGIN" ")ORIGIN 1" "i 4" | {\mathrm{off}}\ {\leftarrow}\ {0}\ {1}\ {{}^{\mathrm{u}}\mathrm{\underline{s}ession}{!}}\ {\text{"i 4"}}\ {\text{")ORIGIN 0"}}\ {\text{"i 4"}}\ {\text{"1 pick 10 20 30"}}\ {\text{"10 20 30 iota 20"}}\ {\text{")ORIGIN 0.5"}}\ {\text{")ORIGIN"}}\ {\text{")ORIGIN 1"}}\ {\text{"i 4"}} | off ← 0 1 usession! "i 4" ")ORIGIN 0" "i 4" "1 pick 10 20 30" "10 20 30 iota 20" ")ORIGIN 0.5" ")ORIGIN" ")ORIGIN 1" "i 4" |
| 172 | on := 1 1 u:s_ession! ")ORIGIN 0.5" "i 4" "+/ i 4" "0.5 1.5 pick 10 20 30 40" "1 2 pick 10 20 30 40" "10 20 30 iota 30 10 99" "(i 3) pick 10 20 30" ")ORIGIN 1" "i 4" | {\mathrm{on}}\ {\leftarrow}\ {1}\ {1}\ {{}^{\mathrm{u}}\mathrm{\underline{s}ession}{!}}\ {\text{")ORIGIN 0.5"}}\ {\text{"i 4"}}\ {\text{"+/ i 4"}}\ {\text{"0.5 1.5 pick 10 20 30 40"}}\ {\text{"1 2 pick 10 20 30 40"}}\ {\text{"10 20 30 iota 30 10 99"}}\ {\text{"(i 3) pick 10 20 30"}}\ {\text{")ORIGIN 1"}}\ {\text{"i 4"}} | on ← 1 1 usession! ")ORIGIN 0.5" "i 4" "+/ i 4" "0.5 1.5 pick 10 20 30 40" "1 2 pick 10 20 30 40" "10 20 30 iota 30 10 99" "(i 3) pick 10 20 30" ")ORIGIN 1" "i 4" |
| 38 | l:dwell := 5.0 | {{}^{\mathrm{l}}\mathrm{dwell}}\ {\leftarrow}\ {5.0} | ldwell ← 5.0 |
| 39 | l:idleBefore := 20.0 | {{}^{\mathrm{l}}\mathrm{idleBefore}}\ {\leftarrow}\ {20.0} | lidleBefore ← 20.0 |
| 47 | l:s_tart := { i l -> ((i c_at l c_at l, 0 0 0, 0.0 0.0 0.0, 1 1 1), (0, 0.0 0.0, 0.0, 0.0), (l:idleBefore, 0.0, 0, 0)) } | {{}^{\mathrm{l}}\mathrm{\underline{s}tart}}\ {\leftarrow}\ {\{}\ {\mathrm{i}}\ {\mathrm{l}}\ {\to}\ {(}{(}{\mathrm{i}}\ {\mathrm{\underline{c}at}}\ {\mathrm{l}}\ {\mathrm{\underline{c}at}}\ {\mathrm{l}}{,}\ {0}\ {0}\ {0}{,}\ {0.0}\ {0.0}\ {0.0}{,}\ {1}\ {1}\ {1}{)}{,}\ {(}{0}{,}\ {0.0}\ {0.0}{,}\ {0.0}{,}\ {0.0}{)}{,}\ {(}{{}^{\mathrm{l}}\mathrm{idleBefore}}{,}\ {0.0}{,}\ {0}{,}\ {0}{)}{)}\ {\}} | lstart ← { i l → ((i cat l cat l, 0 0 0, 0.0 0.0 0.0, 1 1 1), (0, 0.0 0.0, 0.0, 0.0), (lidleBefore, 0.0, 0, 0)) } |
| 50 | l:IDIOM := 1 | {{}^{\mathrm{l}}\mathrm{IDIOM}}\ {\leftarrow}\ {1} | lIDIOM ← 1 |
| 51 | l:TOP := 2 | {{}^{\mathrm{l}}\mathrm{TOP}}\ {\leftarrow}\ {2} | lTOP ← 2 |
| 52 | l:BOTTOM := 3 | {{}^{\mathrm{l}}\mathrm{BOTTOM}}\ {\leftarrow}\ {3} | lBOTTOM ← 3 |
| 57 | l:middle := 210.0 | {{}^{\mathrm{l}}\mathrm{middle}}\ {\leftarrow}\ {210.0} | lmiddle ← 210.0 |
| 58 | l:perPixel := 90.0 / 210.0 | {{}^{\mathrm{l}}\mathrm{perPixel}}\ {\leftarrow}\ {90.0}\ {\div}\ {210.0} | lperPixel ← 90.0 ÷ 210.0 |
| 64 | l:c_ount := { axis state -> ((c, _, _, _), _, _) := state; axis s_elect c } | {{}^{\mathrm{l}}\mathrm{\underline{c}ount}}\ {\leftarrow}\ {\{}\ {\mathrm{axis}}\ {\mathrm{state}}\ {\to}\ {(}{(}{\mathrm{c}}{,}\ {\_}{,}\ {\_}{,}\ {\_}{)}{,}\ {\_}{,}\ {\_}{)}\ {\leftarrow}\ {\mathrm{state}}{\diamond}\ {\mathrm{axis}}\ {\mathrm{\underline{s}elect}}\ {\mathrm{c}}\ {\}} | lcount ← { axis state → ((c, _, _, _), _, _) ← state⋄ axis select c } |
| 65 | l:s_teps := { axis state -> ((_, s, _, _), _, _) := state; axis s_elect s } | {{}^{\mathrm{l}}\mathrm{\underline{s}teps}}\ {\leftarrow}\ {\{}\ {\mathrm{axis}}\ {\mathrm{state}}\ {\to}\ {(}{(}{\_}{,}\ {\mathrm{s}}{,}\ {\_}{,}\ {\_}{)}{,}\ {\_}{,}\ {\_}{)}\ {\leftarrow}\ {\mathrm{state}}{\diamond}\ {\mathrm{axis}}\ {\mathrm{\underline{s}elect}}\ {\mathrm{s}}\ {\}} | lsteps ← { axis state → ((_, s, _, _), _, _) ← state⋄ axis select s } |
| 66 | l:a_ngle := { axis state -> ((_, _, a, _), _, _) := state; axis s_elect a } | {{}^{\mathrm{l}}\mathrm{\underline{a}ngle}}\ {\leftarrow}\ {\{}\ {\mathrm{axis}}\ {\mathrm{state}}\ {\to}\ {(}{(}{\_}{,}\ {\_}{,}\ {\mathrm{a}}{,}\ {\_}{)}{,}\ {\_}{,}\ {\_}{)}\ {\leftarrow}\ {\mathrm{state}}{\diamond}\ {\mathrm{axis}}\ {\mathrm{\underline{s}elect}}\ {\mathrm{a}}\ {\}} | langle ← { axis state → ((_, _, a, _), _, _) ← state⋄ axis select a } |
| 67 | l:p_laying := { axis state -> ((_, _, _, p), _, _) := state; axis s_elect p } | {{}^{\mathrm{l}}\mathrm{\underline{p}laying}}\ {\leftarrow}\ {\{}\ {\mathrm{axis}}\ {\mathrm{state}}\ {\to}\ {(}{(}{\_}{,}\ {\_}{,}\ {\_}{,}\ {\mathrm{p}}{)}{,}\ {\_}{,}\ {\_}{)}\ {\leftarrow}\ {\mathrm{state}}{\diamond}\ {\mathrm{axis}}\ {\mathrm{\underline{s}elect}}\ {\mathrm{p}}\ {\}} | lplaying ← { axis state → ((_, _, _, p), _, _) ← state⋄ axis select p } |
| 70 | l:p_ointer := { state -> (_, q, _) := state; q } | {{}^{\mathrm{l}}\mathrm{\underline{p}ointer}}\ {\leftarrow}\ {\{}\ {\mathrm{state}}\ {\to}\ {(}{\_}{,}\ {\mathrm{q}}{,}\ {\_}{)}\ {\leftarrow}\ {\mathrm{state}}{\diamond}\ {\mathrm{q}}\ {\}} | lpointer ← { state → (_, q, _) ← state⋄ q } |
| 71 | l:c_lock := { state -> (_, _, k) := state; k } | {{}^{\mathrm{l}}\mathrm{\underline{c}lock}}\ {\leftarrow}\ {\{}\ {\mathrm{state}}\ {\to}\ {(}{\_}{,}\ {\_}{,}\ {\mathrm{k}}{)}\ {\leftarrow}\ {\mathrm{state}}{\diamond}\ {\mathrm{k}}\ {\}} | lclock ← { state → (_, _, k) ← state⋄ k } |
| 74 | h:s_et := { (k, x) v -> ((k - 1) t_ake v) c_at x c_at k d_rop v } | {{}^{\mathrm{h}}\mathrm{\underline{s}et}}\ {\leftarrow}\ {\{}\ {(}{\mathrm{k}}{,}\ {\mathrm{x}}{)}\ {\mathrm{v}}\ {\to}\ {(}{(}{\mathrm{k}}\ {-}\ {1}{)}\ {\mathrm{\underline{t}ake}}\ {\mathrm{v}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{x}}\ {\mathrm{\underline{c}at}}\ {\mathrm{k}}\ {\mathrm{\underline{d}rop}}\ {\mathrm{v}}\ {\}} | hset ← { (k, x) v → ((k − 1) take v) cat x cat k drop v } |
| 77 | h:s_tepsTo := { (axis, n) state -> ((c, s, a, p), q, k) := state; ((c, (axis, n) h:s_et s, a, p), q, k) } | {{}^{\mathrm{h}}\mathrm{\underline{s}tepsTo}}\ {\leftarrow}\ {\{}\ {(}{\mathrm{axis}}{,}\ {\mathrm{n}}{)}\ {\mathrm{state}}\ {\to}\ {(}{(}{\mathrm{c}}{,}\ {\mathrm{s}}{,}\ {\mathrm{a}}{,}\ {\mathrm{p}}{)}{,}\ {\mathrm{q}}{,}\ {\mathrm{k}}{)}\ {\leftarrow}\ {\mathrm{state}}{\diamond}\ {(}{(}{\mathrm{c}}{,}\ {(}{\mathrm{axis}}{,}\ {\mathrm{n}}{)}\ {{}^{\mathrm{h}}\mathrm{\underline{s}et}}\ {\mathrm{s}}{,}\ {\mathrm{a}}{,}\ {\mathrm{p}}{)}{,}\ {\mathrm{q}}{,}\ {\mathrm{k}}{)}\ {\}} | hstepsTo ← { (axis, n) state → ((c, s, a, p), q, k) ← state⋄ ((c, (axis, n) hset s, a, p), q, k) } |
| 78 | h:a_ngleTo := { (axis, x) state -> ((c, s, a, p), q, k) := state; ((c, s, (axis, x) h:s_et a, p), q, k) } | {{}^{\mathrm{h}}\mathrm{\underline{a}ngleTo}}\ {\leftarrow}\ {\{}\ {(}{\mathrm{axis}}{,}\ {\mathrm{x}}{)}\ {\mathrm{state}}\ {\to}\ {(}{(}{\mathrm{c}}{,}\ {\mathrm{s}}{,}\ {\mathrm{a}}{,}\ {\mathrm{p}}{)}{,}\ {\mathrm{q}}{,}\ {\mathrm{k}}{)}\ {\leftarrow}\ {\mathrm{state}}{\diamond}\ {(}{(}{\mathrm{c}}{,}\ {\mathrm{s}}{,}\ {(}{\mathrm{axis}}{,}\ {\mathrm{x}}{)}\ {{}^{\mathrm{h}}\mathrm{\underline{s}et}}\ {\mathrm{a}}{,}\ {\mathrm{p}}{)}{,}\ {\mathrm{q}}{,}\ {\mathrm{k}}{)}\ {\}} | hangleTo ← { (axis, x) state → ((c, s, a, p), q, k) ← state⋄ ((c, s, (axis, x) hset a, p), q, k) } |
| 79 | h:p_layingTo := { (axis, b) state -> ((c, s, a, p), q, k) := state; ((c, s, a, (axis, b) h:s_et p), q, k) } | {{}^{\mathrm{h}}\mathrm{\underline{p}layingTo}}\ {\leftarrow}\ {\{}\ {(}{\mathrm{axis}}{,}\ {\mathrm{b}}{)}\ {\mathrm{state}}\ {\to}\ {(}{(}{\mathrm{c}}{,}\ {\mathrm{s}}{,}\ {\mathrm{a}}{,}\ {\mathrm{p}}{)}{,}\ {\mathrm{q}}{,}\ {\mathrm{k}}{)}\ {\leftarrow}\ {\mathrm{state}}{\diamond}\ {(}{(}{\mathrm{c}}{,}\ {\mathrm{s}}{,}\ {\mathrm{a}}{,}\ {(}{\mathrm{axis}}{,}\ {\mathrm{b}}{)}\ {{}^{\mathrm{h}}\mathrm{\underline{s}et}}\ {\mathrm{p}}{)}{,}\ {\mathrm{q}}{,}\ {\mathrm{k}}{)}\ {\}} | hplayingTo ← { (axis, b) state → ((c, s, a, p), q, k) ← state⋄ ((c, s, a, (axis, b) hset p), q, k) } |
| 82 | h:i_dleTo := { t state -> (axes, q, (_, since, b, i)) := state; (axes, q, (t, since, b, i)) } | {{}^{\mathrm{h}}\mathrm{\underline{i}dleTo}}\ {\leftarrow}\ {\{}\ {\mathrm{t}}\ {\mathrm{state}}\ {\to}\ {(}{\mathrm{axes}}{,}\ {\mathrm{q}}{,}\ {(}{\_}{,}\ {\mathrm{since}}{,}\ {\mathrm{b}}{,}\ {\mathrm{i}}{)}{)}\ {\leftarrow}\ {\mathrm{state}}{\diamond}\ {(}{\mathrm{axes}}{,}\ {\mathrm{q}}{,}\ {(}{\mathrm{t}}{,}\ {\mathrm{since}}{,}\ {\mathrm{b}}{,}\ {\mathrm{i}}{)}{)}\ {\}} | hidleTo ← { t state → (axes, q, (_, since, b, i)) ← state⋄ (axes, q, (t, since, b, i)) } |
| 85 | l:w_rap := { n k -> 1 + (k - 1) m_od n } | {{}^{\mathrm{l}}\mathrm{\underline{w}rap}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\mathrm{k}}\ {\to}\ {1}\ {+}\ {(}{\mathrm{k}}\ {-}\ {1}{)}\ {\mathrm{\underline{m}od}}\ {\mathrm{n}}\ {\}} | lwrap ← { n k → 1 + (k − 1) mod n } |
| 91 | l:c_urrent := { axis state -> (axis l:c_ount state) l:w_rap 1 + axis l:s_teps state } | {{}^{\mathrm{l}}\mathrm{\underline{c}urrent}}\ {\leftarrow}\ {\{}\ {\mathrm{axis}}\ {\mathrm{state}}\ {\to}\ {(}{\mathrm{axis}}\ {{}^{\mathrm{l}}\mathrm{\underline{c}ount}}\ {\mathrm{state}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{w}rap}}\ {1}\ {+}\ {\mathrm{axis}}\ {{}^{\mathrm{l}}\mathrm{\underline{s}teps}}\ {\mathrm{state}}\ {\}} | lcurrent ← { axis state → (axis lcount state) lwrap 1 + axis lsteps state } |
| 102 | l:s_tep := { (axis, d) state -> | {{}^{\mathrm{l}}\mathrm{\underline{s}tep}}\ {\leftarrow}\ {\{}\ {(}{\mathrm{axis}}{,}\ {\mathrm{d}}{)}\ {\mathrm{state}}\ {\to} | lstep ← { (axis, d) state → |
| 103 | moved := (axis, d + axis l:s_teps state) h:s_tepsTo state | \ \ {\mathrm{moved}}\ {\leftarrow}\ {(}{\mathrm{axis}}{,}\ {\mathrm{d}}\ {+}\ {\mathrm{axis}}\ {{}^{\mathrm{l}}\mathrm{\underline{s}teps}}\ {\mathrm{state}}{)}\ {{}^{\mathrm{h}}\mathrm{\underline{s}tepsTo}}\ {\mathrm{state}} | moved ← (axis, d + axis lsteps state) hstepsTo state |
| 104 | axis = l:IDIOM ? moved | \ \ {\mathrm{axis}}\ {=}\ {{}^{\mathrm{l}}\mathrm{IDIOM}}\ {?}\ {\mathrm{moved}} | axis = lIDIOM ? moved |
| 105 | other := 5 - axis | \ \ {\mathrm{other}}\ {\leftarrow}\ {5}\ {-}\ {\mathrm{axis}} | other ← 5 − axis |
| 106 | clash := (axis l:c_urrent moved) = other l:c_urrent moved | \ \ {\mathrm{clash}}\ {\leftarrow}\ {(}{\mathrm{axis}}\ {{}^{\mathrm{l}}\mathrm{\underline{c}urrent}}\ {\mathrm{moved}}{)}\ {=}\ {\mathrm{other}}\ {{}^{\mathrm{l}}\mathrm{\underline{c}urrent}}\ {\mathrm{moved}} | clash ← (axis lcurrent moved) = other lcurrent moved |
| 107 | c"clash" i_f< c"(axis, d) l:s_tep moved; moved" | \ \ {\text{c"}}{\mathrm{clash}}{\text{"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{c"}}{(}{\mathrm{axis}}{,}\ {\mathrm{d}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{s}tep}}\ {\mathrm{moved}}{\diamond}\ {\mathrm{moved}}{\text{"}} | c"clash" if< c"(axis, d) lstep moved⋄ moved" |
| 108 | } | {\}} | } |
| 119 | l:c_hoose := { (axis, k) state -> | {{}^{\mathrm{l}}\mathrm{\underline{c}hoose}}\ {\leftarrow}\ {\{}\ {(}{\mathrm{axis}}{,}\ {\mathrm{k}}{)}\ {\mathrm{state}}\ {\to} | lchoose ← { (axis, k) state → |
| 120 | n := axis l:c_ount state | \ \ {\mathrm{n}}\ {\leftarrow}\ {\mathrm{axis}}\ {{}^{\mathrm{l}}\mathrm{\underline{c}ount}}\ {\mathrm{state}} | n ← axis lcount state |
| 121 | d := (k - axis l:c_urrent state) m_od n | \ \ {\mathrm{d}}\ {\leftarrow}\ {(}{\mathrm{k}}\ {-}\ {\mathrm{axis}}\ {{}^{\mathrm{l}}\mathrm{\underline{c}urrent}}\ {\mathrm{state}}{)}\ {\mathrm{\underline{m}od}}\ {\mathrm{n}} | d ← (k − axis lcurrent state) mod n |
| 122 | short := c"(2 * d) > n" i_f< c"d - n; d" | \ \ {\mathrm{short}}\ {\leftarrow}\ {\text{c"}}{(}{2}\ {\times}\ {\mathrm{d}}{)}\ {>}\ {\mathrm{n}}{\text{"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{c"}}{\mathrm{d}}\ {-}\ {\mathrm{n}}{\diamond}\ {\mathrm{d}}{\text{"}} | short ← c"(2 × d) > n" if< c"d − n⋄ d" |
| 123 | chosen := (axis, 0) h:p_layingTo (axis, short) l:s_tep state | \ \ {\mathrm{chosen}}\ {\leftarrow}\ {(}{\mathrm{axis}}{,}\ {0}{)}\ {{}^{\mathrm{h}}\mathrm{\underline{p}layingTo}}\ {(}{\mathrm{axis}}{,}\ {\mathrm{short}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{s}tep}}\ {\mathrm{state}} | chosen ← (axis, 0) hplayingTo (axis, short) lstep state |
| 124 | axis = l:IDIOM ? chosen | \ \ {\mathrm{axis}}\ {=}\ {{}^{\mathrm{l}}\mathrm{IDIOM}}\ {?}\ {\mathrm{chosen}} | axis = lIDIOM ? chosen |
| 125 | k = (5 - axis) l:c_urrent state ? state | \ \ {\mathrm{k}}\ {=}\ {(}{5}\ {-}\ {\mathrm{axis}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{c}urrent}}\ {\mathrm{state}}\ {?}\ {\mathrm{state}} | k = (5 − axis) lcurrent state ? state |
| 126 | chosen | \ \ {\mathrm{chosen}} | chosen |
| 127 | } | {\}} | } |
| 135 | l:e_ase := { (axis, dt) state -> | {{}^{\mathrm{l}}\mathrm{\underline{e}ase}}\ {\leftarrow}\ {\{}\ {(}{\mathrm{axis}}{,}\ {\mathrm{dt}}{)}\ {\mathrm{state}}\ {\to} | lease ← { (axis, dt) state → |
| 136 | angle := axis l:a_ngle state | \ \ {\mathrm{angle}}\ {\leftarrow}\ {\mathrm{axis}}\ {{}^{\mathrm{l}}\mathrm{\underline{a}ngle}}\ {\mathrm{state}} | angle ← axis langle state |
| 137 | target := 90.0 * f_loat axis l:s_teps state | \ \ {\mathrm{target}}\ {\leftarrow}\ {90.0}\ {\times}\ {\mathrm{\underline{f}loat}}\ {\mathrm{axis}}\ {{}^{\mathrm{l}}\mathrm{\underline{s}teps}}\ {\mathrm{state}} | target ← 90.0 × float axis lsteps state |
| 138 | gap := target - angle | \ \ {\mathrm{gap}}\ {\leftarrow}\ {\mathrm{target}}\ {-}\ {\mathrm{angle}} | gap ← target − angle |
| 139 | moved := angle + gap * 1.0 m_in 2.0 * dt | \ \ {\mathrm{moved}}\ {\leftarrow}\ {\mathrm{angle}}\ {+}\ {\mathrm{gap}}\ {\times}\ {1.0}\ {\mathrm{\underline{m}in}}\ {2.0}\ {\times}\ {\mathrm{dt}} | moved ← angle + gap × 1.0 min 2.0 × dt |
| 140 | near := c"0.5 > a_bs target - moved" i_f< c"target; moved" | \ \ {\mathrm{near}}\ {\leftarrow}\ {\text{c"}}{0.5}\ {>}\ {\mathrm{\underline{a}bs}}\ {\mathrm{target}}\ {-}\ {\mathrm{moved}}{\text{"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{c"}}{\mathrm{target}}{\diamond}\ {\mathrm{moved}}{\text{"}} | near ← c"0.5 > abs target − moved" if< c"target⋄ moved" |
| 141 | (axis, near) h:a_ngleTo state | \ \ {(}{\mathrm{axis}}{,}\ {\mathrm{near}}{)}\ {{}^{\mathrm{h}}\mathrm{\underline{a}ngleTo}}\ {\mathrm{state}} | (axis, near) hangleTo state |
| 142 | } | {\}} | } |
| 149 | l:s_ettle := { state -> (l:BOTTOM, 9.0) l:e_ase (l:TOP, 9.0) l:e_ase (l:IDIOM, 9.0) l:e_ase state } | {{}^{\mathrm{l}}\mathrm{\underline{s}ettle}}\ {\leftarrow}\ {\{}\ {\mathrm{state}}\ {\to}\ {(}{{}^{\mathrm{l}}\mathrm{BOTTOM}}{,}\ {9.0}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{e}ase}}\ {(}{{}^{\mathrm{l}}\mathrm{TOP}}{,}\ {9.0}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{e}ase}}\ {(}{{}^{\mathrm{l}}\mathrm{IDIOM}}{,}\ {9.0}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{e}ase}}\ {\mathrm{state}}\ {\}} | lsettle ← { state → (lBOTTOM, 9.0) lease (lTOP, 9.0) lease (lIDIOM, 9.0) lease state } |
| 160 | l:t_ick := { dt state -> | {{}^{\mathrm{l}}\mathrm{\underline{t}ick}}\ {\leftarrow}\ {\{}\ {\mathrm{dt}}\ {\mathrm{state}}\ {\to} | ltick ← { dt state → |
| 161 | eased := (l:BOTTOM, dt) l:e_ase (l:TOP, dt) l:e_ase (l:IDIOM, dt) l:e_ase state | \ \ {\mathrm{eased}}\ {\leftarrow}\ {(}{{}^{\mathrm{l}}\mathrm{BOTTOM}}{,}\ {\mathrm{dt}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{e}ase}}\ {(}{{}^{\mathrm{l}}\mathrm{TOP}}{,}\ {\mathrm{dt}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{e}ase}}\ {(}{{}^{\mathrm{l}}\mathrm{IDIOM}}{,}\ {\mathrm{dt}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{e}ase}}\ {\mathrm{state}} | eased ← (lBOTTOM, dt) lease (lTOP, dt) lease (lIDIOM, dt) lease state |
| 162 | (axes, q, (idle0, since0, b, i)) := eased | \ \ {(}{\mathrm{axes}}{,}\ {\mathrm{q}}{,}\ {(}{\mathrm{idle0}}{,}\ {\mathrm{since0}}{,}\ {\mathrm{b}}{,}\ {\mathrm{i}}{)}{)}\ {\leftarrow}\ {\mathrm{eased}} | (axes, q, (idle0, since0, b, i)) ← eased |
| 163 | idle := dt + idle0 | \ \ {\mathrm{idle}}\ {\leftarrow}\ {\mathrm{dt}}\ {+}\ {\mathrm{idle0}} | idle ← dt + idle0 |
| 164 | since := dt + since0 | \ \ {\mathrm{since}}\ {\leftarrow}\ {\mathrm{dt}}\ {+}\ {\mathrm{since0}} | since ← dt + since0 |
| 165 | (idle < l:idleBefore) | since < l:dwell ? (axes, q, (idle, since, b, i)) | \ \ {(}{\mathrm{idle}}\ {<}\ {{}^{\mathrm{l}}\mathrm{idleBefore}}{)}\ {\vee}\ {\mathrm{since}}\ {<}\ {{}^{\mathrm{l}}\mathrm{dwell}}\ {?}\ {(}{\mathrm{axes}}{,}\ {\mathrm{q}}{,}\ {(}{\mathrm{idle}}{,}\ {\mathrm{since}}{,}\ {\mathrm{b}}{,}\ {\mathrm{i}}{)}{)} | (idle < lidleBefore) ∨ since < ldwell ? (axes, q, (idle, since, b, i)) |
| 166 | l:a_ttract (axes, q, (idle, 0.0, b, i)) | \ \ {{}^{\mathrm{l}}\mathrm{\underline{a}ttract}}\ {(}{\mathrm{axes}}{,}\ {\mathrm{q}}{,}\ {(}{\mathrm{idle}}{,}\ {0.0}{,}\ {\mathrm{b}}{,}\ {\mathrm{i}}{)}{)} | lattract (axes, q, (idle, 0.0, b, i)) |
| 167 | } | {\}} | } |
| 185 | l:a_ttract := { state -> | {{}^{\mathrm{l}}\mathrm{\underline{a}ttract}}\ {\leftarrow}\ {\{}\ {\mathrm{state}}\ {\to} | lattract ← { state → |
| 186 | n := (l:TOP l:c_ount state) - 1 | \ \ {\mathrm{n}}\ {\leftarrow}\ {(}{{}^{\mathrm{l}}\mathrm{TOP}}\ {{}^{\mathrm{l}}\mathrm{\underline{c}ount}}\ {\mathrm{state}}{)}\ {-}\ {1} | n ← (lTOP lcount state) − 1 |
| 187 | m := l:IDIOM l:c_ount state | \ \ {\mathrm{m}}\ {\leftarrow}\ {{}^{\mathrm{l}}\mathrm{IDIOM}}\ {{}^{\mathrm{l}}\mathrm{\underline{c}ount}}\ {\mathrm{state}} | m ← lIDIOM lcount state |
| 188 | (_, _, (idle, since, b0, i0)) := state | \ \ {(}{\_}{,}\ {\_}{,}\ {(}{\mathrm{idle}}{,}\ {\mathrm{since}}{,}\ {\mathrm{b0}}{,}\ {\mathrm{i0}}{)}{)}\ {\leftarrow}\ {\mathrm{state}} | (_, _, (idle, since, b0, i0)) ← state |
| 189 | (axes1, q1, _) := l:BOTTOM l:p_lay state | \ \ {(}{\mathrm{axes1}}{,}\ {\mathrm{q1}}{,}\ {\_}{)}\ {\leftarrow}\ {{}^{\mathrm{l}}\mathrm{BOTTOM}}\ {{}^{\mathrm{l}}\mathrm{\underline{p}lay}}\ {\mathrm{state}} | (axes1, q1, _) ← lBOTTOM lplay state |
| 190 | (1 + b0) < n ? (axes1, q1, (idle, since, 1 + b0, i0)) | \ \ {(}{1}\ {+}\ {\mathrm{b0}}{)}\ {<}\ {\mathrm{n}}\ {?}\ {(}{\mathrm{axes1}}{,}\ {\mathrm{q1}}{,}\ {(}{\mathrm{idle}}{,}\ {\mathrm{since}}{,}\ {1}\ {+}\ {\mathrm{b0}}{,}\ {\mathrm{i0}}{)}{)} | (1 + b0) < n ? (axes1, q1, (idle, since, 1 + b0, i0)) |
| 191 | (axes2, q2, _) := l:IDIOM l:p_lay (axes1, q1, (idle, since, 0, i0)) | \ \ {(}{\mathrm{axes2}}{,}\ {\mathrm{q2}}{,}\ {\_}{)}\ {\leftarrow}\ {{}^{\mathrm{l}}\mathrm{IDIOM}}\ {{}^{\mathrm{l}}\mathrm{\underline{p}lay}}\ {(}{\mathrm{axes1}}{,}\ {\mathrm{q1}}{,}\ {(}{\mathrm{idle}}{,}\ {\mathrm{since}}{,}\ {0}{,}\ {\mathrm{i0}}{)}{)} | (axes2, q2, _) ← lIDIOM lplay (axes1, q1, (idle, since, 0, i0)) |
| 192 | (1 + i0) < m ? (axes2, q2, (idle, since, 0, 1 + i0)) | \ \ {(}{1}\ {+}\ {\mathrm{i0}}{)}\ {<}\ {\mathrm{m}}\ {?}\ {(}{\mathrm{axes2}}{,}\ {\mathrm{q2}}{,}\ {(}{\mathrm{idle}}{,}\ {\mathrm{since}}{,}\ {0}{,}\ {1}\ {+}\ {\mathrm{i0}}{)}{)} | (1 + i0) < m ? (axes2, q2, (idle, since, 0, 1 + i0)) |
| 193 | l:TOP l:p_lay (axes2, q2, (idle, since, 0, 0)) | \ \ {{}^{\mathrm{l}}\mathrm{TOP}}\ {{}^{\mathrm{l}}\mathrm{\underline{p}lay}}\ {(}{\mathrm{axes2}}{,}\ {\mathrm{q2}}{,}\ {(}{\mathrm{idle}}{,}\ {\mathrm{since}}{,}\ {0}{,}\ {0}{)}{)} | lTOP lplay (axes2, q2, (idle, since, 0, 0)) |
| 194 | } | {\}} | } |
| 197 | l:p_lay := { axis state -> c"1 = axis l:p_laying state" i_f< c"(axis, 1) l:s_tep state; state" } | {{}^{\mathrm{l}}\mathrm{\underline{p}lay}}\ {\leftarrow}\ {\{}\ {\mathrm{axis}}\ {\mathrm{state}}\ {\to}\ {\text{c"}}{1}\ {=}\ {\mathrm{axis}}\ {{}^{\mathrm{l}}\mathrm{\underline{p}laying}}\ {\mathrm{state}}{\text{"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{c"}}{(}{\mathrm{axis}}{,}\ {1}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{s}tep}}\ {\mathrm{state}}{\diamond}\ {\mathrm{state}}{\text{"}}\ {\}} | lplay ← { axis state → c"1 = axis lplaying state" if< c"(axis, 1) lstep state⋄ state" } |
| 200 | l:t_ouched := { state -> (axes, q, (_, _, b, i)) := state; (axes, q, (0.0, 0.0, b, i)) } | {{}^{\mathrm{l}}\mathrm{\underline{t}ouched}}\ {\leftarrow}\ {\{}\ {\mathrm{state}}\ {\to}\ {(}{\mathrm{axes}}{,}\ {\mathrm{q}}{,}\ {(}{\_}{,}\ {\_}{,}\ {\mathrm{b}}{,}\ {\mathrm{i}}{)}{)}\ {\leftarrow}\ {\mathrm{state}}{\diamond}\ {(}{\mathrm{axes}}{,}\ {\mathrm{q}}{,}\ {(}{0.0}{,}\ {0.0}{,}\ {\mathrm{b}}{,}\ {\mathrm{i}}{)}{)}\ {\}} | ltouched ← { state → (axes, q, (_, _, b, i)) ← state⋄ (axes, q, (0.0, 0.0, b, i)) } |
| 203 | l:r_esume := { state -> ((c, s, a, _), q, k) := state; ((c, s, a, 1 1 1), q, k) } | {{}^{\mathrm{l}}\mathrm{\underline{r}esume}}\ {\leftarrow}\ {\{}\ {\mathrm{state}}\ {\to}\ {(}{(}{\mathrm{c}}{,}\ {\mathrm{s}}{,}\ {\mathrm{a}}{,}\ {\_}{)}{,}\ {\mathrm{q}}{,}\ {\mathrm{k}}{)}\ {\leftarrow}\ {\mathrm{state}}{\diamond}\ {(}{(}{\mathrm{c}}{,}\ {\mathrm{s}}{,}\ {\mathrm{a}}{,}\ {1}\ {1}\ {1}{)}{,}\ {\mathrm{q}}{,}\ {\mathrm{k}}{)}\ {\}} | lresume ← { state → ((c, s, a, _), q, k) ← state⋄ ((c, s, a, 1 1 1), q, k) } |
| 214 | l:t_oggleTour := { state -> | {{}^{\mathrm{l}}\mathrm{\underline{t}oggleTour}}\ {\leftarrow}\ {\{}\ {\mathrm{state}}\ {\to} | ltoggleTour ← { state → |
| 215 | ((c, s, a, p), q, k) := state | \ \ {(}{(}{\mathrm{c}}{,}\ {\mathrm{s}}{,}\ {\mathrm{a}}{,}\ {\mathrm{p}}{)}{,}\ {\mathrm{q}}{,}\ {\mathrm{k}}{)}\ {\leftarrow}\ {\mathrm{state}} | ((c, s, a, p), q, k) ← state |
| 216 | 0 < '+ r_/ p ? ((c, s, a, 0 0 0), q, k) | \ \ {0}\ {<}\ {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{p}}\ {?}\ {(}{(}{\mathrm{c}}{,}\ {\mathrm{s}}{,}\ {\mathrm{a}}{,}\ {0}\ {0}\ {0}{)}{,}\ {\mathrm{q}}{,}\ {\mathrm{k}}{)} | 0 < ’+ r/ p ? ((c, s, a, 0 0 0), q, k) |
| 217 | l:r_esume state | \ \ {{}^{\mathrm{l}}\mathrm{\underline{r}esume}}\ {\mathrm{state}} | lresume state |
| 218 | } | {\}} | } |
| 232 | l:m_ode := { state -> | {{}^{\mathrm{l}}\mathrm{\underline{m}ode}}\ {\leftarrow}\ {\{}\ {\mathrm{state}}\ {\to} | lmode ← { state → |
| 233 | ((_, _, _, p), _, (idle, _, _, _)) := state | \ \ {(}{(}{\_}{,}\ {\_}{,}\ {\_}{,}\ {\mathrm{p}}{)}{,}\ {\_}{,}\ {(}{\mathrm{idle}}{,}\ {\_}{,}\ {\_}{,}\ {\_}{)}{)}\ {\leftarrow}\ {\mathrm{state}} | ((_, _, _, p), _, (idle, _, _, _)) ← state |
| 234 | paused := 1 - p | \ \ {\mathrm{paused}}\ {\leftarrow}\ {1}\ {-}\ {\mathrm{p}} | paused ← 1 − p |
| 235 | 3 = '+ r_/ paused ? "paused" | \ \ {3}\ {=}\ {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{paused}}\ {?}\ {\text{"paused"}} | 3 = ’+ r/ paused ? "paused" |
| 236 | names := paused r_eplicate "roll" "top" "bottom" | \ \ {\mathrm{names}}\ {\leftarrow}\ {\mathrm{paused}}\ {\mathrm{\underline{r}eplicate}}\ {\text{"roll"}}\ {\text{"top"}}\ {\text{"bottom"}} | names ← paused replicate "roll" "top" "bottom" |
| 237 | 0 < '+ r_/ paused ? "paused: " c_at d_isclose '{ x y -> e_nclose (d_isclose x) c_at ", " c_at d_isclose y } r_/ names | \ \ {0}\ {<}\ {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{paused}}\ {?}\ {\text{"paused: "}}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{d}isclose}}\ {\text{'}}{\{}\ {\mathrm{x}}\ {\mathrm{y}}\ {\to}\ {\mathrm{\underline{e}nclose}}\ {(}{\mathrm{\underline{d}isclose}}\ {\mathrm{x}}{)}\ {\mathrm{\underline{c}at}}\ {\text{", "}}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{d}isclose}}\ {\mathrm{y}}\ {\}}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{names}} | 0 < ’+ r/ paused ? "paused: " cat disclose ’{ x y → enclose (disclose x) cat ", " cat disclose y } r/ names |
| 238 | l:idleBefore > idle ? "holding" | \ \ {{}^{\mathrm{l}}\mathrm{idleBefore}}\ {>}\ {\mathrm{idle}}\ {?}\ {\text{"holding"}} | lidleBefore > idle ? "holding" |
| 239 | "touring" | \ \ {\text{"touring"}} | "touring" |
| 240 | } | {\}} | } |
| 243 | l:t_oggle := { axis state -> (axis, 1 - axis l:p_laying state) h:p_layingTo state } | {{}^{\mathrm{l}}\mathrm{\underline{t}oggle}}\ {\leftarrow}\ {\{}\ {\mathrm{axis}}\ {\mathrm{state}}\ {\to}\ {(}{\mathrm{axis}}{,}\ {1}\ {-}\ {\mathrm{axis}}\ {{}^{\mathrm{l}}\mathrm{\underline{p}laying}}\ {\mathrm{state}}{)}\ {{}^{\mathrm{h}}\mathrm{\underline{p}layingTo}}\ {\mathrm{state}}\ {\}} | ltoggle ← { axis state → (axis, 1 − axis lplaying state) hplayingTo state } |
| 255 | l:u_pdate := { state e -> | {{}^{\mathrm{l}}\mathrm{\underline{u}pdate}}\ {\leftarrow}\ {\{}\ {\mathrm{state}}\ {\mathrm{e}}\ {\to} | lupdate ← { state e → |
| 256 | kind := []E_KIND e | \ \ {\mathrm{kind}}\ {\leftarrow}\ {\square \mathrm{\underline{E}KIND}}\ {\mathrm{e}} | kind ← □EKIND e |
| 257 | kind m_atch "tick" ? (f_irst []E_AT e) l:t_ick state | \ \ {\mathrm{kind}}\ {\mathrm{\underline{m}atch}}\ {\text{"tick"}}\ {?}\ {(}{\mathrm{\underline{f}irst}}\ {\square \mathrm{\underline{E}AT}}\ {\mathrm{e}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{t}ick}}\ {\mathrm{state}} | kind match "tick" ? (first □EAT e) ltick state |
| 258 | touched := l:t_ouched state | \ \ {\mathrm{touched}}\ {\leftarrow}\ {{}^{\mathrm{l}}\mathrm{\underline{t}ouched}}\ {\mathrm{state}} | touched ← ltouched state |
| 259 | at := []E_AT e | \ \ {\mathrm{at}}\ {\leftarrow}\ {\square \mathrm{\underline{E}AT}}\ {\mathrm{e}} | at ← □EAT e |
| 260 | kind m_atch "key" ? ([]E_KEY e) l:k_ey touched | \ \ {\mathrm{kind}}\ {\mathrm{\underline{m}atch}}\ {\text{"key"}}\ {?}\ {(}{\square \mathrm{\underline{E}KEY}}\ {\mathrm{e}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{k}ey}}\ {\mathrm{touched}} | kind match "key" ? (□EKEY e) lkey touched |
| 261 | kind m_atch "down" ? at l:d_own touched | \ \ {\mathrm{kind}}\ {\mathrm{\underline{m}atch}}\ {\text{"down"}}\ {?}\ {\mathrm{at}}\ {{}^{\mathrm{l}}\mathrm{\underline{d}own}}\ {\mathrm{touched}} | kind match "down" ? at ldown touched |
| 262 | kind m_atch "move" ? at l:m_ove touched | \ \ {\mathrm{kind}}\ {\mathrm{\underline{m}atch}}\ {\text{"move"}}\ {?}\ {\mathrm{at}}\ {{}^{\mathrm{l}}\mathrm{\underline{m}ove}}\ {\mathrm{touched}} | kind match "move" ? at lmove touched |
| 263 | kind m_atch "up" ? at l:u_p touched | \ \ {\mathrm{kind}}\ {\mathrm{\underline{m}atch}}\ {\text{"up"}}\ {?}\ {\mathrm{at}}\ {{}^{\mathrm{l}}\mathrm{\underline{u}p}}\ {\mathrm{touched}} | kind match "up" ? at lup touched |
| 264 | kind m_atch "click" ? at l:c_lick touched | \ \ {\mathrm{kind}}\ {\mathrm{\underline{m}atch}}\ {\text{"click"}}\ {?}\ {\mathrm{at}}\ {{}^{\mathrm{l}}\mathrm{\underline{c}lick}}\ {\mathrm{touched}} | kind match "click" ? at lclick touched |
| 265 | kind m_atch "choose" ? (f_loor 1 s_elect at, f_loor 2 s_elect at) l:c_hoose touched | \ \ {\mathrm{kind}}\ {\mathrm{\underline{m}atch}}\ {\text{"choose"}}\ {?}\ {(}{\mathrm{\underline{f}loor}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{at}}{,}\ {\mathrm{\underline{f}loor}}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{at}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{c}hoose}}\ {\mathrm{touched}} | kind match "choose" ? (floor 1 select at, floor 2 select at) lchoose touched |
| 266 | state | \ \ {\mathrm{state}} | state |
| 267 | } | {\}} | } |
| 271 | l:h_alf := { xy -> c"(2 s_elect xy) < l:middle" i_f< c"l:TOP; l:BOTTOM" } | {{}^{\mathrm{l}}\mathrm{\underline{h}alf}}\ {\leftarrow}\ {\{}\ {\mathrm{xy}}\ {\to}\ {\text{c"}}{(}{2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{xy}}{)}\ {<}\ {{}^{\mathrm{l}}\mathrm{middle}}{\text{"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{c"}}{{}^{\mathrm{l}}\mathrm{TOP}}{\diamond}\ {{}^{\mathrm{l}}\mathrm{BOTTOM}}{\text{"}}\ {\}} | lhalf ← { xy → c"(2 select xy) < lmiddle" if< c"lTOP⋄ lBOTTOM" } |
| 278 | l:d_own := { xy state -> (axes, _, k) := state; (axes, (-1, xy, 0.0, 0.0), k) } | {{}^{\mathrm{l}}\mathrm{\underline{d}own}}\ {\leftarrow}\ {\{}\ {\mathrm{xy}}\ {\mathrm{state}}\ {\to}\ {(}{\mathrm{axes}}{,}\ {\_}{,}\ {\mathrm{k}}{)}\ {\leftarrow}\ {\mathrm{state}}{\diamond}\ {(}{\mathrm{axes}}{,}\ {(}{-1}{,}\ {\mathrm{xy}}{,}\ {0.0}{,}\ {0.0}{)}{,}\ {\mathrm{k}}{)}\ {\}} | ldown ← { xy state → (axes, _, k) ← state⋄ (axes, (−1, xy, 0.0, 0.0), k) } |
| 292 | l:m_ove := { xy state -> | {{}^{\mathrm{l}}\mathrm{\underline{m}ove}}\ {\leftarrow}\ {\{}\ {\mathrm{xy}}\ {\mathrm{state}}\ {\to} | lmove ← { xy state → |
| 293 | (axes, (held, was, moved0, last), k) := state | \ \ {(}{\mathrm{axes}}{,}\ {(}{\mathrm{held}}{,}\ {\mathrm{was}}{,}\ {\mathrm{moved0}}{,}\ {\mathrm{last}}{)}{,}\ {\mathrm{k}}{)}\ {\leftarrow}\ {\mathrm{state}} | (axes, (held, was, moved0, last), k) ← state |
| 294 | held = 0 ? state | \ \ {\mathrm{held}}\ {=}\ {0}\ {?}\ {\mathrm{state}} | held = 0 ? state |
| 295 | dx := (1 s_elect xy) - 1 s_elect was | \ \ {\mathrm{dx}}\ {\leftarrow}\ {(}{1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{xy}}{)}\ {-}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{was}} | dx ← (1 select xy) − 1 select was |
| 296 | dy := (2 s_elect xy) - 2 s_elect was | \ \ {\mathrm{dy}}\ {\leftarrow}\ {(}{2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{xy}}{)}\ {-}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{was}} | dy ← (2 select xy) − 2 select was |
| 297 | moved := (a_bs dx) + (a_bs dy) + moved0 | \ \ {\mathrm{moved}}\ {\leftarrow}\ {(}{\mathrm{\underline{a}bs}}\ {\mathrm{dx}}{)}\ {+}\ {(}{\mathrm{\underline{a}bs}}\ {\mathrm{dy}}{)}\ {+}\ {\mathrm{moved0}} | moved ← (abs dx) + (abs dy) + moved0 |
| 298 | placed := (axes, (held, xy, moved, last), k) | \ \ {\mathrm{placed}}\ {\leftarrow}\ {(}{\mathrm{axes}}{,}\ {(}{\mathrm{held}}{,}\ {\mathrm{xy}}{,}\ {\mathrm{moved}}{,}\ {\mathrm{last}}{)}{,}\ {\mathrm{k}}{)} | placed ← (axes, (held, xy, moved, last), k) |
| 299 | (held = -1) & moved <= 4.0 ? placed | \ \ {(}{\mathrm{held}}\ {=}\ {-1}{)}\ {\wedge}\ {\mathrm{moved}}\ {\leq}\ {4.0}\ {?}\ {\mathrm{placed}} | (held = −1) ∧ moved ≤ 4.0 ? placed |
| 300 | axis := c"held = -1" i_f< c"\"(a_bs dx) >= a_bs dy\" i_f< \"l:h_alf xy; l:IDIOM\"; held" | \ \ {\mathrm{axis}}\ {\leftarrow}\ {\text{c"}}{\mathrm{held}}\ {=}\ {-1}{\text{"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{c"}}{\text{\textbackslash{}"(a\_bs dx) >= a\_bs dy\textbackslash{}"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{\textbackslash{}"l:h\_alf xy; l:IDIOM\textbackslash{}"}}{\diamond}\ {\mathrm{held}}{\text{"}} | axis ← c"held = −1" if< c"\"(a_bs dx) >= a_bs dy\" if< \"l:h_alf xy; l:IDIOM\"⋄ held" |
| 301 | along := c"axis = l:IDIOM" i_f< c"dy; dx" | \ \ {\mathrm{along}}\ {\leftarrow}\ {\text{c"}}{\mathrm{axis}}\ {=}\ {{}^{\mathrm{l}}\mathrm{IDIOM}}{\text{"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{c"}}{\mathrm{dy}}{\diamond}\ {\mathrm{dx}}{\text{"}} | along ← c"axis = lIDIOM" if< c"dy⋄ dx" |
| 302 | turn := n_eg along * l:perPixel | \ \ {\mathrm{turn}}\ {\leftarrow}\ {\mathrm{\underline{n}eg}}\ {\mathrm{along}}\ {\times}\ {{}^{\mathrm{l}}\mathrm{perPixel}} | turn ← neg along × lperPixel |
| 303 | (turned, _, _) := (axis, turn + axis l:a_ngle placed) h:a_ngleTo placed | \ \ {(}{\mathrm{turned}}{,}\ {\_}{,}\ {\_}{)}\ {\leftarrow}\ {(}{\mathrm{axis}}{,}\ {\mathrm{turn}}\ {+}\ {\mathrm{axis}}\ {{}^{\mathrm{l}}\mathrm{\underline{a}ngle}}\ {\mathrm{placed}}{)}\ {{}^{\mathrm{h}}\mathrm{\underline{a}ngleTo}}\ {\mathrm{placed}} | (turned, _, _) ← (axis, turn + axis langle placed) hangleTo placed |
| 304 | (turned, (axis, xy, moved, turn), k) | \ \ {(}{\mathrm{turned}}{,}\ {(}{\mathrm{axis}}{,}\ {\mathrm{xy}}{,}\ {\mathrm{moved}}{,}\ {\mathrm{turn}}{)}{,}\ {\mathrm{k}}{)} | (turned, (axis, xy, moved, turn), k) |
| 305 | } | {\}} | } |
| 316 | l:u_p := { xy state -> | {{}^{\mathrm{l}}\mathrm{\underline{u}p}}\ {\leftarrow}\ {\{}\ {\mathrm{xy}}\ {\mathrm{state}}\ {\to} | lup ← { xy state → |
| 317 | (axes, (held, was, moved, last), k) := state | \ \ {(}{\mathrm{axes}}{,}\ {(}{\mathrm{held}}{,}\ {\mathrm{was}}{,}\ {\mathrm{moved}}{,}\ {\mathrm{last}}{)}{,}\ {\mathrm{k}}{)}\ {\leftarrow}\ {\mathrm{state}} | (axes, (held, was, moved, last), k) ← state |
| 318 | held = 0 ? state | \ \ {\mathrm{held}}\ {=}\ {0}\ {?}\ {\mathrm{state}} | held = 0 ? state |
| 319 | released := (axes, (0, was, moved, last), k) | \ \ {\mathrm{released}}\ {\leftarrow}\ {(}{\mathrm{axes}}{,}\ {(}{0}{,}\ {\mathrm{was}}{,}\ {\mathrm{moved}}{,}\ {\mathrm{last}}{)}{,}\ {\mathrm{k}}{)} | released ← (axes, (0, was, moved, last), k) |
| 320 | held = -1 ? xy l:c_lick released | \ \ {\mathrm{held}}\ {=}\ {-1}\ {?}\ {\mathrm{xy}}\ {{}^{\mathrm{l}}\mathrm{\underline{c}lick}}\ {\mathrm{released}} | held = −1 ? xy lclick released |
| 321 | flick := c"6.0 < a_bs last" i_f< c"45.0 * last / a_bs last; 0.0" | \ \ {\mathrm{flick}}\ {\leftarrow}\ {\text{c"}}{6.0}\ {<}\ {\mathrm{\underline{a}bs}}\ {\mathrm{last}}{\text{"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{c"}}{45.0}\ {\times}\ {\mathrm{last}}\ {\div}\ {\mathrm{\underline{a}bs}}\ {\mathrm{last}}{\diamond}\ {0.0}{\text{"}} | flick ← c"6.0 < abs last" if< c"45.0 × last ÷ abs last⋄ 0.0" |
| 322 | angle := held l:a_ngle state | \ \ {\mathrm{angle}}\ {\leftarrow}\ {\mathrm{held}}\ {{}^{\mathrm{l}}\mathrm{\underline{a}ngle}}\ {\mathrm{state}} | angle ← held langle state |
| 323 | (held, f_loor 0.5 + (angle + flick) / 90.0) h:s_tepsTo released | \ \ {(}{\mathrm{held}}{,}\ {\mathrm{\underline{f}loor}}\ {0.5}\ {+}\ {(}{\mathrm{angle}}\ {+}\ {\mathrm{flick}}{)}\ {\div}\ {90.0}{)}\ {{}^{\mathrm{h}}\mathrm{\underline{s}tepsTo}}\ {\mathrm{released}} | (held, floor 0.5 + (angle + flick) ÷ 90.0) hstepsTo released |
| 324 | } | {\}} | } |
| 330 | l:c_lick := { xy state -> (l:h_alf xy) l:t_oggle state } | {{}^{\mathrm{l}}\mathrm{\underline{c}lick}}\ {\leftarrow}\ {\{}\ {\mathrm{xy}}\ {\mathrm{state}}\ {\to}\ {(}{{}^{\mathrm{l}}\mathrm{\underline{h}alf}}\ {\mathrm{xy}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{t}oggle}}\ {\mathrm{state}}\ {\}} | lclick ← { xy state → (lhalf xy) ltoggle state } |
| 334 | l:k_ey := { k state -> | {{}^{\mathrm{l}}\mathrm{\underline{k}ey}}\ {\leftarrow}\ {\{}\ {\mathrm{k}}\ {\mathrm{state}}\ {\to} | lkey ← { k state → |
| 335 | k = []K_NAMED 1 ? (l:IDIOM, -1) l:s_tep state | \ \ {\mathrm{k}}\ {=}\ {\square \mathrm{\underline{K}NAMED}}\ {1}\ {?}\ {(}{{}^{\mathrm{l}}\mathrm{IDIOM}}{,}\ {-1}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{s}tep}}\ {\mathrm{state}} | k = □KNAMED 1 ? (lIDIOM, −1) lstep state |
| 336 | k = []K_NAMED 2 ? (l:IDIOM, 1) l:s_tep state | \ \ {\mathrm{k}}\ {=}\ {\square \mathrm{\underline{K}NAMED}}\ {2}\ {?}\ {(}{{}^{\mathrm{l}}\mathrm{IDIOM}}{,}\ {1}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{s}tep}}\ {\mathrm{state}} | k = □KNAMED 2 ? (lIDIOM, 1) lstep state |
| 337 | k = []K_NAMED 3 ? (l:TOP, -1) l:s_tep state | \ \ {\mathrm{k}}\ {=}\ {\square \mathrm{\underline{K}NAMED}}\ {3}\ {?}\ {(}{{}^{\mathrm{l}}\mathrm{TOP}}{,}\ {-1}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{s}tep}}\ {\mathrm{state}} | k = □KNAMED 3 ? (lTOP, −1) lstep state |
| 338 | k = []K_NAMED 4 ? (l:TOP, 1) l:s_tep state | \ \ {\mathrm{k}}\ {=}\ {\square \mathrm{\underline{K}NAMED}}\ {4}\ {?}\ {(}{{}^{\mathrm{l}}\mathrm{TOP}}{,}\ {1}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{s}tep}}\ {\mathrm{state}} | k = □KNAMED 4 ? (lTOP, 1) lstep state |
| 339 | c := []K_CHAR k | \ \ {\mathrm{c}}\ {\leftarrow}\ {\square \mathrm{\underline{K}CHAR}}\ {\mathrm{k}} | c ← □KCHAR k |
| 340 | c m_atch "a" ? (l:BOTTOM, -1) l:s_tep state | \ \ {\mathrm{c}}\ {\mathrm{\underline{m}atch}}\ {\text{"a"}}\ {?}\ {(}{{}^{\mathrm{l}}\mathrm{BOTTOM}}{,}\ {-1}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{s}tep}}\ {\mathrm{state}} | c match "a" ? (lBOTTOM, −1) lstep state |
| 341 | c m_atch "d" ? (l:BOTTOM, 1) l:s_tep state | \ \ {\mathrm{c}}\ {\mathrm{\underline{m}atch}}\ {\text{"d"}}\ {?}\ {(}{{}^{\mathrm{l}}\mathrm{BOTTOM}}{,}\ {1}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{s}tep}}\ {\mathrm{state}} | c match "d" ? (lBOTTOM, 1) lstep state |
| 342 | c m_atch " " ? l:t_oggleTour state | \ \ {\mathrm{c}}\ {\mathrm{\underline{m}atch}}\ {\text{" "}}\ {?}\ {{}^{\mathrm{l}}\mathrm{\underline{t}oggleTour}}\ {\mathrm{state}} | c match " " ? ltoggleTour state |
| 343 | c m_atch "r" ? l:idleBefore h:i_dleTo l:r_esume state | \ \ {\mathrm{c}}\ {\mathrm{\underline{m}atch}}\ {\text{"r"}}\ {?}\ {{}^{\mathrm{l}}\mathrm{idleBefore}}\ {{}^{\mathrm{h}}\mathrm{\underline{i}dleTo}}\ {{}^{\mathrm{l}}\mathrm{\underline{r}esume}}\ {\mathrm{state}} | c match "r" ? lidleBefore hidleTo lresume state |
| 344 | c m_atch "s" ? l:BOTTOM l:t_oggle state | \ \ {\mathrm{c}}\ {\mathrm{\underline{m}atch}}\ {\text{"s"}}\ {?}\ {{}^{\mathrm{l}}\mathrm{BOTTOM}}\ {{}^{\mathrm{l}}\mathrm{\underline{t}oggle}}\ {\mathrm{state}} | c match "s" ? lBOTTOM ltoggle state |
| 345 | c m_atch "w" ? l:IDIOM l:t_oggle state | \ \ {\mathrm{c}}\ {\mathrm{\underline{m}atch}}\ {\text{"w"}}\ {?}\ {{}^{\mathrm{l}}\mathrm{IDIOM}}\ {{}^{\mathrm{l}}\mathrm{\underline{t}oggle}}\ {\mathrm{state}} | c match "w" ? lIDIOM ltoggle state |
| 346 | state | \ \ {\mathrm{state}} | state |
| 347 | } | {\}} | } |
| 14 | "g:" u_se< "Geometry3D" | {\text{"g:"}}\ {\mathrm{\underline{u}se}{<}}\ {\text{"Geometry3D"}} | "g:" use< "Geometry3D" |
| 15 | "v:" u_se< "Svg" | {\text{"v:"}}\ {\mathrm{\underline{u}se}{<}}\ {\text{"Svg"}} | "v:" use< "Svg" |
| 20 | l:width := 2.4 | {{}^{\mathrm{l}}\mathrm{width}}\ {\leftarrow}\ {2.4} | lwidth ← 2.4 |
| 21 | l:height := 2.0 | {{}^{\mathrm{l}}\mathrm{height}}\ {\leftarrow}\ {2.0} | lheight ← 2.0 |
| 22 | l:depth := 2.0 | {{}^{\mathrm{l}}\mathrm{depth}}\ {\leftarrow}\ {2.0} | ldepth ← 2.0 |
| 23 | l:eye := 7.0 | {{}^{\mathrm{l}}\mathrm{eye}}\ {\leftarrow}\ {7.0} | leye ← 7.0 |
| 24 | l:size := 420.0 | {{}^{\mathrm{l}}\mathrm{size}}\ {\leftarrow}\ {420.0} | lsize ← 420.0 |
| 25 | zoom := 112.0 | {\mathrm{zoom}}\ {\leftarrow}\ {112.0} | zoom ← 112.0 |
| 30 | l:b_ox := { whd -> (3 8 r_eshape 8 r_eplicate 0.5 * whd) * g:c_ube 2 } | {{}^{\mathrm{l}}\mathrm{\underline{b}ox}}\ {\leftarrow}\ {\{}\ {\mathrm{whd}}\ {\to}\ {(}{3}\ {8}\ {\mathrm{\underline{r}eshape}}\ {8}\ {\mathrm{\underline{r}eplicate}}\ {0.5}\ {\times}\ {\mathrm{whd}}{)}\ {\times}\ {{}^{\mathrm{g}}\mathrm{\underline{c}ube}}\ {2}\ {\}} | lbox ← { whd → (3 8 reshape 8 replicate 0.5 × whd) × gcube 2 } |
| 34 | l:v_iew := { points -> ((g:r_otX 22.0) g:t_urn g:r_otY -28.0) g:t_urn points } | {{}^{\mathrm{l}}\mathrm{\underline{v}iew}}\ {\leftarrow}\ {\{}\ {\mathrm{points}}\ {\to}\ {(}{(}{{}^{\mathrm{g}}\mathrm{\underline{r}otX}}\ {22.0}{)}\ {{}^{\mathrm{g}}\mathrm{\underline{t}urn}}\ {{}^{\mathrm{g}}\mathrm{\underline{r}otY}}\ {-28.0}{)}\ {{}^{\mathrm{g}}\mathrm{\underline{t}urn}}\ {\mathrm{points}}\ {\}} | lview ← { points → ((grotX 22.0) gturn grotY −28.0) gturn points } |
| 38 | l:s_creen := { points -> | {{}^{\mathrm{l}}\mathrm{\underline{s}creen}}\ {\leftarrow}\ {\{}\ {\mathrm{points}}\ {\to} | lscreen ← { points → |
| 39 | p := l:eye g:p_roject points | \ \ {\mathrm{p}}\ {\leftarrow}\ {{}^{\mathrm{l}}\mathrm{eye}}\ {{}^{\mathrm{g}}\mathrm{\underline{p}roject}}\ {\mathrm{points}} | p ← leye gproject points |
| 40 | xs := (l:size / 2) + zoom * 1 s_elect p | \ \ {\mathrm{xs}}\ {\leftarrow}\ {(}{{}^{\mathrm{l}}\mathrm{size}}\ {\div}\ {2}{)}\ {+}\ {\mathrm{zoom}}\ {\times}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{p}} | xs ← (lsize ÷ 2) + zoom × 1 select p |
| 41 | ys := (l:size / 2) - zoom * 2 s_elect p | \ \ {\mathrm{ys}}\ {\leftarrow}\ {(}{{}^{\mathrm{l}}\mathrm{size}}\ {\div}\ {2}{)}\ {-}\ {\mathrm{zoom}}\ {\times}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{p}} | ys ← (lsize ÷ 2) − zoom × 2 select p |
| 42 | (2 c_at t_ally xs) r_eshape xs c_at ys | \ \ {(}{2}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{t}ally}}\ {\mathrm{xs}}{)}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{xs}}\ {\mathrm{\underline{c}at}}\ {\mathrm{ys}} | (2 cat tally xs) reshape xs cat ys |
| 43 | } | {\}} | } |
| 52 | l:b_ase := { a -> f_loor a / 90.0 } | {{}^{\mathrm{l}}\mathrm{\underline{b}ase}}\ {\leftarrow}\ {\{}\ {\mathrm{a}}\ {\to}\ {\mathrm{\underline{f}loor}}\ {\mathrm{a}}\ {\div}\ {90.0}\ {\}} | lbase ← { a → floor a ÷ 90.0 } |
| 53 | l:p_art := { a -> a - 90.0 * f_loat l:b_ase a } | {{}^{\mathrm{l}}\mathrm{\underline{p}art}}\ {\leftarrow}\ {\{}\ {\mathrm{a}}\ {\to}\ {\mathrm{a}}\ {-}\ {90.0}\ {\times}\ {\mathrm{\underline{f}loat}}\ {{}^{\mathrm{l}}\mathrm{\underline{b}ase}}\ {\mathrm{a}}\ {\}} | lpart ← { a → a − 90.0 × float lbase a } |
| 75 | l:r_ing := { half ad -> | {{}^{\mathrm{l}}\mathrm{\underline{r}ing}}\ {\leftarrow}\ {\{}\ {\mathrm{half}}\ {\mathrm{ad}}\ {\to} | lring ← { half ad → |
| 76 | box := l:b_ox l:width c_at (l:height / 2) c_at l:depth | \ \ {\mathrm{box}}\ {\leftarrow}\ {{}^{\mathrm{l}}\mathrm{\underline{b}ox}}\ {{}^{\mathrm{l}}\mathrm{width}}\ {\mathrm{\underline{c}at}}\ {(}{{}^{\mathrm{l}}\mathrm{height}}\ {\div}\ {2}{)}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{depth}} | box ← lbox lwidth cat (lheight ÷ 2) cat ldepth |
| 77 | lifted := box + 3 8 r_eshape 8 r_eplicate 0.0 c_at (half * l:height / 4) c_at 0.0 | \ \ {\mathrm{lifted}}\ {\leftarrow}\ {\mathrm{box}}\ {+}\ {3}\ {8}\ {\mathrm{\underline{r}eshape}}\ {8}\ {\mathrm{\underline{r}eplicate}}\ {0.0}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{half}}\ {\times}\ {{}^{\mathrm{l}}\mathrm{height}}\ {\div}\ {4}{)}\ {\mathrm{\underline{c}at}}\ {0.0} | lifted ← box + 3 8 reshape 8 replicate 0.0 cat (half × lheight ÷ 4) cat 0.0 |
| 78 | sides := 6 4 r_eshape 1 2 3 4 2 6 7 3 6 5 8 7 5 1 4 8 5 6 2 1 4 3 7 8 | \ \ {\mathrm{sides}}\ {\leftarrow}\ {6}\ {4}\ {\mathrm{\underline{r}eshape}}\ {1}\ {2}\ {3}\ {4}\ {2}\ {6}\ {7}\ {3}\ {6}\ {5}\ {8}\ {7}\ {5}\ {1}\ {4}\ {8}\ {5}\ {6}\ {2}\ {1}\ {4}\ {3}\ {7}\ {8} | sides ← 6 4 reshape 1 2 3 4 2 6 7 3 6 5 8 7 5 1 4 8 5 6 2 1 4 3 7 8 |
| 79 | turned := (g:r_otY n_eg l:p_art 1 s_elect ad) g:t_urn lifted | \ \ {\mathrm{turned}}\ {\leftarrow}\ {(}{{}^{\mathrm{g}}\mathrm{\underline{r}otY}}\ {\mathrm{\underline{n}eg}}\ {{}^{\mathrm{l}}\mathrm{\underline{p}art}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{ad}}{)}\ {{}^{\mathrm{g}}\mathrm{\underline{t}urn}}\ {\mathrm{lifted}} | turned ← (grotY neg lpart 1 select ad) gturn lifted |
| 80 | sides g:s_olid l:v_iew (g:r_otX n_eg l:p_art 2 s_elect ad) g:t_urn turned | \ \ {\mathrm{sides}}\ {{}^{\mathrm{g}}\mathrm{\underline{s}olid}}\ {{}^{\mathrm{l}}\mathrm{\underline{v}iew}}\ {(}{{}^{\mathrm{g}}\mathrm{\underline{r}otX}}\ {\mathrm{\underline{n}eg}}\ {{}^{\mathrm{l}}\mathrm{\underline{p}art}}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{ad}}{)}\ {{}^{\mathrm{g}}\mathrm{\underline{t}urn}}\ {\mathrm{turned}} | sides gsolid lview (grotX neg lpart 2 select ad) gturn turned |
| 81 | } | {\}} | } |
| 82 | l:ringOffsets := 0 1 2 -1 | {{}^{\mathrm{l}}\mathrm{ringOffsets}}\ {\leftarrow}\ {0}\ {1}\ {2}\ {-1} | lringOffsets ← 0 1 2 −1 |
| 83 | l:capOffsets := -1 1 | {{}^{\mathrm{l}}\mathrm{capOffsets}}\ {\leftarrow}\ {-1}\ {1} | lcapOffsets ← −1 1 |
| 93 | l:p_anel := { style f -> | {{}^{\mathrm{l}}\mathrm{\underline{p}anel}}\ {\leftarrow}\ {\{}\ {\mathrm{style}}\ {\mathrm{f}}\ {\to} | lpanel ← { style f → |
| 94 | s := l:s_creen f | \ \ {\mathrm{s}}\ {\leftarrow}\ {{}^{\mathrm{l}}\mathrm{\underline{s}creen}}\ {\mathrm{f}} | s ← lscreen f |
| 95 | fill := d_isclose 1 s_elect style | \ \ {\mathrm{fill}}\ {\leftarrow}\ {\mathrm{\underline{d}isclose}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{style}} | fill ← disclose 1 select style |
| 96 | lines := 1 d_rop style | \ \ {\mathrm{lines}}\ {\leftarrow}\ {1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{style}} | lines ← 1 drop style |
| 97 | shape := ((v:f_ill fill) c_at "#30363d" v:s_troke 1.2) v:p_olygon f_loor 0.5 + s | \ \ {\mathrm{shape}}\ {\leftarrow}\ {(}{(}{{}^{\mathrm{v}}\mathrm{\underline{f}ill}}\ {\mathrm{fill}}{)}\ {\mathrm{\underline{c}at}}\ {\text{"\#30363d"}}\ {{}^{\mathrm{v}}\mathrm{\underline{s}troke}}\ {1.2}{)}\ {{}^{\mathrm{v}}\mathrm{\underline{p}olygon}}\ {\mathrm{\underline{f}loor}}\ {0.5}\ {+}\ {\mathrm{s}} | shape ← ((vfill fill) cat "#30363d" vstroke 1.2) vpolygon floor 0.5 + s |
| 98 | n_ot l:f_acing s ? shape | \ \ {\mathrm{\underline{n}ot}}\ {{}^{\mathrm{l}}\mathrm{\underline{f}acing}}\ {\mathrm{s}}\ {?}\ {\mathrm{shape}} | not lfacing s ? shape |
| 99 | on := l:a_ffine 1 2 4 s_elect_2 s | \ \ {\mathrm{on}}\ {\leftarrow}\ {{}^{\mathrm{l}}\mathrm{\underline{a}ffine}}\ {1}\ {2}\ {4}\ {{\mathrm{\underline{s}elect}}_{2}}\ {\mathrm{s}} | on ← laffine 1 2 4 select2 s |
| 100 | texts := h:j_oin '{ k -> k l:l_ine d_isclose k s_elect lines } m_ap r_ange t_ally lines | \ \ {\mathrm{texts}}\ {\leftarrow}\ {{}^{\mathrm{h}}\mathrm{\underline{j}oin}}\ {\text{'}}{\{}\ {\mathrm{k}}\ {\to}\ {\mathrm{k}}\ {{}^{\mathrm{l}}\mathrm{\underline{l}ine}}\ {\mathrm{\underline{d}isclose}}\ {\mathrm{k}}\ {\mathrm{\underline{s}elect}}\ {\mathrm{lines}}\ {\}}\ {\mathrm{\underline{m}ap}}\ {\mathrm{\underline{r}ange}}\ {\mathrm{\underline{t}ally}}\ {\mathrm{lines}} | texts ← hjoin ’{ k → k lline disclose k select lines } map range tally lines |
| 101 | shape c_at on v:g_roup texts | \ \ {\mathrm{shape}}\ {\mathrm{\underline{c}at}}\ {\mathrm{on}}\ {{}^{\mathrm{v}}\mathrm{\underline{g}roup}}\ {\mathrm{texts}} | shape cat on vgroup texts |
| 102 | } | {\}} | } |
| 110 | l:r_ounded := { xs -> (f_loat f_loor 0.5 + 1000.0 * xs) / 1000.0 } | {{}^{\mathrm{l}}\mathrm{\underline{r}ounded}}\ {\leftarrow}\ {\{}\ {\mathrm{xs}}\ {\to}\ {(}{\mathrm{\underline{f}loat}}\ {\mathrm{\underline{f}loor}}\ {0.5}\ {+}\ {1000.0}\ {\times}\ {\mathrm{xs}}{)}\ {\div}\ {1000.0}\ {\}} | lrounded ← { xs → (float floor 0.5 + 1000.0 × xs) ÷ 1000.0 } |
| 119 | l:a_ffine := { c -> | {{}^{\mathrm{l}}\mathrm{\underline{a}ffine}}\ {\leftarrow}\ {\{}\ {\mathrm{c}}\ {\to} | laffine ← { c → |
| 120 | tl := 1 s_elect_2 c | \ \ {\mathrm{tl}}\ {\leftarrow}\ {1}\ {{\mathrm{\underline{s}elect}}_{2}}\ {\mathrm{c}} | tl ← 1 select2 c |
| 121 | tr := (2 s_elect_2 c) - tl | \ \ {\mathrm{tr}}\ {\leftarrow}\ {(}{2}\ {{\mathrm{\underline{s}elect}}_{2}}\ {\mathrm{c}}{)}\ {-}\ {\mathrm{tl}} | tr ← (2 select2 c) − tl |
| 122 | bl := (3 s_elect_2 c) - tl | \ \ {\mathrm{bl}}\ {\leftarrow}\ {(}{3}\ {{\mathrm{\underline{s}elect}}_{2}}\ {\mathrm{c}}{)}\ {-}\ {\mathrm{tl}} | bl ← (3 select2 c) − tl |
| 123 | "transform" v:a_ttr "matrix(" c_at (f_ormat l:r_ounded tr) c_at " " c_at (f_ormat l:r_ounded bl) c_at " " c_at (f_ormat l:r_ounded tl) c_at ")" | \ \ {\text{"transform"}}\ {{}^{\mathrm{v}}\mathrm{\underline{a}ttr}}\ {\text{"matrix("}}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{f}ormat}}\ {{}^{\mathrm{l}}\mathrm{\underline{r}ounded}}\ {\mathrm{tr}}{)}\ {\mathrm{\underline{c}at}}\ {\text{" "}}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{f}ormat}}\ {{}^{\mathrm{l}}\mathrm{\underline{r}ounded}}\ {\mathrm{bl}}{)}\ {\mathrm{\underline{c}at}}\ {\text{" "}}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{f}ormat}}\ {{}^{\mathrm{l}}\mathrm{\underline{r}ounded}}\ {\mathrm{tl}}{)}\ {\mathrm{\underline{c}at}}\ {\text{")"}} | "transform" vattr "matrix(" cat (format lrounded tr) cat " " cat (format lrounded bl) cat " " cat (format lrounded tl) cat ")" |
| 124 | } | {\}} | } |
| 135 | l:f_acing := { s -> | {{}^{\mathrm{l}}\mathrm{\underline{f}acing}}\ {\leftarrow}\ {\{}\ {\mathrm{s}}\ {\to} | lfacing ← { s → |
| 136 | xs := 1 s_elect s | \ \ {\mathrm{xs}}\ {\leftarrow}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{s}} | xs ← 1 select s |
| 137 | ys := 2 s_elect s | \ \ {\mathrm{ys}}\ {\leftarrow}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{s}} | ys ← 2 select s |
| 138 | 0 < '+ r_/ (xs * 1 o_- ys) - ys * 1 o_- xs | \ \ {0}\ {<}\ {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {(}{\mathrm{xs}}\ {\times}\ {1}\ {\mathrm{\underline{o}}{-}}\ {\mathrm{ys}}{)}\ {-}\ {\mathrm{ys}}\ {\times}\ {1}\ {\mathrm{\underline{o}}{-}}\ {\mathrm{xs}} | 0 < ’+ r/ (xs × 1 o− ys) − ys × 1 o− xs |
| 139 | } | {\}} | } |
| 145 | l:l_ine := { k t -> | {{}^{\mathrm{l}}\mathrm{\underline{l}ine}}\ {\leftarrow}\ {\{}\ {\mathrm{k}}\ {\mathrm{t}}\ {\to} | lline ← { k t → |
| 146 | size := c"k = 1" i_f< c"\"0.06\"; \"0.1\"" | \ \ {\mathrm{size}}\ {\leftarrow}\ {\text{c"}}{\mathrm{k}}\ {=}\ {1}{\text{"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{c"}}{\text{\textbackslash{}"0.06\textbackslash{}"}}{\diamond}\ {\text{\textbackslash{}"0.1\textbackslash{}"}}{\text{"}} | size ← c"k = 1" if< c"\"0.06\"⋄ \"0.1\"" |
| 147 | y := c"k = 1" i_f< c"0.13; 0.14 + 0.16 * f_loat k" | \ \ {\mathrm{y}}\ {\leftarrow}\ {\text{c"}}{\mathrm{k}}\ {=}\ {1}{\text{"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{c"}}{0.13}{\diamond}\ {0.14}\ {+}\ {0.16}\ {\times}\ {\mathrm{\underline{f}loat}}\ {\mathrm{k}}{\text{"}} | y ← c"k = 1" if< c"0.13⋄ 0.14 + 0.16 × float k" |
| 148 | color := c"k = 1" i_f< c"\"#4b5563\"; \"#000000\"" | \ \ {\mathrm{color}}\ {\leftarrow}\ {\text{c"}}{\mathrm{k}}\ {=}\ {1}{\text{"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{c"}}{\text{\textbackslash{}"\#4b5563\textbackslash{}"}}{\diamond}\ {\text{\textbackslash{}"\#000000\textbackslash{}"}}{\text{"}} | color ← c"k = 1" if< c"\"#4b5563\"⋄ \"#000000\"" |
| 149 | weight := c"k = 1" i_f< c"\"500\"; \"700\"" | \ \ {\mathrm{weight}}\ {\leftarrow}\ {\text{c"}}{\mathrm{k}}\ {=}\ {1}{\text{"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{c"}}{\text{\textbackslash{}"500\textbackslash{}"}}{\diamond}\ {\text{\textbackslash{}"700\textbackslash{}"}}{\text{"}} | weight ← c"k = 1" if< c"\"500\"⋄ \"700\"" |
| 150 | ((v:a_t 0.06 c_at y) c_at ("font-size" v:a_ttr size) c_at ("font-weight" v:a_ttr weight) c_at (v:f_ill color) c_at "font-family" v:a_ttr "ui-monospace, monospace") v:m_arkup t | \ \ {(}{(}{{}^{\mathrm{v}}\mathrm{\underline{a}t}}\ {0.06}\ {\mathrm{\underline{c}at}}\ {\mathrm{y}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\text{"font-size"}}\ {{}^{\mathrm{v}}\mathrm{\underline{a}ttr}}\ {\mathrm{size}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\text{"font-weight"}}\ {{}^{\mathrm{v}}\mathrm{\underline{a}ttr}}\ {\mathrm{weight}}{)}\ {\mathrm{\underline{c}at}}\ {(}{{}^{\mathrm{v}}\mathrm{\underline{f}ill}}\ {\mathrm{color}}{)}\ {\mathrm{\underline{c}at}}\ {\text{"font-family"}}\ {{}^{\mathrm{v}}\mathrm{\underline{a}ttr}}\ {\text{"ui-monospace, monospace"}}{)}\ {{}^{\mathrm{v}}\mathrm{\underline{m}arkup}}\ {\mathrm{t}} | ((vat 0.06 cat y) cat ("font-size" vattr size) cat ("font-weight" vattr weight) cat (vfill color) cat "font-family" vattr "ui-monospace, monospace") vmarkup t |
| 151 | } | {\}} | } |
| 155 | l:p_ainting := { solid -> g:o_rder solid } | {{}^{\mathrm{l}}\mathrm{\underline{p}ainting}}\ {\leftarrow}\ {\{}\ {\mathrm{solid}}\ {\to}\ {{}^{\mathrm{g}}\mathrm{\underline{o}rder}}\ {\mathrm{solid}}\ {\}} | lpainting ← { solid → gorder solid } |
| 158 | h:j_oin := { b -> | {{}^{\mathrm{h}}\mathrm{\underline{j}oin}}\ {\leftarrow}\ {\{}\ {\mathrm{b}}\ {\to} | hjoin ← { b → |
| 159 | 0 = t_ally b ? "" | \ \ {0}\ {=}\ {\mathrm{\underline{t}ally}}\ {\mathrm{b}}\ {?}\ {\text{""}} | 0 = tally b ? "" |
| 160 | d_isclose '{ x y -> e_nclose (d_isclose x) c_at d_isclose y } r_/ b | \ \ {\mathrm{\underline{d}isclose}}\ {\text{'}}{\{}\ {\mathrm{x}}\ {\mathrm{y}}\ {\to}\ {\mathrm{\underline{e}nclose}}\ {(}{\mathrm{\underline{d}isclose}}\ {\mathrm{x}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{d}isclose}}\ {\mathrm{y}}\ {\}}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{b}} | disclose ’{ x y → enclose (disclose x) cat disclose y } r/ b |
| 161 | } | {\}} | } |
| 12 | "cm:" u_se< "Comparison" | {\text{"cm:"}}\ {\mathrm{\underline{u}se}{<}}\ {\text{"Comparison"}} | "cm:" use< "Comparison" |
| 13 | "st:" u_se< "Stone" | {\text{"st:"}}\ {\mathrm{\underline{u}se}{<}}\ {\text{"Stone"}} | "st:" use< "Stone" |
| 14 | "v:" u_se< "Svg" | {\text{"v:"}}\ {\mathrm{\underline{u}se}{<}}\ {\text{"Svg"}} | "v:" use< "Svg" |
| 16 | data := "data.toml" | {\mathrm{data}}\ {\leftarrow}\ {\text{"data.toml"}} | data ← "data.toml" |
| 17 | idioms := data []L_IST "idioms" | {\mathrm{idioms}}\ {\leftarrow}\ {\mathrm{data}}\ {\square \mathrm{\underline{L}IST}}\ {\text{"idioms"}} | idioms ← data □LIST "idioms" |
| 18 | idiomNames := data []L_IST "idiom_names" | {\mathrm{idiomNames}}\ {\leftarrow}\ {\mathrm{data}}\ {\square \mathrm{\underline{L}IST}}\ {\text{"idiom\_names"}} | idiomNames ← data □LIST "idiom_names" |
| 19 | languages := data []L_IST "languages" | {\mathrm{languages}}\ {\leftarrow}\ {\mathrm{data}}\ {\square \mathrm{\underline{L}IST}}\ {\text{"languages"}} | languages ← data □LIST "languages" |
| 20 | languageNames := data []L_IST "language_names" | {\mathrm{languageNames}}\ {\leftarrow}\ {\mathrm{data}}\ {\square \mathrm{\underline{L}IST}}\ {\text{"language\_names"}} | languageNames ← data □LIST "language_names" |
| 21 | u:t_able := { name -> ((e_nclose data) c_at e_nclose name) []T_ABLE "idioms" "languages" } | {{}^{\mathrm{u}}\mathrm{\underline{t}able}}\ {\leftarrow}\ {\{}\ {\mathrm{name}}\ {\to}\ {(}{(}{\mathrm{\underline{e}nclose}}\ {\mathrm{data}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{e}nclose}}\ {\mathrm{name}}{)}\ {\square \mathrm{\underline{T}ABLE}}\ {\text{"idioms"}}\ {\text{"languages"}}\ {\}} | utable ← { name → ((enclose data) cat enclose name) □TABLE "idioms" "languages" } |
| 22 | source := u:t_able "source" | {\mathrm{source}}\ {\leftarrow}\ {{}^{\mathrm{u}}\mathrm{\underline{t}able}}\ {\text{"source"}} | source ← utable "source" |
| 23 | output := u:t_able "output" | {\mathrm{output}}\ {\leftarrow}\ {{}^{\mathrm{u}}\mathrm{\underline{t}able}}\ {\text{"output"}} | output ← utable "output" |
| 24 | notes := u:t_able "notes" | {\mathrm{notes}}\ {\leftarrow}\ {{}^{\mathrm{u}}\mathrm{\underline{t}able}}\ {\text{"notes"}} | notes ← utable "notes" |
| 25 | spans := u:t_able "spans" | {\mathrm{spans}}\ {\leftarrow}\ {{}^{\mathrm{u}}\mathrm{\underline{t}able}}\ {\text{"spans"}} | spans ← utable "spans" |
| 30 | u:c_olor := { class -> | {{}^{\mathrm{u}}\mathrm{\underline{c}olor}}\ {\leftarrow}\ {\{}\ {\mathrm{class}}\ {\to} | ucolor ← { class → |
| 31 | class m_atch "builtin" ? "#1d4ed8" | \ \ {\mathrm{class}}\ {\mathrm{\underline{m}atch}}\ {\text{"builtin"}}\ {?}\ {\text{"\#1d4ed8"}} | class match "builtin" ? "#1d4ed8" |
| 32 | class m_atch "userfunc" ? "#7c3aed" | \ \ {\mathrm{class}}\ {\mathrm{\underline{m}atch}}\ {\text{"userfunc"}}\ {?}\ {\text{"\#7c3aed"}} | class match "userfunc" ? "#7c3aed" |
| 33 | class m_atch "libfunc" ? "#7c3aed" | \ \ {\mathrm{class}}\ {\mathrm{\underline{m}atch}}\ {\text{"libfunc"}}\ {?}\ {\text{"\#7c3aed"}} | class match "libfunc" ? "#7c3aed" |
| 34 | class m_atch "macro" ? "#7c3aed" | \ \ {\mathrm{class}}\ {\mathrm{\underline{m}atch}}\ {\text{"macro"}}\ {?}\ {\text{"\#7c3aed"}} | class match "macro" ? "#7c3aed" |
| 35 | class m_atch "number" ? "#b45309" | \ \ {\mathrm{class}}\ {\mathrm{\underline{m}atch}}\ {\text{"number"}}\ {?}\ {\text{"\#b45309"}} | class match "number" ? "#b45309" |
| 36 | class m_atch "string" ? "#15803d" | \ \ {\mathrm{class}}\ {\mathrm{\underline{m}atch}}\ {\text{"string"}}\ {?}\ {\text{"\#15803d"}} | class match "string" ? "#15803d" |
| 37 | class m_atch "symbol" ? "#111827" | \ \ {\mathrm{class}}\ {\mathrm{\underline{m}atch}}\ {\text{"symbol"}}\ {?}\ {\text{"\#111827"}} | class match "symbol" ? "#111827" |
| 38 | class m_atch "comment" ? "#6b7280" | \ \ {\mathrm{class}}\ {\mathrm{\underline{m}atch}}\ {\text{"comment"}}\ {?}\ {\text{"\#6b7280"}} | class match "comment" ? "#6b7280" |
| 39 | class m_atch "lambdaarg" ? "#0f766e" | \ \ {\mathrm{class}}\ {\mathrm{\underline{m}atch}}\ {\text{"lambdaarg"}}\ {?}\ {\text{"\#0f766e"}} | class match "lambdaarg" ? "#0f766e" |
| 40 | class m_atch "keyword" ? "#1d4ed8" | \ \ {\mathrm{class}}\ {\mathrm{\underline{m}atch}}\ {\text{"keyword"}}\ {?}\ {\text{"\#1d4ed8"}} | class match "keyword" ? "#1d4ed8" |
| 41 | class m_atch "function" ? "#1d4ed8" | \ \ {\mathrm{class}}\ {\mathrm{\underline{m}atch}}\ {\text{"function"}}\ {?}\ {\text{"\#1d4ed8"}} | class match "function" ? "#1d4ed8" |
| 42 | class m_atch "operator" ? "#111827" | \ \ {\mathrm{class}}\ {\mathrm{\underline{m}atch}}\ {\text{"operator"}}\ {?}\ {\text{"\#111827"}} | class match "operator" ? "#111827" |
| 43 | class m_atch "name" ? "#000000" | \ \ {\mathrm{class}}\ {\mathrm{\underline{m}atch}}\ {\text{"name"}}\ {?}\ {\text{"\#000000"}} | class match "name" ? "#000000" |
| 44 | "#000000" | \ \ {\text{"\#000000"}} | "#000000" |
| 45 | } | {\}} | } |
| 49 | u:r_uns := { m -> u:j_oin '{ k -> (u:c_olor d_isclose 2 s_elect k s_elect m) v:s_pan d_isclose 1 s_elect k s_elect m } m_ap r_ange 1 s_elect s_hape m } | {{}^{\mathrm{u}}\mathrm{\underline{r}uns}}\ {\leftarrow}\ {\{}\ {\mathrm{m}}\ {\to}\ {{}^{\mathrm{u}}\mathrm{\underline{j}oin}}\ {\text{'}}{\{}\ {\mathrm{k}}\ {\to}\ {(}{{}^{\mathrm{u}}\mathrm{\underline{c}olor}}\ {\mathrm{\underline{d}isclose}}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{k}}\ {\mathrm{\underline{s}elect}}\ {\mathrm{m}}{)}\ {{}^{\mathrm{v}}\mathrm{\underline{s}pan}}\ {\mathrm{\underline{d}isclose}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{k}}\ {\mathrm{\underline{s}elect}}\ {\mathrm{m}}\ {\}}\ {\mathrm{\underline{m}ap}}\ {\mathrm{\underline{r}ange}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{\underline{s}hape}}\ {\mathrm{m}}\ {\}} | uruns ← { m → ujoin ’{ k → (ucolor disclose 2 select k select m) vspan disclose 1 select k select m } map range 1 select shape m } |
| 57 | u:g_uess := { src -> | {{}^{\mathrm{u}}\mathrm{\underline{g}uess}}\ {\leftarrow}\ {\{}\ {\mathrm{src}}\ {\to} | uguess ← { src → |
| 58 | cls := (src m_ember? "0123456789") + (2 * src m_ember? "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_") + 3 * src = f_irst " " | \ \ {\mathrm{cls}}\ {\leftarrow}\ {(}{\mathrm{src}}\ {\mathrm{\underline{m}ember}{?}}\ {\text{"0123456789"}}{)}\ {+}\ {(}{2}\ {\times}\ {\mathrm{src}}\ {\mathrm{\underline{m}ember}{?}}\ {\text{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\_"}}{)}\ {+}\ {3}\ {\times}\ {\mathrm{src}}\ {=}\ {\mathrm{\underline{f}irst}}\ {\text{" "}} | cls ← (src member? "0123456789") + (2 × src member? "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_") + 3 × src = first " " |
| 59 | starts := 1 c_at (1 d_rop cls) != -1 d_rop cls | \ \ {\mathrm{starts}}\ {\leftarrow}\ {1}\ {\mathrm{\underline{c}at}}\ {(}{1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{cls}}{)}\ {\neq}\ {-1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{cls}} | starts ← 1 cat (1 drop cls) = −1 drop cls |
| 60 | runs := ('+ s_\ starts) p_artition src | \ \ {\mathrm{runs}}\ {\leftarrow}\ {(}{\text{'}}{+}\ {\mathrm{\underline{s}}{\backslash}}\ {\mathrm{starts}}{)}\ {\mathrm{\underline{p}artition}}\ {\mathrm{src}} | runs ← (’+ s\ starts) partition src |
| 61 | kinds := (e_nclose "builtin") c_at (e_nclose "number") c_at (e_nclose "name") c_at e_nclose "plain" | \ \ {\mathrm{kinds}}\ {\leftarrow}\ {(}{\mathrm{\underline{e}nclose}}\ {\text{"builtin"}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{e}nclose}}\ {\text{"number"}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{e}nclose}}\ {\text{"name"}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{e}nclose}}\ {\text{"plain"}} | kinds ← (enclose "builtin") cat (enclose "number") cat (enclose "name") cat enclose "plain" |
| 62 | classes := (1 + (w_here starts) s_elect cls) s_elect kinds | \ \ {\mathrm{classes}}\ {\leftarrow}\ {(}{1}\ {+}\ {(}{\mathrm{\underline{w}here}}\ {\mathrm{starts}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{cls}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{kinds}} | classes ← (1 + (where starts) select cls) select kinds |
| 63 | o_\ (2 c_at t_ally runs) r_eshape runs c_at classes | \ \ {\mathrm{\underline{o}}{\backslash}}\ {(}{2}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{t}ally}}\ {\mathrm{runs}}{)}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{runs}}\ {\mathrm{\underline{c}at}}\ {\mathrm{classes}} | o\ (2 cat tally runs) reshape runs cat classes |
| 64 | } | {\}} | } |
| 68 | u:s_pans := { src spans -> | {{}^{\mathrm{u}}\mathrm{\underline{s}pans}}\ {\leftarrow}\ {\{}\ {\mathrm{src}}\ {\mathrm{spans}}\ {\to} | uspans ← { src spans → |
| 69 | 0 = t_ally spans ? u:g_uess src | \ \ {0}\ {=}\ {\mathrm{\underline{t}ally}}\ {\mathrm{spans}}\ {?}\ {{}^{\mathrm{u}}\mathrm{\underline{g}uess}}\ {\mathrm{src}} | 0 = tally spans ? uguess src |
| 70 | pieces := (n_ot spans = f_irst "|") p_artition spans | \ \ {\mathrm{pieces}}\ {\leftarrow}\ {(}{\mathrm{\underline{n}ot}}\ {\mathrm{spans}}\ {=}\ {\mathrm{\underline{f}irst}}\ {\text{"|"}}{)}\ {\mathrm{\underline{p}artition}}\ {\mathrm{spans}} | pieces ← (not spans = first "|") partition spans |
| 71 | o_ne := { p -> t := d_isclose p; cut := t i_ndexOf f_irst " "; (e_nclose cut d_rop t) c_at e_nclose (cut - 1) t_ake t } | \ \ {\mathrm{\underline{o}ne}}\ {\leftarrow}\ {\{}\ {\mathrm{p}}\ {\to}\ {\mathrm{t}}\ {\leftarrow}\ {\mathrm{\underline{d}isclose}}\ {\mathrm{p}}{\diamond}\ {\mathrm{cut}}\ {\leftarrow}\ {\mathrm{t}}\ {\mathrm{\underline{i}ndexOf}}\ {\mathrm{\underline{f}irst}}\ {\text{" "}}{\diamond}\ {(}{\mathrm{\underline{e}nclose}}\ {\mathrm{cut}}\ {\mathrm{\underline{d}rop}}\ {\mathrm{t}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{e}nclose}}\ {(}{\mathrm{cut}}\ {-}\ {1}{)}\ {\mathrm{\underline{t}ake}}\ {\mathrm{t}}\ {\}} | one ← { p → t ← disclose p⋄ cut ← t indexOf first " "⋄ (enclose cut drop t) cat enclose (cut − 1) take t } |
| 72 | ((t_ally pieces) c_at 2) r_eshape d_isclose '{ x y -> e_nclose (d_isclose x) c_at d_isclose y } r_/ 'o_ne m_ap pieces | \ \ {(}{(}{\mathrm{\underline{t}ally}}\ {\mathrm{pieces}}{)}\ {\mathrm{\underline{c}at}}\ {2}{)}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{\underline{d}isclose}}\ {\text{'}}{\{}\ {\mathrm{x}}\ {\mathrm{y}}\ {\to}\ {\mathrm{\underline{e}nclose}}\ {(}{\mathrm{\underline{d}isclose}}\ {\mathrm{x}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{d}isclose}}\ {\mathrm{y}}\ {\}}\ {\mathrm{\underline{r}}{/}}\ {\text{'}}{\mathrm{\underline{o}ne}}\ {\mathrm{\underline{m}ap}}\ {\mathrm{pieces}} | ((tally pieces) cat 2) reshape disclose ’{ x y → enclose (disclose x) cat disclose y } r/ ’one map pieces |
| 73 | } | {\}} | } |
| 78 | u:c_olored := { il src -> | {{}^{\mathrm{u}}\mathrm{\underline{c}olored}}\ {\leftarrow}\ {\{}\ {\mathrm{il}}\ {\mathrm{src}}\ {\to} | ucolored ← { il src → |
| 79 | i := 1 s_elect il | \ \ {\mathrm{i}}\ {\leftarrow}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{il}} | i ← 1 select il |
| 80 | l := 2 s_elect il | \ \ {\mathrm{l}}\ {\leftarrow}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{il}} | l ← 2 select il |
| 81 | (d_isclose l s_elect languages) m_atch "xetal" ? u:r_uns []V_IEW src | \ \ {(}{\mathrm{\underline{d}isclose}}\ {\mathrm{l}}\ {\mathrm{\underline{s}elect}}\ {\mathrm{languages}}{)}\ {\mathrm{\underline{m}atch}}\ {\text{"xetal"}}\ {?}\ {{}^{\mathrm{u}}\mathrm{\underline{r}uns}}\ {\square \mathrm{\underline{V}IEW}}\ {\mathrm{src}} | (disclose l select languages) match "xetal" ? uruns □VIEW src |
| 82 | u:r_uns src u:s_pans d_isclose l s_elect i s_elect spans | \ \ {{}^{\mathrm{u}}\mathrm{\underline{r}uns}}\ {\mathrm{src}}\ {{}^{\mathrm{u}}\mathrm{\underline{s}pans}}\ {\mathrm{\underline{d}isclose}}\ {\mathrm{l}}\ {\mathrm{\underline{s}elect}}\ {\mathrm{i}}\ {\mathrm{\underline{s}elect}}\ {\mathrm{spans}} | uruns src uspans disclose l select i select spans |
| 83 | } | {\}} | } |
| 88 | fits := 15 | {\mathrm{fits}}\ {\leftarrow}\ {15} | fits ← 15 |
| 89 | smallest := 0.05 | {\mathrm{smallest}}\ {\leftarrow}\ {0.05} | smallest ← 0.05 |
| 93 | u:f_itted := { n markup -> | {{}^{\mathrm{u}}\mathrm{\underline{f}itted}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\mathrm{markup}}\ {\to} | ufitted ← { n markup → |
| 94 | n <= fits ? markup | \ \ {\mathrm{n}}\ {\leq}\ {\mathrm{fits}}\ {?}\ {\mathrm{markup}} | n ≤ fits ? markup |
| 95 | size := 0.1 * (f_loat fits) / f_loat n | \ \ {\mathrm{size}}\ {\leftarrow}\ {0.1}\ {\times}\ {(}{\mathrm{\underline{f}loat}}\ {\mathrm{fits}}{)}\ {\div}\ {\mathrm{\underline{f}loat}}\ {\mathrm{n}} | size ← 0.1 × (float fits) ÷ float n |
| 96 | (size m_ax smallest) v:s_ized markup | \ \ {(}{\mathrm{size}}\ {\mathrm{\underline{m}ax}}\ {\mathrm{smallest}}{)}\ {{}^{\mathrm{v}}\mathrm{\underline{s}ized}}\ {\mathrm{markup}} | (size max smallest) vsized markup |
| 97 | } | {\}} | } |
| 102 | u:s_plit := { src -> | {{}^{\mathrm{u}}\mathrm{\underline{s}plit}}\ {\leftarrow}\ {\{}\ {\mathrm{src}}\ {\to} | usplit ← { src → |
| 103 | n := t_ally src | \ \ {\mathrm{n}}\ {\leftarrow}\ {\mathrm{\underline{t}ally}}\ {\mathrm{src}} | n ← tally src |
| 104 | n <= fits ? e_nclose src | \ \ {\mathrm{n}}\ {\leq}\ {\mathrm{fits}}\ {?}\ {\mathrm{\underline{e}nclose}}\ {\mathrm{src}} | n ≤ fits ? enclose src |
| 105 | spaces := w_here src = f_irst " " | \ \ {\mathrm{spaces}}\ {\leftarrow}\ {\mathrm{\underline{w}here}}\ {\mathrm{src}}\ {=}\ {\mathrm{\underline{f}irst}}\ {\text{" "}} | spaces ← where src = first " " |
| 106 | 0 = t_ally spaces ? e_nclose src | \ \ {0}\ {=}\ {\mathrm{\underline{t}ally}}\ {\mathrm{spaces}}\ {?}\ {\mathrm{\underline{e}nclose}}\ {\mathrm{src}} | 0 = tally spaces ? enclose src |
| 107 | away := a_bs (2 * spaces) - n | \ \ {\mathrm{away}}\ {\leftarrow}\ {\mathrm{\underline{a}bs}}\ {(}{2}\ {\times}\ {\mathrm{spaces}}{)}\ {-}\ {\mathrm{n}} | away ← abs (2 × spaces) − n |
| 108 | cut := (away i_ndexOf 'm_in r_/ away) s_elect spaces | \ \ {\mathrm{cut}}\ {\leftarrow}\ {(}{\mathrm{away}}\ {\mathrm{\underline{i}ndexOf}}\ {\text{'}}{\mathrm{\underline{m}in}}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{away}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{spaces}} | cut ← (away indexOf ’min r/ away) select spaces |
| 109 | (e_nclose (cut - 1) t_ake src) c_at e_nclose cut d_rop src | \ \ {(}{\mathrm{\underline{e}nclose}}\ {(}{\mathrm{cut}}\ {-}\ {1}{)}\ {\mathrm{\underline{t}ake}}\ {\mathrm{src}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{e}nclose}}\ {\mathrm{cut}}\ {\mathrm{\underline{d}rop}}\ {\mathrm{src}} | (enclose (cut − 1) take src) cat enclose cut drop src |
| 110 | } | {\}} | } |
| 114 | u:l_ines := { width ws -> | {{}^{\mathrm{u}}\mathrm{\underline{l}ines}}\ {\leftarrow}\ {\{}\ {\mathrm{width}}\ {\mathrm{ws}}\ {\to} | ulines ← { width ws → |
| 115 | 0 = t_ally ws ? ws | \ \ {0}\ {=}\ {\mathrm{\underline{t}ally}}\ {\mathrm{ws}}\ {?}\ {\mathrm{ws}} | 0 = tally ws ? ws |
| 116 | lens := '{ b -> t_ally d_isclose b } e_ach ws | \ \ {\mathrm{lens}}\ {\leftarrow}\ {\text{'}}{\{}\ {\mathrm{b}}\ {\to}\ {\mathrm{\underline{t}ally}}\ {\mathrm{\underline{d}isclose}}\ {\mathrm{b}}\ {\}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{ws}} | lens ← ’{ b → tally disclose b } each ws |
| 117 | room := width >= (('+ s_\ lens) + r_ange t_ally ws) - 1 | \ \ {\mathrm{room}}\ {\leftarrow}\ {\mathrm{width}}\ {\geq}\ {(}{(}{\text{'}}{+}\ {\mathrm{\underline{s}}{\backslash}}\ {\mathrm{lens}}{)}\ {+}\ {\mathrm{\underline{r}ange}}\ {\mathrm{\underline{t}ally}}\ {\mathrm{ws}}{)}\ {-}\ {1} | room ← width ≥ ((’+ s\ lens) + range tally ws) − 1 |
| 118 | k := 1 m_ax '+ r_/ room | \ \ {\mathrm{k}}\ {\leftarrow}\ {1}\ {\mathrm{\underline{m}ax}}\ {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{room}} | k ← 1 max ’+ r/ room |
| 119 | line := d_isclose '{ x y -> e_nclose (d_isclose x) c_at " " c_at d_isclose y } r_/ k t_ake ws | \ \ {\mathrm{line}}\ {\leftarrow}\ {\mathrm{\underline{d}isclose}}\ {\text{'}}{\{}\ {\mathrm{x}}\ {\mathrm{y}}\ {\to}\ {\mathrm{\underline{e}nclose}}\ {(}{\mathrm{\underline{d}isclose}}\ {\mathrm{x}}{)}\ {\mathrm{\underline{c}at}}\ {\text{" "}}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{d}isclose}}\ {\mathrm{y}}\ {\}}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{k}}\ {\mathrm{\underline{t}ake}}\ {\mathrm{ws}} | line ← disclose ’{ x y → enclose (disclose x) cat " " cat disclose y } r/ k take ws |
| 120 | (e_nclose line) c_at width u:l_ines k d_rop ws | \ \ {(}{\mathrm{\underline{e}nclose}}\ {\mathrm{line}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{width}}\ {{}^{\mathrm{u}}\mathrm{\underline{l}ines}}\ {\mathrm{k}}\ {\mathrm{\underline{d}rop}}\ {\mathrm{ws}} | (enclose line) cat width ulines k drop ws |
| 121 | } | {\}} | } |
| 124 | u:w_rap := { width t -> width u:l_ines (n_ot t = f_irst " ") p_artition t } | {{}^{\mathrm{u}}\mathrm{\underline{w}rap}}\ {\leftarrow}\ {\{}\ {\mathrm{width}}\ {\mathrm{t}}\ {\to}\ {\mathrm{width}}\ {{}^{\mathrm{u}}\mathrm{\underline{l}ines}}\ {(}{\mathrm{\underline{n}ot}}\ {\mathrm{t}}\ {=}\ {\mathrm{\underline{f}irst}}\ {\text{" "}}{)}\ {\mathrm{\underline{p}artition}}\ {\mathrm{t}}\ {\}} | uwrap ← { width t → width ulines (not t = first " ") partition t } |
| 128 | u:o_neLine := { out -> d_isclose '{ x y -> e_nclose (d_isclose x) c_at " / " c_at d_isclose y } r_/ (n_ot out = f_irst "\n") p_artition out } | {{}^{\mathrm{u}}\mathrm{\underline{o}neLine}}\ {\leftarrow}\ {\{}\ {\mathrm{out}}\ {\to}\ {\mathrm{\underline{d}isclose}}\ {\text{'}}{\{}\ {\mathrm{x}}\ {\mathrm{y}}\ {\to}\ {\mathrm{\underline{e}nclose}}\ {(}{\mathrm{\underline{d}isclose}}\ {\mathrm{x}}{)}\ {\mathrm{\underline{c}at}}\ {\text{" / "}}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{d}isclose}}\ {\mathrm{y}}\ {\}}\ {\mathrm{\underline{r}}{/}}\ {(}{\mathrm{\underline{n}ot}}\ {\mathrm{out}}\ {=}\ {\mathrm{\underline{f}irst}}\ {\text{"\textbackslash{}n"}}{)}\ {\mathrm{\underline{p}artition}}\ {\mathrm{out}}\ {\}} | uoneLine ← { out → disclose ’{ x y → enclose (disclose x) cat " / " cat disclose y } r/ (not out = first "\n") partition out } |
| 134 | u:f_ace := { i l -> | {{}^{\mathrm{u}}\mathrm{\underline{f}ace}}\ {\leftarrow}\ {\{}\ {\mathrm{i}}\ {\mathrm{l}}\ {\to} | uface ← { i l → |
| 135 | name := v:e_scape d_isclose l s_elect languageNames | \ \ {\mathrm{name}}\ {\leftarrow}\ {{}^{\mathrm{v}}\mathrm{\underline{e}scape}}\ {\mathrm{\underline{d}isclose}}\ {\mathrm{l}}\ {\mathrm{\underline{s}elect}}\ {\mathrm{languageNames}} | name ← vescape disclose l select languageNames |
| 136 | src := d_isclose l s_elect i s_elect source | \ \ {\mathrm{src}}\ {\leftarrow}\ {\mathrm{\underline{d}isclose}}\ {\mathrm{l}}\ {\mathrm{\underline{s}elect}}\ {\mathrm{i}}\ {\mathrm{\underline{s}elect}}\ {\mathrm{source}} | src ← disclose l select i select source |
| 137 | out := d_isclose l s_elect i s_elect output | \ \ {\mathrm{out}}\ {\leftarrow}\ {\mathrm{\underline{d}isclose}}\ {\mathrm{l}}\ {\mathrm{\underline{s}elect}}\ {\mathrm{i}}\ {\mathrm{\underline{s}elect}}\ {\mathrm{output}} | out ← disclose l select i select output |
| 138 | note := d_isclose l s_elect i s_elect notes | \ \ {\mathrm{note}}\ {\leftarrow}\ {\mathrm{\underline{d}isclose}}\ {\mathrm{l}}\ {\mathrm{\underline{s}elect}}\ {\mathrm{i}}\ {\mathrm{\underline{s}elect}}\ {\mathrm{notes}} | note ← disclose l select i select notes |
| 139 | missing := c"0 = t_ally note" i_f< c"\"(no concise idiom)\"; note" | \ \ {\mathrm{missing}}\ {\leftarrow}\ {\text{c"}}{0}\ {=}\ {\mathrm{\underline{t}ally}}\ {\mathrm{note}}{\text{"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{c"}}{\text{\textbackslash{}"(no concise idiom)\textbackslash{}"}}{\diamond}\ {\mathrm{note}}{\text{"}} | missing ← c"0 = tally note" if< c"\"(no concise idiom)\"⋄ note" |
| 140 | result := c"0 = t_ally out" i_f< c"\"\"; \"-> \" c_at u:o_neLine out" | \ \ {\mathrm{result}}\ {\leftarrow}\ {\text{c"}}{0}\ {=}\ {\mathrm{\underline{t}ally}}\ {\mathrm{out}}{\text{"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{c"}}{\text{\textbackslash{}"\textbackslash{}"}}{\diamond}\ {\text{\textbackslash{}"-> \textbackslash{}"}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{u}}\mathrm{\underline{o}neLine}}\ {\mathrm{out}}{\text{"}} | result ← c"0 = tally out" if< c"\"\"⋄ \"-> \" cat uoneLine out" |
| 141 | n_oteLine := { b -> 0.07 v:s_ized "#4b5563" v:s_pan d_isclose b } | \ \ {\mathrm{\underline{n}oteLine}}\ {\leftarrow}\ {\{}\ {\mathrm{b}}\ {\to}\ {0.07}\ {{}^{\mathrm{v}}\mathrm{\underline{s}ized}}\ {\text{"\#4b5563"}}\ {{}^{\mathrm{v}}\mathrm{\underline{s}pan}}\ {\mathrm{\underline{d}isclose}}\ {\mathrm{b}}\ {\}} | noteLine ← { b → 0.07 vsized "#4b5563" vspan disclose b } |
| 142 | 0 = t_ally src ? (e_nclose name) c_at 'n_oteLine m_ap 18 u:w_rap missing | \ \ {0}\ {=}\ {\mathrm{\underline{t}ally}}\ {\mathrm{src}}\ {?}\ {(}{\mathrm{\underline{e}nclose}}\ {\mathrm{name}}{)}\ {\mathrm{\underline{c}at}}\ {\text{'}}{\mathrm{\underline{n}oteLine}}\ {\mathrm{\underline{m}ap}}\ {18}\ {{}^{\mathrm{u}}\mathrm{\underline{w}rap}}\ {\mathrm{missing}} | 0 = tally src ? (enclose name) cat ’noteLine map 18 uwrap missing |
| 143 | c_odeLine := { b -> (t_ally d_isclose b) u:f_itted (i c_at l) u:c_olored d_isclose b } | \ \ {\mathrm{\underline{c}odeLine}}\ {\leftarrow}\ {\{}\ {\mathrm{b}}\ {\to}\ {(}{\mathrm{\underline{t}ally}}\ {\mathrm{\underline{d}isclose}}\ {\mathrm{b}}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{f}itted}}\ {(}{\mathrm{i}}\ {\mathrm{\underline{c}at}}\ {\mathrm{l}}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{c}olored}}\ {\mathrm{\underline{d}isclose}}\ {\mathrm{b}}\ {\}} | codeLine ← { b → (tally disclose b) ufitted (i cat l) ucolored disclose b } |
| 144 | code := 'c_odeLine m_ap u:s_plit src | \ \ {\mathrm{code}}\ {\leftarrow}\ {\text{'}}{\mathrm{\underline{c}odeLine}}\ {\mathrm{\underline{m}ap}}\ {{}^{\mathrm{u}}\mathrm{\underline{s}plit}}\ {\mathrm{src}} | code ← ’codeLine map usplit src |
| 145 | (e_nclose name) c_at code c_at e_nclose (t_ally result) u:f_itted "#4b5563" v:s_pan result | \ \ {(}{\mathrm{\underline{e}nclose}}\ {\mathrm{name}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{code}}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{e}nclose}}\ {(}{\mathrm{\underline{t}ally}}\ {\mathrm{result}}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{f}itted}}\ {\text{"\#4b5563"}}\ {{}^{\mathrm{v}}\mathrm{\underline{s}pan}}\ {\mathrm{result}} | (enclose name) cat code cat enclose (tally result) ufitted "#4b5563" vspan result |
| 146 | } | {\}} | } |
| 150 | u:i_tem := { (axis, offset) state -> (axis cm:c_ount state) cm:w_rap 1 + offset + st:b_ase axis cm:a_ngle state } | {{}^{\mathrm{u}}\mathrm{\underline{i}tem}}\ {\leftarrow}\ {\{}\ {(}{\mathrm{axis}}{,}\ {\mathrm{offset}}{)}\ {\mathrm{state}}\ {\to}\ {(}{\mathrm{axis}}\ {{}^{\mathrm{cm}}\mathrm{\underline{c}ount}}\ {\mathrm{state}}{)}\ {{}^{\mathrm{cm}}\mathrm{\underline{w}rap}}\ {1}\ {+}\ {\mathrm{offset}}\ {+}\ {{}^{\mathrm{st}}\mathrm{\underline{b}ase}}\ {\mathrm{axis}}\ {{}^{\mathrm{cm}}\mathrm{\underline{a}ngle}}\ {\mathrm{state}}\ {\}} | uitem ← { (axis, offset) state → (axis cmcount state) cmwrap 1 + offset + stbase axis cmangle state } |
| 158 | u:s_tone := { state -> | {{}^{\mathrm{u}}\mathrm{\underline{s}tone}}\ {\leftarrow}\ {\{}\ {\mathrm{state}}\ {\to} | ustone ← { state → |
| 159 | i := (cm:IDIOM, 0) u:i_tem state | \ \ {\mathrm{i}}\ {\leftarrow}\ {(}{{}^{\mathrm{cm}}\mathrm{IDIOM}}{,}\ {0}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{i}tem}}\ {\mathrm{state}} | i ← (cmIDIOM, 0) uitem state |
| 160 | roll := cm:IDIOM cm:a_ngle state | \ \ {\mathrm{roll}}\ {\leftarrow}\ {{}^{\mathrm{cm}}\mathrm{IDIOM}}\ {{}^{\mathrm{cm}}\mathrm{\underline{a}ngle}}\ {\mathrm{state}} | roll ← cmIDIOM cmangle state |
| 161 | top := 1 st:r_ing (cm:TOP cm:a_ngle state) c_at roll | \ \ {\mathrm{top}}\ {\leftarrow}\ {1}\ {{}^{\mathrm{st}}\mathrm{\underline{r}ing}}\ {(}{{}^{\mathrm{cm}}\mathrm{TOP}}\ {{}^{\mathrm{cm}}\mathrm{\underline{a}ngle}}\ {\mathrm{state}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{roll}} | top ← 1 string (cmTOP cmangle state) cat roll |
| 162 | bottom := -1 st:r_ing (cm:BOTTOM cm:a_ngle state) c_at roll | \ \ {\mathrm{bottom}}\ {\leftarrow}\ {-1}\ {{}^{\mathrm{st}}\mathrm{\underline{r}ing}}\ {(}{{}^{\mathrm{cm}}\mathrm{BOTTOM}}\ {{}^{\mathrm{cm}}\mathrm{\underline{a}ngle}}\ {\mathrm{state}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{roll}} | bottom ← −1 string (cmBOTTOM cmangle state) cat roll |
| 163 | all := top c_at bottom | \ \ {\mathrm{all}}\ {\leftarrow}\ {\mathrm{top}}\ {\mathrm{\underline{c}at}}\ {\mathrm{bottom}} | all ← top cat bottom |
| 164 | c_apName := { k -> v:e_scape d_isclose ((cm:IDIOM, k s_elect st:capOffsets) u:i_tem state) s_elect idiomNames } | \ \ {\mathrm{\underline{c}apName}}\ {\leftarrow}\ {\{}\ {\mathrm{k}}\ {\to}\ {{}^{\mathrm{v}}\mathrm{\underline{e}scape}}\ {\mathrm{\underline{d}isclose}}\ {(}{(}{{}^{\mathrm{cm}}\mathrm{IDIOM}}{,}\ {\mathrm{k}}\ {\mathrm{\underline{s}elect}}\ {{}^{\mathrm{st}}\mathrm{capOffsets}}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{i}tem}}\ {\mathrm{state}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{idiomNames}}\ {\}} | capName ← { k → vescape disclose ((cmIDIOM, k select stcapOffsets) uitem state) select idiomNames } |
| 165 | c_apText := { k -> | \ \ {\mathrm{\underline{c}apText}}\ {\leftarrow}\ {\{}\ {\mathrm{k}}\ {\to} | capText ← { k → |
| 166 | k = 5 ? c_apName 1 | \ \ \ \ {\mathrm{k}}\ {=}\ {5}\ {?}\ {\mathrm{\underline{c}apName}}\ {1} | k = 5 ? capName 1 |
| 167 | k = 12 ? c_apName 2 | \ \ \ \ {\mathrm{k}}\ {=}\ {12}\ {?}\ {\mathrm{\underline{c}apName}}\ {2} | k = 12 ? capName 2 |
| 168 | "" | \ \ \ \ {\text{""}} | "" |
| 169 | } | \ \ {\}} | } |
| 170 | c_ap := { k -> (e_nclose "#e9e4db") c_at (e_nclose "") c_at e_nclose c_apText k } | \ \ {\mathrm{\underline{c}ap}}\ {\leftarrow}\ {\{}\ {\mathrm{k}}\ {\to}\ {(}{\mathrm{\underline{e}nclose}}\ {\text{"\#e9e4db"}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{e}nclose}}\ {\text{""}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{e}nclose}}\ {\mathrm{\underline{c}apText}}\ {\mathrm{k}}\ {\}} | cap ← { k → (enclose "#e9e4db") cat (enclose "") cat enclose capText k } |
| 171 | t_opPanel := { k -> (e_nclose "#fdfcfa") c_at i u:f_ace (cm:TOP, k s_elect st:ringOffsets) u:i_tem state } | \ \ {\mathrm{\underline{t}opPanel}}\ {\leftarrow}\ {\{}\ {\mathrm{k}}\ {\to}\ {(}{\mathrm{\underline{e}nclose}}\ {\text{"\#fdfcfa"}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{i}}\ {{}^{\mathrm{u}}\mathrm{\underline{f}ace}}\ {(}{{}^{\mathrm{cm}}\mathrm{TOP}}{,}\ {\mathrm{k}}\ {\mathrm{\underline{s}elect}}\ {{}^{\mathrm{st}}\mathrm{ringOffsets}}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{i}tem}}\ {\mathrm{state}}\ {\}} | topPanel ← { k → (enclose "#fdfcfa") cat i uface (cmTOP, k select stringOffsets) uitem state } |
| 172 | b_ottomPanel := { k -> (e_nclose "#f4f1ec") c_at i u:f_ace (cm:BOTTOM, k s_elect st:ringOffsets) u:i_tem state } | \ \ {\mathrm{\underline{b}ottomPanel}}\ {\leftarrow}\ {\{}\ {\mathrm{k}}\ {\to}\ {(}{\mathrm{\underline{e}nclose}}\ {\text{"\#f4f1ec"}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{i}}\ {{}^{\mathrm{u}}\mathrm{\underline{f}ace}}\ {(}{{}^{\mathrm{cm}}\mathrm{BOTTOM}}{,}\ {\mathrm{k}}\ {\mathrm{\underline{s}elect}}\ {{}^{\mathrm{st}}\mathrm{ringOffsets}}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{i}tem}}\ {\mathrm{state}}\ {\}} | bottomPanel ← { k → (enclose "#f4f1ec") cat i uface (cmBOTTOM, k select stringOffsets) uitem state } |
| 173 | l_ines := { k -> | \ \ {\mathrm{\underline{l}ines}}\ {\leftarrow}\ {\{}\ {\mathrm{k}}\ {\to} | lines ← { k → |
| 174 | k <= 4 ? t_opPanel k | \ \ \ \ {\mathrm{k}}\ {\leq}\ {4}\ {?}\ {\mathrm{\underline{t}opPanel}}\ {\mathrm{k}} | k ≤ 4 ? topPanel k |
| 175 | k <= 6 ? c_ap k | \ \ \ \ {\mathrm{k}}\ {\leq}\ {6}\ {?}\ {\mathrm{\underline{c}ap}}\ {\mathrm{k}} | k ≤ 6 ? cap k |
| 176 | k <= 10 ? b_ottomPanel k - 6 | \ \ \ \ {\mathrm{k}}\ {\leq}\ {10}\ {?}\ {\mathrm{\underline{b}ottomPanel}}\ {\mathrm{k}}\ {-}\ {6} | k ≤ 10 ? bottomPanel k − 6 |
| 177 | c_ap k | \ \ \ \ {\mathrm{\underline{c}ap}}\ {\mathrm{k}} | cap k |
| 178 | } | \ \ {\}} | } |
| 179 | p_anel := { k -> (l_ines k) st:p_anel k s_elect all } | \ \ {\mathrm{\underline{p}anel}}\ {\leftarrow}\ {\{}\ {\mathrm{k}}\ {\to}\ {(}{\mathrm{\underline{l}ines}}\ {\mathrm{k}}{)}\ {{}^{\mathrm{st}}\mathrm{\underline{p}anel}}\ {\mathrm{k}}\ {\mathrm{\underline{s}elect}}\ {\mathrm{all}}\ {\}} | panel ← { k → (lines k) stpanel k select all } |
| 180 | painted := u:j_oin 'p_anel m_ap st:p_ainting all | \ \ {\mathrm{painted}}\ {\leftarrow}\ {{}^{\mathrm{u}}\mathrm{\underline{j}oin}}\ {\text{'}}{\mathrm{\underline{p}anel}}\ {\mathrm{\underline{m}ap}}\ {{}^{\mathrm{st}}\mathrm{\underline{p}ainting}}\ {\mathrm{all}} | painted ← ujoin ’panel map stpainting all |
| 181 | caption := ((v:a_t (st:size / 2) c_at 28) c_at ("font-size" v:a_ttr "18") c_at ("text-anchor" v:a_ttr "middle") c_at (v:f_ill "#374151") c_at "font-family" v:a_ttr "ui-sans-serif, system-ui, sans-serif") v:t_ext d_isclose i s_elect idiomNames | \ \ {\mathrm{caption}}\ {\leftarrow}\ {(}{(}{{}^{\mathrm{v}}\mathrm{\underline{a}t}}\ {(}{{}^{\mathrm{st}}\mathrm{size}}\ {\div}\ {2}{)}\ {\mathrm{\underline{c}at}}\ {28}{)}\ {\mathrm{\underline{c}at}}\ {(}{\text{"font-size"}}\ {{}^{\mathrm{v}}\mathrm{\underline{a}ttr}}\ {\text{"18"}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\text{"text-anchor"}}\ {{}^{\mathrm{v}}\mathrm{\underline{a}ttr}}\ {\text{"middle"}}{)}\ {\mathrm{\underline{c}at}}\ {(}{{}^{\mathrm{v}}\mathrm{\underline{f}ill}}\ {\text{"\#374151"}}{)}\ {\mathrm{\underline{c}at}}\ {\text{"font-family"}}\ {{}^{\mathrm{v}}\mathrm{\underline{a}ttr}}\ {\text{"ui-sans-serif, system-ui, sans-serif"}}{)}\ {{}^{\mathrm{v}}\mathrm{\underline{t}ext}}\ {\mathrm{\underline{d}isclose}}\ {\mathrm{i}}\ {\mathrm{\underline{s}elect}}\ {\mathrm{idiomNames}} | caption ← ((vat (stsize ÷ 2) cat 28) cat ("font-size" vattr "18") cat ("text-anchor" vattr "middle") cat (vfill "#374151") cat "font-family" vattr "ui-sans-serif, system-ui, sans-serif") vtext disclose i select idiomNames |
| 182 | (st:size c_at st:size) v:p_icture caption c_at painted | \ \ {(}{{}^{\mathrm{st}}\mathrm{size}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{st}}\mathrm{size}}{)}\ {{}^{\mathrm{v}}\mathrm{\underline{p}icture}}\ {\mathrm{caption}}\ {\mathrm{\underline{c}at}}\ {\mathrm{painted}} | (stsize cat stsize) vpicture caption cat painted |
| 183 | } | {\}} | } |
| 185 | u:j_oin := { b -> d_isclose '{ x y -> e_nclose (d_isclose x) c_at d_isclose y } r_/ b } | {{}^{\mathrm{u}}\mathrm{\underline{j}oin}}\ {\leftarrow}\ {\{}\ {\mathrm{b}}\ {\to}\ {\mathrm{\underline{d}isclose}}\ {\text{'}}{\{}\ {\mathrm{x}}\ {\mathrm{y}}\ {\to}\ {\mathrm{\underline{e}nclose}}\ {(}{\mathrm{\underline{d}isclose}}\ {\mathrm{x}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{d}isclose}}\ {\mathrm{y}}\ {\}}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{b}}\ {\}} | ujoin ← { b → disclose ’{ x y → enclose (disclose x) cat disclose y } r/ b } |
| 192 | u:w_here := { s -> | {{}^{\mathrm{u}}\mathrm{\underline{w}here}}\ {\leftarrow}\ {\{}\ {\mathrm{s}}\ {\to} | uwhere ← { s → |
| 193 | i := d_isclose ((cm:IDIOM, 0) u:i_tem s) s_elect idioms | \ \ {\mathrm{i}}\ {\leftarrow}\ {\mathrm{\underline{d}isclose}}\ {(}{(}{{}^{\mathrm{cm}}\mathrm{IDIOM}}{,}\ {0}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{i}tem}}\ {\mathrm{s}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{idioms}} | i ← disclose ((cmIDIOM, 0) uitem s) select idioms |
| 194 | t := d_isclose ((cm:TOP, 0) u:i_tem s) s_elect languages | \ \ {\mathrm{t}}\ {\leftarrow}\ {\mathrm{\underline{d}isclose}}\ {(}{(}{{}^{\mathrm{cm}}\mathrm{TOP}}{,}\ {0}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{i}tem}}\ {\mathrm{s}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{languages}} | t ← disclose ((cmTOP, 0) uitem s) select languages |
| 195 | b := d_isclose ((cm:BOTTOM, 0) u:i_tem s) s_elect languages | \ \ {\mathrm{b}}\ {\leftarrow}\ {\mathrm{\underline{d}isclose}}\ {(}{(}{{}^{\mathrm{cm}}\mathrm{BOTTOM}}{,}\ {0}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{i}tem}}\ {\mathrm{s}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{languages}} | b ← disclose ((cmBOTTOM, 0) uitem s) select languages |
| 196 | "at " c_at i c_at " " c_at t c_at " " c_at b | \ \ {\text{"at "}}\ {\mathrm{\underline{c}at}}\ {\mathrm{i}}\ {\mathrm{\underline{c}at}}\ {\text{" "}}\ {\mathrm{\underline{c}at}}\ {\mathrm{t}}\ {\mathrm{\underline{c}at}}\ {\text{" "}}\ {\mathrm{\underline{c}at}}\ {\mathrm{b}} | "at " cat i cat " " cat t cat " " cat b |
| 197 | } | {\}} | } |
| 203 | u:l_oop! := { state -> | {{}^{\mathrm{u}}\mathrm{\underline{l}oop}{!}}\ {\leftarrow}\ {\{}\ {\mathrm{state}}\ {\to} | uloop! ← { state → |
| 204 | e := []E_VENT @ | \ \ {\mathrm{e}}\ {\leftarrow}\ {\square \mathrm{\underline{E}VENT}}\ {@} | e ← □EVENT @ |
| 205 | kind := []E_KIND e | \ \ {\mathrm{kind}}\ {\leftarrow}\ {\square \mathrm{\underline{E}KIND}}\ {\mathrm{e}} | kind ← □EKIND e |
| 206 | kind m_atch "end" ? state | \ \ {\mathrm{kind}}\ {\mathrm{\underline{m}atch}}\ {\text{"end"}}\ {?}\ {\mathrm{state}} | kind match "end" ? state |
| 207 | next := state cm:u_pdate e | \ \ {\mathrm{next}}\ {\leftarrow}\ {\mathrm{state}}\ {{}^{\mathrm{cm}}\mathrm{\underline{u}pdate}}\ {\mathrm{e}} | next ← state cmupdate e |
| 208 | c"(u:w_here state) m_atch u:w_here next" u_nless< c"p_rint! u:w_here next" | \ \ {\text{c"}}{(}{{}^{\mathrm{u}}\mathrm{\underline{w}here}}\ {\mathrm{state}}{)}\ {\mathrm{\underline{m}atch}}\ {{}^{\mathrm{u}}\mathrm{\underline{w}here}}\ {\mathrm{next}}{\text{"}}\ {\mathrm{\underline{u}nless}{<}}\ {\text{c"}}{\mathrm{\underline{p}rint}{!}}\ {{}^{\mathrm{u}}\mathrm{\underline{w}here}}\ {\mathrm{next}}{\text{"}} | c"(uwhere state) match uwhere next" unless< c"print! uwhere next" |
| 209 | c"(cm:m_ode state) m_atch cm:m_ode next" u_nless< c"p_rint! \"mode \" c_at cm:m_ode next" | \ \ {\text{c"}}{(}{{}^{\mathrm{cm}}\mathrm{\underline{m}ode}}\ {\mathrm{state}}{)}\ {\mathrm{\underline{m}atch}}\ {{}^{\mathrm{cm}}\mathrm{\underline{m}ode}}\ {\mathrm{next}}{\text{"}}\ {\mathrm{\underline{u}nless}{<}}\ {\text{c"}}{\mathrm{\underline{p}rint}{!}}\ {\text{\textbackslash{}"mode \textbackslash{}"}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{cm}}\mathrm{\underline{m}ode}}\ {\mathrm{next}}{\text{"}} | c"(cmmode state) match cmmode next" unless< c"print! \"mode \" cat cmmode next" |
| 210 | c"n_ot kind m_atch \"tick\"" u_nless< c"[]S_HOW u:s_tone next" | \ \ {\text{c"}}{\mathrm{\underline{n}ot}}\ {\mathrm{kind}}\ {\mathrm{\underline{m}atch}}\ {\text{\textbackslash{}"tick\textbackslash{}"}}{\text{"}}\ {\mathrm{\underline{u}nless}{<}}\ {\text{c"}}{\square \mathrm{\underline{S}HOW}}\ {{}^{\mathrm{u}}\mathrm{\underline{s}tone}}\ {\mathrm{next}}{\text{"}} | c"not kind match \"tick\"" unless< c"□SHOW ustone next" |
| 211 | u:l_oop! next | \ \ {{}^{\mathrm{u}}\mathrm{\underline{l}oop}{!}}\ {\mathrm{next}} | uloop! next |
| 212 | } | {\}} | } |
| 217 | start := cm:r_esume cm:s_ettle (cm:BOTTOM, 2) cm:c_hoose (t_ally idioms) cm:s_tart t_ally languages | {\mathrm{start}}\ {\leftarrow}\ {{}^{\mathrm{cm}}\mathrm{\underline{r}esume}}\ {{}^{\mathrm{cm}}\mathrm{\underline{s}ettle}}\ {(}{{}^{\mathrm{cm}}\mathrm{BOTTOM}}{,}\ {2}{)}\ {{}^{\mathrm{cm}}\mathrm{\underline{c}hoose}}\ {(}{\mathrm{\underline{t}ally}}\ {\mathrm{idioms}}{)}\ {{}^{\mathrm{cm}}\mathrm{\underline{s}tart}}\ {\mathrm{\underline{t}ally}}\ {\mathrm{languages}} | start ← cmresume cmsettle (cmBOTTOM, 2) cmchoose (tally idioms) cmstart tally languages |
| 218 | shown := p_rint! u:w_here start | {\mathrm{shown}}\ {\leftarrow}\ {\mathrm{\underline{p}rint}{!}}\ {{}^{\mathrm{u}}\mathrm{\underline{w}here}}\ {\mathrm{start}} | shown ← print! uwhere start |
| 219 | mode := p_rint! "mode " c_at cm:m_ode start | {\mathrm{mode}}\ {\leftarrow}\ {\mathrm{\underline{p}rint}{!}}\ {\text{"mode "}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{cm}}\mathrm{\underline{m}ode}}\ {\mathrm{start}} | mode ← print! "mode " cat cmmode start |
| 220 | u:l_oop! start | {{}^{\mathrm{u}}\mathrm{\underline{l}oop}{!}}\ {\mathrm{start}} | uloop! start |
| 17 | 42 # an Int | {42} | 42 |
| 18 | -3 2.5 # a negative literal; a strand has one type (Float) | {-3}\ {2.5} | −3 2.5 |
| 20 | x := 3 # `:=` binds; `=` is always equality | {\mathrm{x}}\ {\leftarrow}\ {3} | x ← 3 |
| 21 | x^2 # a literal exponent touches its value: superscript | {\mathrm{x}}^{2} | x2 |
| 22 | 4^-1 # a negative exponent gives a Float (a literal base) | {4}^{-1} | 4−1 |
| 23 | 2 ^ 10 # spaced `^` is the power function (computed exponents) | {2}\ {\mathbin{\hat{}}}\ {10} | 2 ^ 10 |
| 24 | 7 / 2 # `/` always gives a Float | {7}\ {\div}\ {2} | 7 ÷ 2 |
| 25 | 7 d_iv 2; 7 m_od 3 # integer quotient and remainder; `;` separates statements | {7}\ {\mathrm{\underline{d}iv}}\ {2}{\diamond}\ {7}\ {\mathrm{\underline{m}od}}\ {3} | 7 div 2⋄ 7 mod 3 |
| 26 | (0.1 + 0.2) = 0.3 # `=` is exact: 0 (false) | {(}{0.1}\ {+}\ {0.2}{)}\ {=}\ {0.3} | (0.1 + 0.2) = 0.3 |
| 27 | (0.1 + 0.2) e_q~ 0.3 # tolerant equality: 1 | {(}{0.1}\ {+}\ {0.2}{)}\ {\mathrm{\underline{e}q}{\sim}}\ {0.3} | (0.1 + 0.2) eq∼ 0.3 |
| 28 | (3 < 4) & 2 != 2 # Bool (`& | !=`); no precedence: parenthesize the left | {(}{3}\ {<}\ {4}{)}\ {\wedge}\ {2}\ {\neq}\ {2} | (3 < 4) ∧ 2 = 2 |
| 29 | f_loat 3 # Int to Float | {\mathrm{\underline{f}loat}}\ {3} | float 3 |
| 30 | s_in (p_i @) / 2 # trigonometry in radians; `p_i @` is pi (niladic) | {\mathrm{\underline{s}in}}\ {(}{\mathrm{\underline{p}i}}\ {@}{)}\ {\div}\ {2} | sin (pi @) ÷ 2 |
| 31 | a_tan 1 # and c_os | {\mathrm{\underline{a}tan}}\ {1} | atan 1 |
| 35 | count! := 0 # only names ending in ! (like `count!`) may be reassigned | {\mathrm{count}!}\ {\leftarrow}\ {0} | count! ← 0 |
| 36 | count! := count! + 1 | {\mathrm{count}!}\ {\leftarrow}\ {\mathrm{count}!}\ {+}\ {1} | count! ← count! + 1 |
| 37 | count! | {\mathrm{count}!} | count! |
| 40 | "hello" | {\text{"hello"}} | "hello" |
| 41 | "abc" = "abd" # item by item | {\text{"abc"}}\ {=}\ {\text{"abd"}} | "abc" = "abd" |
| 42 | 3 t_ake "hello" | {3}\ {\mathrm{\underline{t}ake}}\ {\text{"hello"}} | 3 take "hello" |
| 43 | "hello X̲ᵉTᵃL" # strings and comments may hold any Unicode (code may not) | {\text{"hello \underline{X}ᵉTᵃL"}} | "hello XᵉTᵃL" |
| 47 | m := 2 3 r_eshape r_ange 6 # 1-origin: `r_ange 6` is 1 2 3 4 5 6 | {\mathrm{m}}\ {\leftarrow}\ {2}\ {3}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{\underline{r}ange}}\ {6} | m ← 2 3 reshape range 6 |
| 48 | m | {\mathrm{m}} | m |
| 49 | s_hape m; t_ally m | {\mathrm{\underline{s}hape}}\ {\mathrm{m}}{\diamond}\ {\mathrm{\underline{t}ally}}\ {\mathrm{m}} | shape m⋄ tally m |
| 50 | m * 10 # a scalar extends to every item | {\mathrm{m}}\ {\times}\ {10} | m × 10 |
| 51 | 2 s_elect m # the 2nd major cell (row) | {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{m}} | 2 select m |
| 52 | -1 t_ake m; 1 d_rop m # take and drop count from the end when negative | {-1}\ {\mathrm{\underline{t}ake}}\ {\mathrm{m}}{\diamond}\ {1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{m}} | −1 take m⋄ 1 drop m |
| 53 | (f_irst m) c_at 7 8 9 # join along the leading axis | {(}{\mathrm{\underline{f}irst}}\ {\mathrm{m}}{)}\ {\mathrm{\underline{c}at}}\ {7}\ {8}\ {9} | (first m) cat 7 8 9 |
| 54 | m c_at_2 0 9 # ... or along axis 2: a column on the right | {\mathrm{m}}\ {{\mathrm{\underline{c}at}}_{2}}\ {0}\ {9} | m cat2 0 9 |
| 55 | 1 0 2 r_eplicate 7 8 9 # replicate: each item, as many times as its count | {1}\ {0}\ {2}\ {\mathrm{\underline{r}eplicate}}\ {7}\ {8}\ {9} | 1 0 2 replicate 7 8 9 |
| 56 | 10 10 10 e_ncode 123 # encode: the digits, in the radices on the left | {10}\ {10}\ {10}\ {\mathrm{\underline{e}ncode}}\ {123} | 10 10 10 encode 123 |
| 57 | 24 60 60 d_ecode 1 2 5 # decode: 1 hour 2 minutes 5 seconds, in seconds | {24}\ {60}\ {60}\ {\mathrm{\underline{d}ecode}}\ {1}\ {2}\ {5} | 24 60 60 decode 1 2 5 |
| 58 | r_avel m | {\mathrm{\underline{r}avel}}\ {\mathrm{m}} | ravel m |
| 59 | 10 ^ r_ev o_ffsets 3 # `o_ffsets` counts from 0: place values 100 10 1 | {10}\ {\mathbin{\hat{}}}\ {\mathrm{\underline{r}ev}}\ {\mathrm{\underline{o}ffsets}}\ {3} | 10 ^ rev offsets 3 |
| 63 | u:s_quare := { _r * _r } # `_r` is the right argument | {{}^{\mathrm{u}}\mathrm{\underline{s}quare}}\ {\leftarrow}\ {\{}\ {\_\mathrm{r}}\ {\times}\ {\_\mathrm{r}}\ {\}} | usquare ← { _r × _r } |
| 64 | u:s_quare 1 2 3 # scalar functions work on arrays unchanged | {{}^{\mathrm{u}}\mathrm{\underline{s}quare}}\ {1}\ {2}\ {3} | usquare 1 2 3 |
| 66 | u:s_ub := { _l - _r } # `_l` is the left argument | {{}^{\mathrm{u}}\mathrm{\underline{s}ub}}\ {\leftarrow}\ {\{}\ {\_\mathrm{l}}\ {-}\ {\_\mathrm{r}}\ {\}} | usub ← { _l − _r } |
| 67 | 10 u:s_ub 3 # dyadic use is currying: `(u:s_ub 10) 3` | {10}\ {{}^{\mathrm{u}}\mathrm{\underline{s}ub}}\ {3} | 10 usub 3 |
| 69 | u:h_yp := { a b -> ((a * a) + b * b) ^ 0.5 } # named parameters before `->` | {{}^{\mathrm{u}}\mathrm{\underline{h}yp}}\ {\leftarrow}\ {\{}\ {\mathrm{a}}\ {\mathrm{b}}\ {\to}\ {(}{(}{\mathrm{a}}\ {\times}\ {\mathrm{a}}{)}\ {+}\ {\mathrm{b}}\ {\times}\ {\mathrm{b}}{)}\ {\mathbin{\hat{}}}\ {0.5}\ {\}} | uhyp ← { a b → ((a × a) + b × b) ^ 0.5 } |
| 70 | 3 u:h_yp 4 | {3}\ {{}^{\mathrm{u}}\mathrm{\underline{h}yp}}\ {4} | 3 uhyp 4 |
| 72 | u:s_ign := { x -> x < 0 ? -1; x = 0 ? 0; 1 } # guards: condition `?` result | {{}^{\mathrm{u}}\mathrm{\underline{s}ign}}\ {\leftarrow}\ {\{}\ {\mathrm{x}}\ {\to}\ {\mathrm{x}}\ {<}\ {0}\ {?}\ {-1}{\diamond}\ {\mathrm{x}}\ {=}\ {0}\ {?}\ {0}{\diamond}\ {1}\ {\}} | usign ← { x → x < 0 ? −1⋄ x = 0 ? 0⋄ 1 } |
| 74 | u:f_act := { n -> | {{}^{\mathrm{u}}\mathrm{\underline{f}act}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\to} | ufact ← { n → |
| 75 | n <= 1 ? 1 | \ \ {\mathrm{n}}\ {\leq}\ {1}\ {?}\ {1} | n ≤ 1 ? 1 |
| 76 | n * u:f_act n - 1 | \ \ {\mathrm{n}}\ {\times}\ {{}^{\mathrm{u}}\mathrm{\underline{f}act}}\ {\mathrm{n}}\ {-}\ {1} | n × ufact n − 1 |
| 77 | } | {\}} | } |
| 78 | u:f_act 10 # recursion | {{}^{\mathrm{u}}\mathrm{\underline{f}act}}\ {10} | ufact 10 |
| 80 | u:t_wo := { @ -> 2 } # a niladic function takes `@` | {{}^{\mathrm{u}}\mathrm{\underline{t}wo}}\ {\leftarrow}\ {\{}\ {@}\ {\to}\ {2}\ {\}} | utwo ← { @ → 2 } |
| 81 | u:t_wo @ | {{}^{\mathrm{u}}\mathrm{\underline{t}wo}}\ {@} | utwo @ |
| 84 | u:k_eep := { a ~_u -> a } # `_u` is a parameter nothing reads; the | {{}^{\mathrm{u}}\mathrm{\underline{k}eep}}\ {\leftarrow}\ {\{}\ {\mathrm{a}}\ {\sim}{\_\mathrm{u}}\ {\to}\ {\mathrm{a}}\ {\}} | ukeep ← { a ∼_u → a } |
| 85 | 7 u:k_eep 1 / 0 # tilde makes it lazy: no division by zero | {7}\ {{}^{\mathrm{u}}\mathrm{\underline{k}eep}}\ {1}\ {\div}\ {0} | 7 ukeep 1 ÷ 0 |
| 86 | (u:s_ub 100)_ 1 # `(expr)_` applies a function value | {\underline{(}}{{}^{\mathrm{u}}\mathrm{\underline{s}ub}}\ {100}{\underline{)}}\ {1} | (usub 100) 1 |
| 88 | u:t_wice := { f_ x -> f_ f_ x } # apply a function parameter two times | {{}^{\mathrm{u}}\mathrm{\underline{t}wice}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{f}}}\ {\mathrm{x}}\ {\to}\ {\mathrm{\underline{f}}}\ {\mathrm{\underline{f}}}\ {\mathrm{x}}\ {\}} | utwice ← { f x → f f x } |
| 89 | '{ _r + 10 } u:t_wice 3 # 3 + 10 + 10 | {\text{'}}{\{}\ {\_\mathrm{r}}\ {+}\ {10}\ {\}}\ {{}^{\mathrm{u}}\mathrm{\underline{t}wice}}\ {3} | ’{ _r + 10 } utwice 3 |
| 90 | 'u:s_quare u:t_wice 3 # square (square 3) = 9 squared | {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{s}quare}}\ {{}^{\mathrm{u}}\mathrm{\underline{t}wice}}\ {3} | ’usquare utwice 3 |
| 93 | '+ r_/ 1 2 3 4 # a quoted function is the operand of `r_/` (reduce) | {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {1}\ {2}\ {3}\ {4} | ’+ r/ 1 2 3 4 |
| 94 | '- r_/ 1 2 3 # reduce folds from the right: 1 - (2 - 3) | {\text{'}}{-}\ {\mathrm{\underline{r}}{/}}\ {1}\ {2}\ {3} | ’− r/ 1 2 3 |
| 95 | '+ s_\ 1 2 3 4 # scan: the prefix reductions | {\text{'}}{+}\ {\mathrm{\underline{s}}{\backslash}}\ {1}\ {2}\ {3}\ {4} | ’+ s\ 1 2 3 4 |
| 96 | '+ r_/ m # the leading axis: column sums | {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{m}} | ’+ r/ m |
| 97 | 'u:s_ign e_ach -5 0 5 # each: apply to every item | {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{s}ign}}\ {\mathrm{\underline{e}ach}}\ {-5}\ {0}\ {5} | ’usign each −5 0 5 |
| 98 | 1 2 3 '= e_ach 1 5 3 # dyadic each is currying | {1}\ {2}\ {3}\ {\text{'}}{=}\ {\mathrm{\underline{e}ach}}\ {1}\ {5}\ {3} | 1 2 3 ’= each 1 5 3 |
| 99 | 1 2 3 '* t_able 1 2 3 # table: the outer product | {1}\ {2}\ {3}\ {\text{'}}{\times}\ {\mathrm{\underline{t}able}}\ {1}\ {2}\ {3} | 1 2 3 ’× table 1 2 3 |
| 100 | m '+ '* i_nner 1 1 1 # inner product: the nearest operand pairs | {\mathrm{m}}\ {\text{'}}{+}\ {\text{'}}{\times}\ {\mathrm{\underline{i}nner}}\ {1}\ {1}\ {1} | m ’+ ’× inner 1 1 1 |
| 101 | 'n_eg 'a_bs c_ompose -4 # compose: the nearest operand applies first | {\text{'}}{\mathrm{\underline{n}eg}}\ {\text{'}}{\mathrm{\underline{a}bs}}\ {\mathrm{\underline{c}ompose}}\ {-4} | ’neg ’abs compose −4 |
| 102 | 2 '/ s_wap 1 # swap the arguments: 1 / 2 | {2}\ {\text{'}}{\div}\ {\mathrm{\underline{s}wap}}\ {1} | 2 ’÷ swap 1 |
| 104 | '{ _l + _r } r_/ 1 2 3 # a quoted lambda is an operand too | {\text{'}}{\{}\ {\_\mathrm{l}}\ {+}\ {\_\mathrm{r}}\ {\}}\ {\mathrm{\underline{r}}{/}}\ {1}\ {2}\ {3} | ’{ _l + _r } r/ 1 2 3 |
| 108 | u:a_vg := ['+ r_/ / t_ally] # fork: `('+ r_/ x) / t_ally x` | {{}^{\mathrm{u}}\mathrm{\underline{a}vg}}\ {\leftarrow}\ {[}{\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\div}\ {\mathrm{\underline{t}ally}}{]} | uavg ← [’+ r/ ÷ tally] |
| 109 | u:a_vg 1 2 3 4 | {{}^{\mathrm{u}}\mathrm{\underline{a}vg}}\ {1}\ {2}\ {3}\ {4} | uavg 1 2 3 4 |
| 110 | { x -> ('+ r_/ x) / t_ally x } 1 2 3 4 # the same, spelled out | {\{}\ {\mathrm{x}}\ {\to}\ {(}{\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{x}}{)}\ {\div}\ {\mathrm{\underline{t}ally}}\ {\mathrm{x}}\ {\}}\ {1}\ {2}\ {3}\ {4} | { x → (’+ r/ x) ÷ tally x } 1 2 3 4 |
| 111 | [n_eg a_bs] -5 # atop: `n_eg a_bs x` | {[}{\mathrm{\underline{n}eg}}\ {\mathrm{\underline{a}bs}}{]}\ {-5} | [neg abs] −5 |
| 112 | 3 [l_eft + r_ight] 4 # dyadic fork: `(x l_eft y) + (x r_ight y)`, so `x + y` | {3}\ {[}{\mathrm{\underline{l}eft}}\ {+}\ {\mathrm{\underline{r}ight}}{]}\ {4} | 3 [left + right] 4 |
| 113 | [i_d - n_eg] 5 # hook: `x - n_eg x` | {[}{\mathrm{\underline{i}d}}\ {-}\ {\mathrm{\underline{n}eg}}{]}\ {5} | [id − neg] 5 |
| 114 | 1 2 [+ * -] 3 4 # dyadic fork: `(x + y) * (x - y)` | {1}\ {2}\ {[}{+}\ {\times}\ {-}{]}\ {3}\ {4} | 1 2 [+ × −] 3 4 |
| 115 | [f_irst c_at 'm_ax r_/ c_at 'm_in r_/] 3 1 4 1 5 # `(f_irst x) c_at ('m_ax r_/ x) c_at 'm_in r_/ x` | {[}{\mathrm{\underline{f}irst}}\ {\mathrm{\underline{c}at}}\ {\text{'}}{\mathrm{\underline{m}ax}}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{\underline{c}at}}\ {\text{'}}{\mathrm{\underline{m}in}}\ {\mathrm{\underline{r}}{/}}{]}\ {3}\ {1}\ {4}\ {1}\ {5} | [first cat ’max r/ cat ’min r/] 3 1 4 1 5 |
| 116 | '[t_ally d_isclose] e_ach "ab" "cde" "f" # each item i: `t_ally d_isclose i` | {\text{'}}{[}{\mathrm{\underline{t}ally}}\ {\mathrm{\underline{d}isclose}}{]}\ {\mathrm{\underline{e}ach}}\ {\text{"ab"}}\ {\text{"cde"}}\ {\text{"f"}} | ’[tally disclose] each "ab" "cde" "f" |
| 119 | 1 o_- 1 2 3 4 # rotate toward the front | {1}\ {\mathrm{\underline{o}}{-}}\ {1}\ {2}\ {3}\ {4} | 1 o− 1 2 3 4 |
| 120 | r_ev "stressed" | {\mathrm{\underline{r}ev}}\ {\text{"stressed"}} | rev "stressed" |
| 124 | '+ r_/ m # implicit: axis 1, so column sums | {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{m}} | ’+ r/ m |
| 125 | '+ r_/_1 m # the same, explicit | {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{1}}\ {\mathrm{m}} | ’+ r/1 m |
| 126 | '+ r_/_2 m # axis 2: row sums | {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{2}}\ {\mathrm{m}} | ’+ r/2 m |
| 127 | '+ s_\_2 m # running sums along each row | {\text{'}}{+}\ {{\mathrm{\underline{s}}{\backslash}}_{2}}\ {\mathrm{m}} | ’+ s\2 m |
| 128 | 1 o_- m # rotate the rows (axis 1) | {1}\ {\mathrm{\underline{o}}{-}}\ {\mathrm{m}} | 1 o− m |
| 129 | 1 o_-_1 m # the same, explicit | {1}\ {{\mathrm{\underline{o}}{-}}_{1}}\ {\mathrm{m}} | 1 o−1 m |
| 130 | 1 o_-_2 m # rotate within each row (axis 2) | {1}\ {{\mathrm{\underline{o}}{-}}_{2}}\ {\mathrm{m}} | 1 o−2 m |
| 131 | r_ev_2 m # reverse each row | {{\mathrm{\underline{r}ev}}_{2}}\ {\mathrm{m}} | rev2 m |
| 132 | '+ r_/_12 m # two axes in turn: the total | {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{12}}\ {\mathrm{m}} | ’+ r/12 m |
| 133 | -1 0 1 o_- 1 2 3 # a list of amounts gives every rotation | {-1}\ {0}\ {1}\ {\mathrm{\underline{o}}{-}}\ {1}\ {2}\ {3} | −1 0 1 o− 1 2 3 |
| 134 | s_hape -1 0 1 o_-_12 m # every combination along both axes: 3 3 2 3 | {\mathrm{\underline{s}hape}}\ {-1}\ {0}\ {1}\ {{\mathrm{\underline{o}}{-}}_{12}}\ {\mathrm{m}} | shape −1 0 1 o−12 m |
| 135 | o_\ m # transpose: rows become columns | {\mathrm{\underline{o}}{\backslash}}\ {\mathrm{m}} | o\ m |
| 137 | a := 2 3 4 r_eshape r_ange 24 | {\mathrm{a}}\ {\leftarrow}\ {2}\ {3}\ {4}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{\underline{r}ange}}\ {24} | a ← 2 3 4 reshape range 24 |
| 138 | s_hape o_\ a # every axis reversed: 4 3 2 | {\mathrm{\underline{s}hape}}\ {\mathrm{\underline{o}}{\backslash}}\ {\mathrm{a}} | shape o\ a |
| 139 | s_hape o_\_23 a # axes 2 and 3 swapped: 2 4 3 | {\mathrm{\underline{s}hape}}\ {{\mathrm{\underline{o}}{\backslash}}_{23}}\ {\mathrm{a}} | shape o\23 a |
| 140 | s_hape 3 1 2 t_ranspose a # axis 1 to 3, 2 to 1, 3 to 2: 3 4 2 | {\mathrm{\underline{s}hape}}\ {3}\ {1}\ {2}\ {\mathrm{\underline{t}ranspose}}\ {\mathrm{a}} | shape 3 1 2 transpose a |
| 144 | v := 3 1 4 1 5 9 2 6 | {\mathrm{v}}\ {\leftarrow}\ {3}\ {1}\ {4}\ {1}\ {5}\ {9}\ {2}\ {6} | v ← 3 1 4 1 5 9 2 6 |
| 145 | s_ort v; g_rade v # sort, and the indices that sort | {\mathrm{\underline{s}ort}}\ {\mathrm{v}}{\diamond}\ {\mathrm{\underline{g}rade}}\ {\mathrm{v}} | sort v⋄ grade v |
| 146 | u_nique v | {\mathrm{\underline{u}nique}}\ {\mathrm{v}} | unique v |
| 147 | v i_ndexOf 5 7 # 7 is absent: tally + 1 | {\mathrm{v}}\ {\mathrm{\underline{i}ndexOf}}\ {5}\ {7} | v indexOf 5 7 |
| 148 | 2 7 m_ember? v | {2}\ {7}\ {\mathrm{\underline{m}ember}{?}}\ {\mathrm{v}} | 2 7 member? v |
| 149 | w_here v > 4 # indices of the 1s | {\mathrm{\underline{w}here}}\ {\mathrm{v}}\ {>}\ {4} | where v > 4 |
| 153 | n := "ab" "cde" # a strand of strings: a vector of 2 boxes | {\mathrm{n}}\ {\leftarrow}\ {\text{"ab"}}\ {\text{"cde"}} | n ← "ab" "cde" |
| 154 | n # nested values print framed (APL2's DISPLAY) | {\mathrm{n}} | n |
| 155 | t_ally n | {\mathrm{\underline{t}ally}}\ {\mathrm{n}} | tally n |
| 156 | d_isclose 2 s_elect n # open the 2nd box | {\mathrm{\underline{d}isclose}}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{n}} | disclose 2 select n |
| 158 | s := "to be or not" | {\mathrm{s}}\ {\leftarrow}\ {\text{"to be or not"}} | s ← "to be or not" |
| 159 | (s != f_irst " ") p_artition s # cut where the mask is 0: the words, boxed | {(}{\mathrm{s}}\ {\neq}\ {\mathrm{\underline{f}irst}}\ {\text{" "}}{)}\ {\mathrm{\underline{p}artition}}\ {\mathrm{s}} | (s = first " ") partition s |
| 160 | 'r_ange m_ap 1 2 3 # map: each result boxed, so it may be an array | {\text{'}}{\mathrm{\underline{r}ange}}\ {\mathrm{\underline{m}ap}}\ {1}\ {2}\ {3} | ’range map 1 2 3 |
| 161 | d_isplay m # any value framed, as a character matrix (xetal --box prints all so) | {\mathrm{\underline{d}isplay}}\ {\mathrm{m}} | display m |
| 164 | r_oll! 6 6 6 # three dice: random 1..6 each, so every run differs | {\mathrm{\underline{r}oll}{!}}\ {6}\ {6}\ {6} | roll! 6 6 6 |
| 165 | r_oll! 6 6 6 # (and each line rolls again) | {\mathrm{\underline{r}oll}{!}}\ {6}\ {6}\ {6} | roll! 6 6 6 |
| 166 | r_oll! 6 6 6 | {\mathrm{\underline{r}oll}{!}}\ {6}\ {6}\ {6} | roll! 6 6 6 |
| 167 | p_rint! "printed, then returned" # `p_rint!` prints and returns its argument | {\mathrm{\underline{p}rint}{!}}\ {\text{"printed, then returned"}} | print! "printed, then returned" |
| 174 | 15 t_ake []G_RID 2 2 r_eshape 1 0 0 1 | {15}\ {\mathrm{\underline{t}ake}}\ {\square \mathrm{\underline{G}RID}}\ {2}\ {2}\ {\mathrm{\underline{r}eshape}}\ {1}\ {0}\ {0}\ {1} | 15 take □GRID 2 2 reshape 1 0 0 1 |
| 177 | "s:" u_se< "Stats" # import a library under an alias of your choosing | {\text{"s:"}}\ {\mathrm{\underline{u}se}{<}}\ {\text{"Stats"}} | "s:" use< "Stats" |
| 178 | s:m_ean 2 4 4 4 5 5 7 9 # its exported names, used through the alias | {{}^{\mathrm{s}}\mathrm{\underline{m}ean}}\ {2}\ {4}\ {4}\ {4}\ {5}\ {5}\ {7}\ {9} | smean 2 4 4 4 5 5 7 9 |
| 179 | s:s_d 2 4 4 4 5 5 7 9 # the standard deviation | {{}^{\mathrm{s}}\mathrm{\underline{s}d}}\ {2}\ {4}\ {4}\ {4}\ {5}\ {5}\ {7}\ {9} | ssd 2 4 4 4 5 5 7 9 |
| 180 | s:s_pread 3 1 4 1 5 # largest minus smallest | {{}^{\mathrm{s}}\mathrm{\underline{s}pread}}\ {3}\ {1}\ {4}\ {1}\ {5} | sspread 3 1 4 1 5 |
| 181 | "hi:" u_se< "Hello" # a library of your own, found in userlibs/ | {\text{"hi:"}}\ {\mathrm{\underline{u}se}{<}}\ {\text{"Hello"}} | "hi:" use< "Hello" |
| 182 | hi:h_ello @ # niladic: called with Unit | {{}^{\mathrm{hi}}\mathrm{\underline{h}ello}}\ {@} | hihello @ |
| 185 | "c:" u_se< "Combinators" # Smullyan's birds, a standard library | {\text{"c:"}}\ {\mathrm{\underline{u}se}{<}}\ {\text{"Combinators"}} | "c:" use< "Combinators" |
| 186 | 1 c:K_ 2 # K keeps its first argument | {1}\ {{}^{\mathrm{c}}\mathrm{\underline{K}}}\ {2} | 1 cK 2 |
| 187 | 10 '- c:C_ 3 # C swaps the arguments: 3 - 10 | {10}\ {\text{'}}{-}\ {{}^{\mathrm{c}}\mathrm{\underline{C}}}\ {3} | 10 ’− cC 3 |
| 188 | 'n_eg 'a_bs c:B_ -5 # B composes, the nearest operand last: a_bs n_eg -5 | {\text{'}}{\mathrm{\underline{n}eg}}\ {\text{'}}{\mathrm{\underline{a}bs}}\ {{}^{\mathrm{c}}\mathrm{\underline{B}}}\ {-5} | ’neg ’abs cB −5 |
| 189 | '* c:W_ 4 # W uses its argument twice: 4 * 4 | {\text{'}}{\times}\ {{}^{\mathrm{c}}\mathrm{\underline{W}}}\ {4} | ’× cW 4 |
| 192 | u:t_riangle := { ~s_elf n -> n <= 1 ? 1; n + s_elf n - 1 } | {{}^{\mathrm{u}}\mathrm{\underline{t}riangle}}\ {\leftarrow}\ {\{}\ {\sim}{\mathrm{\underline{s}elf}}\ {\mathrm{n}}\ {\to}\ {\mathrm{n}}\ {\leq}\ {1}\ {?}\ {1}{\diamond}\ {\mathrm{n}}\ {+}\ {\mathrm{\underline{s}elf}}\ {\mathrm{n}}\ {-}\ {1}\ {\}} | utriangle ← { ∼self n → n ≤ 1 ? 1⋄ n + self n − 1 } |
| 193 | 'u:t_riangle c:Y_ 5 # Y: recursion, from a function handed itself: 1+2+3+4+5 | {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{t}riangle}}\ {{}^{\mathrm{c}}\mathrm{\underline{Y}}}\ {5} | ’utriangle cY 5 |
| 194 | n_eg^3 5 # a superscript repeats a function: n_eg three times | {\mathrm{\underline{n}eg}}^{3}\ {5} | neg3 5 |
| 197 | (1 2 3, 4.5, "abc") # a tuple: several values of their own types side by side | {(}{1}\ {2}\ {3}{,}\ {4.5}{,}\ {\text{"abc"}}{)} | (1 2 3, 4.5, "abc") |
| 199 | u:s_wapped := { (a, b) -> (b, a) } | {{}^{\mathrm{u}}\mathrm{\underline{s}wapped}}\ {\leftarrow}\ {\{}\ {(}{\mathrm{a}}{,}\ {\mathrm{b}}{)}\ {\to}\ {(}{\mathrm{b}}{,}\ {\mathrm{a}}{)}\ {\}} | uswapped ← { (a, b) → (b, a) } |
| 200 | u:s_wapped (1, "x") | {{}^{\mathrm{u}}\mathrm{\underline{s}wapped}}\ {(}{1}{,}\ {\text{"x"}}{)} | uswapped (1, "x") |
| 201 | (n, (x, _)) := (3, (2.5, "unused")) # a pattern binds names; _ ignores a part | {(}{\mathrm{n}}{,}\ {(}{\mathrm{x}}{,}\ {\_}{)}{)}\ {\leftarrow}\ {(}{3}{,}\ {(}{2.5}{,}\ {\text{"unused"}}{)}{)} | (n, (x, _)) ← (3, (2.5, "unused")) |
| 202 | x * f_loat n | {\mathrm{x}}\ {\times}\ {\mathrm{\underline{f}loat}}\ {\mathrm{n}} | x × float n |
| 204 | u:s_tep := { (w, k) -> (w * 0.5, k + 1) } | {{}^{\mathrm{u}}\mathrm{\underline{s}tep}}\ {\leftarrow}\ {\{}\ {(}{\mathrm{w}}{,}\ {\mathrm{k}}{)}\ {\to}\ {(}{\mathrm{w}}\ {\times}\ {0.5}{,}\ {\mathrm{k}}\ {+}\ {1}{)}\ {\}} | ustep ← { (w, k) → (w × 0.5, k + 1) } |
| 205 | 3 'u:s_tep p_ower (8.0 4.0, 0) | {3}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{s}tep}}\ {\mathrm{\underline{p}ower}}\ {(}{8.0}\ {4.0}{,}\ {0}{)} | 3 ’ustep power (8.0 4.0, 0) |
| 206 | (1, 2.5) m_atch (1, 2.5) # m_atch compares tuples part by part | {(}{1}{,}\ {2.5}{)}\ {\mathrm{\underline{m}atch}}\ {(}{1}{,}\ {2.5}{)} | (1, 2.5) match (1, 2.5) |
| 207 | '{ k -> (k, f_loat k) } m_ap 1 2 # boxed tuples: an array of tuples | {\text{'}}{\{}\ {\mathrm{k}}\ {\to}\ {(}{\mathrm{k}}{,}\ {\mathrm{\underline{f}loat}}\ {\mathrm{k}}{)}\ {\}}\ {\mathrm{\underline{m}ap}}\ {1}\ {2} | ’{ k → (k, float k) } map 1 2 |
| 213 | u:l_ife := { ('+ r_/_12 -1 0 1 o_-_12 _r) { (_l = 3) + _r * _l = 4 } _r } | {{}^{\mathrm{u}}\mathrm{\underline{l}ife}}\ {\leftarrow}\ {\{}\ {(}{\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{12}}\ {-1}\ {0}\ {1}\ {{\mathrm{\underline{o}}{-}}_{12}}\ {\_\mathrm{r}}{)}\ {\{}\ {(}{\_\mathrm{l}}\ {=}\ {3}{)}\ {+}\ {\_\mathrm{r}}\ {\times}\ {\_\mathrm{l}}\ {=}\ {4}\ {\}}\ {\_\mathrm{r}}\ {\}} | ulife ← { (’+ r/12 −1 0 1 o−12 _r) { (_l = 3) + _r × _l = 4 } _r } |
| 214 | u:l_ife 5 5 r_eshape 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 | {{}^{\mathrm{u}}\mathrm{\underline{l}ife}}\ {5}\ {5}\ {\mathrm{\underline{r}eshape}}\ {0}\ {0}\ {0}\ {0}\ {0}\ {0}\ {0}\ {1}\ {0}\ {0}\ {0}\ {0}\ {1}\ {0}\ {0}\ {0}\ {0}\ {1}\ {0}\ {0}\ {0}\ {0}\ {0}\ {0}\ {0} | ulife 5 5 reshape 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 |
| 25 | l:I_ := { x -> x } # Idiot Bird (identity) | {{}^{\mathrm{l}}\mathrm{\underline{I}}}\ {\leftarrow}\ {\{}\ {\mathrm{x}}\ {\to}\ {\mathrm{x}}\ {\}} | lI ← { x → x } |
| 32 | l:K_ := { x _u -> x } # Kestrel | {{}^{\mathrm{l}}\mathrm{\underline{K}}}\ {\leftarrow}\ {\{}\ {\mathrm{x}}\ {\_\mathrm{u}}\ {\to}\ {\mathrm{x}}\ {\}} | lK ← { x _u → x } |
| 38 | l:T_ := { x y_ -> y_ x } # Thrush | {{}^{\mathrm{l}}\mathrm{\underline{T}}}\ {\leftarrow}\ {\{}\ {\mathrm{x}}\ {\mathrm{\underline{y}}}\ {\to}\ {\mathrm{\underline{y}}}\ {\mathrm{x}}\ {\}} | lT ← { x y → y x } |
| 44 | l:W_ := { x_ y -> y x_ y } # Warbler | {{}^{\mathrm{l}}\mathrm{\underline{W}}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{y}}\ {\to}\ {\mathrm{y}}\ {\mathrm{\underline{x}}}\ {\mathrm{y}}\ {\}} | lW ← { x y → y x y } |
| 51 | l:W_1 := { x y_ -> x y_ x } # Converse Warbler | {{}^{\mathrm{l}}\mathrm{\underline{W}1}}\ {\leftarrow}\ {\{}\ {\mathrm{x}}\ {\mathrm{\underline{y}}}\ {\to}\ {\mathrm{x}}\ {\mathrm{\underline{y}}}\ {\mathrm{x}}\ {\}} | lW1 ← { x y → x y x } |
| 59 | l:B_ := { x_ y_ z -> x_ y_ z } # Bluebird: compose | {{}^{\mathrm{l}}\mathrm{\underline{B}}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{\underline{y}}}\ {\mathrm{z}}\ {\to}\ {\mathrm{\underline{x}}}\ {\mathrm{\underline{y}}}\ {\mathrm{z}}\ {\}} | lB ← { x y z → x y z } |
| 62 | l:B_1 := { x_ y_ z w -> x_ z y_ w } # Blackbird | {{}^{\mathrm{l}}\mathrm{\underline{B}1}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{\underline{y}}}\ {\mathrm{z}}\ {\mathrm{w}}\ {\to}\ {\mathrm{\underline{x}}}\ {\mathrm{z}}\ {\mathrm{\underline{y}}}\ {\mathrm{w}}\ {\}} | lB1 ← { x y z w → x z y w } |
| 65 | l:B_2 := { x_ y_ z w v -> x_ (z y_ w)_ v } # Bunting | {{}^{\mathrm{l}}\mathrm{\underline{B}2}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{\underline{y}}}\ {\mathrm{z}}\ {\mathrm{w}}\ {\mathrm{v}}\ {\to}\ {\mathrm{\underline{x}}}\ {\underline{(}}{\mathrm{z}}\ {\mathrm{\underline{y}}}\ {\mathrm{w}}{\underline{)}}\ {\mathrm{v}}\ {\}} | lB2 ← { x y z w v → x (z y w) v } |
| 68 | l:B_3 := { x_ y_ z_ w -> x_ y_ z_ w } # Becard | {{}^{\mathrm{l}}\mathrm{\underline{B}3}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{\underline{y}}}\ {\mathrm{\underline{z}}}\ {\mathrm{w}}\ {\to}\ {\mathrm{\underline{x}}}\ {\mathrm{\underline{y}}}\ {\mathrm{\underline{z}}}\ {\mathrm{w}}\ {\}} | lB3 ← { x y z w → x y z w } |
| 75 | l:C_ := { x_ y z -> z x_ y } # Cardinal: swap | {{}^{\mathrm{l}}\mathrm{\underline{C}}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{y}}\ {\mathrm{z}}\ {\to}\ {\mathrm{z}}\ {\mathrm{\underline{x}}}\ {\mathrm{y}}\ {\}} | lC ← { x y z → z x y } |
| 78 | l:D_ := { x_ y z_ w -> y x_ z_ w } # Dove | {{}^{\mathrm{l}}\mathrm{\underline{D}}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{y}}\ {\mathrm{\underline{z}}}\ {\mathrm{w}}\ {\to}\ {\mathrm{y}}\ {\mathrm{\underline{x}}}\ {\mathrm{\underline{z}}}\ {\mathrm{w}}\ {\}} | lD ← { x y z w → y x z w } |
| 81 | l:D_1 := { x_ y z w_ v -> (y x_ z)_ w_ v } # Dickcissel | {{}^{\mathrm{l}}\mathrm{\underline{D}1}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{y}}\ {\mathrm{z}}\ {\mathrm{\underline{w}}}\ {\mathrm{v}}\ {\to}\ {\underline{(}}{\mathrm{y}}\ {\mathrm{\underline{x}}}\ {\mathrm{z}}{\underline{)}}\ {\mathrm{\underline{w}}}\ {\mathrm{v}}\ {\}} | lD1 ← { x y z w v → (y x z) w v } |
| 85 | l:D_2 := { x_ y_ z w_ v -> (y_ z) x_ w_ v } # Dovekie | {{}^{\mathrm{l}}\mathrm{\underline{D}2}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{\underline{y}}}\ {\mathrm{z}}\ {\mathrm{\underline{w}}}\ {\mathrm{v}}\ {\to}\ {(}{\mathrm{\underline{y}}}\ {\mathrm{z}}{)}\ {\mathrm{\underline{x}}}\ {\mathrm{\underline{w}}}\ {\mathrm{v}}\ {\}} | lD2 ← { x y z w v → (y z) x w v } |
| 88 | l:E_ := { x_ y z_ w v -> y x_ w z_ v } # Eagle | {{}^{\mathrm{l}}\mathrm{\underline{E}}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{y}}\ {\mathrm{\underline{z}}}\ {\mathrm{w}}\ {\mathrm{v}}\ {\to}\ {\mathrm{y}}\ {\mathrm{\underline{x}}}\ {\mathrm{w}}\ {\mathrm{\underline{z}}}\ {\mathrm{v}}\ {\}} | lE ← { x y z w v → y x w z v } |
| 91 | l:E_h := { x_ a_ b c d_ e f -> (b a_ c) x_ e d_ f } # Bald Eagle | {{}^{\mathrm{l}}\mathrm{\underline{E}h}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{\underline{a}}}\ {\mathrm{b}}\ {\mathrm{c}}\ {\mathrm{\underline{d}}}\ {\mathrm{e}}\ {\mathrm{f}}\ {\to}\ {(}{\mathrm{b}}\ {\mathrm{\underline{a}}}\ {\mathrm{c}}{)}\ {\mathrm{\underline{x}}}\ {\mathrm{e}}\ {\mathrm{\underline{d}}}\ {\mathrm{f}}\ {\}} | lEh ← { x a b c d e f → (b a c) x e d f } |
| 100 | l:F_ := { x y z_ -> y z_ x } # Finch | {{}^{\mathrm{l}}\mathrm{\underline{F}}}\ {\leftarrow}\ {\{}\ {\mathrm{x}}\ {\mathrm{y}}\ {\mathrm{\underline{z}}}\ {\to}\ {\mathrm{y}}\ {\mathrm{\underline{z}}}\ {\mathrm{x}}\ {\}} | lF ← { x y z → y z x } |
| 103 | l:G_ := { x_ y_ z w -> w x_ y_ z } # Goldfinch | {{}^{\mathrm{l}}\mathrm{\underline{G}}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{\underline{y}}}\ {\mathrm{z}}\ {\mathrm{w}}\ {\to}\ {\mathrm{w}}\ {\mathrm{\underline{x}}}\ {\mathrm{\underline{y}}}\ {\mathrm{z}}\ {\}} | lG ← { x y z w → w x y z } |
| 106 | l:H_ := { x_ y z -> (y x_ z)_ y } # Hummingbird | {{}^{\mathrm{l}}\mathrm{\underline{H}}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{y}}\ {\mathrm{z}}\ {\to}\ {\underline{(}}{\mathrm{y}}\ {\mathrm{\underline{x}}}\ {\mathrm{z}}{\underline{)}}\ {\mathrm{y}}\ {\}} | lH ← { x y z → (y x z) y } |
| 109 | l:J_ := { x_ y z w -> y x_ w x_ z } # Jay | {{}^{\mathrm{l}}\mathrm{\underline{J}}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{y}}\ {\mathrm{z}}\ {\mathrm{w}}\ {\to}\ {\mathrm{y}}\ {\mathrm{\underline{x}}}\ {\mathrm{w}}\ {\mathrm{\underline{x}}}\ {\mathrm{z}}\ {\}} | lJ ← { x y z w → y x w x z } |
| 112 | l:O_ := { x_ y_ -> y_ x_ 'y_ } # Owl | {{}^{\mathrm{l}}\mathrm{\underline{O}}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{\underline{y}}}\ {\to}\ {\mathrm{\underline{y}}}\ {\mathrm{\underline{x}}}\ {\text{'}}{\mathrm{\underline{y}}}\ {\}} | lO ← { x y → y x ’y } |
| 119 | l:Q_ := { x_ y_ z -> y_ x_ z } # Queer Bird | {{}^{\mathrm{l}}\mathrm{\underline{Q}}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{\underline{y}}}\ {\mathrm{z}}\ {\to}\ {\mathrm{\underline{y}}}\ {\mathrm{\underline{x}}}\ {\mathrm{z}}\ {\}} | lQ ← { x y z → y x z } |
| 122 | l:Q_1 := { x_ y z_ -> x_ z_ y } # Quixotic Bird | {{}^{\mathrm{l}}\mathrm{\underline{Q}1}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{y}}\ {\mathrm{\underline{z}}}\ {\to}\ {\mathrm{\underline{x}}}\ {\mathrm{\underline{z}}}\ {\mathrm{y}}\ {\}} | lQ1 ← { x y z → x z y } |
| 125 | l:Q_2 := { x y_ z_ -> y_ z_ x } # Quizzical Bird | {{}^{\mathrm{l}}\mathrm{\underline{Q}2}}\ {\leftarrow}\ {\{}\ {\mathrm{x}}\ {\mathrm{\underline{y}}}\ {\mathrm{\underline{z}}}\ {\to}\ {\mathrm{\underline{y}}}\ {\mathrm{\underline{z}}}\ {\mathrm{x}}\ {\}} | lQ2 ← { x y z → y z x } |
| 128 | l:Q_3 := { x_ y z_ -> z_ x_ y } # Quirky Bird | {{}^{\mathrm{l}}\mathrm{\underline{Q}3}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{y}}\ {\mathrm{\underline{z}}}\ {\to}\ {\mathrm{\underline{z}}}\ {\mathrm{\underline{x}}}\ {\mathrm{y}}\ {\}} | lQ3 ← { x y z → z x y } |
| 131 | l:Q_4 := { x y_ z_ -> z_ y_ x } # Quacky Bird | {{}^{\mathrm{l}}\mathrm{\underline{Q}4}}\ {\leftarrow}\ {\{}\ {\mathrm{x}}\ {\mathrm{\underline{y}}}\ {\mathrm{\underline{z}}}\ {\to}\ {\mathrm{\underline{z}}}\ {\mathrm{\underline{y}}}\ {\mathrm{x}}\ {\}} | lQ4 ← { x y z → z y x } |
| 137 | l:R_ := { x y_ z -> z y_ x } # Robin | {{}^{\mathrm{l}}\mathrm{\underline{R}}}\ {\leftarrow}\ {\{}\ {\mathrm{x}}\ {\mathrm{\underline{y}}}\ {\mathrm{z}}\ {\to}\ {\mathrm{z}}\ {\mathrm{\underline{y}}}\ {\mathrm{x}}\ {\}} | lR ← { x y z → z y x } |
| 143 | l:S_ := { x_ y_ z -> z x_ y_ z } # Starling | {{}^{\mathrm{l}}\mathrm{\underline{S}}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{\underline{y}}}\ {\mathrm{z}}\ {\to}\ {\mathrm{z}}\ {\mathrm{\underline{x}}}\ {\mathrm{\underline{y}}}\ {\mathrm{z}}\ {\}} | lS ← { x y z → z x y z } |
| 150 | l:V_ := { x y z_ -> x z_ y } # Vireo: a pair | {{}^{\mathrm{l}}\mathrm{\underline{V}}}\ {\leftarrow}\ {\{}\ {\mathrm{x}}\ {\mathrm{y}}\ {\mathrm{\underline{z}}}\ {\to}\ {\mathrm{x}}\ {\mathrm{\underline{z}}}\ {\mathrm{y}}\ {\}} | lV ← { x y z → x z y } |
| 160 | l:P_hi := { x_ y_ z_ w -> (y_ w) x_ z_ w } # Phoenix: a fork | {{}^{\mathrm{l}}\mathrm{\underline{P}hi}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{\underline{y}}}\ {\mathrm{\underline{z}}}\ {\mathrm{w}}\ {\to}\ {(}{\mathrm{\underline{y}}}\ {\mathrm{w}}{)}\ {\mathrm{\underline{x}}}\ {\mathrm{\underline{z}}}\ {\mathrm{w}}\ {\}} | lPhi ← { x y z w → (y w) x z w } |
| 167 | l:P_si := { x_ y_ z w -> (y_ z) x_ y_ w } # Psi: on | {{}^{\mathrm{l}}\mathrm{\underline{P}si}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{\underline{y}}}\ {\mathrm{z}}\ {\mathrm{w}}\ {\to}\ {(}{\mathrm{\underline{y}}}\ {\mathrm{z}}{)}\ {\mathrm{\underline{x}}}\ {\mathrm{\underline{y}}}\ {\mathrm{w}}\ {\}} | lPsi ← { x y z w → (y z) x y w } |
| 172 | l:C_s := { x_ y z w -> (y x_ w)_ z } | {{}^{\mathrm{l}}\mathrm{\underline{C}s}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{y}}\ {\mathrm{z}}\ {\mathrm{w}}\ {\to}\ {\underline{(}}{\mathrm{y}}\ {\mathrm{\underline{x}}}\ {\mathrm{w}}{\underline{)}}\ {\mathrm{z}}\ {\}} | lCs ← { x y z w → (y x w) z } |
| 175 | l:R_s := { x_ y z w -> (z x_ w)_ y } | {{}^{\mathrm{l}}\mathrm{\underline{R}s}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{y}}\ {\mathrm{z}}\ {\mathrm{w}}\ {\to}\ {\underline{(}}{\mathrm{z}}\ {\mathrm{\underline{x}}}\ {\mathrm{w}}{\underline{)}}\ {\mathrm{y}}\ {\}} | lRs ← { x y z w → (z x w) y } |
| 178 | l:F_s := { x_ y z w -> (w x_ z)_ y } | {{}^{\mathrm{l}}\mathrm{\underline{F}s}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{y}}\ {\mathrm{z}}\ {\mathrm{w}}\ {\to}\ {\underline{(}}{\mathrm{w}}\ {\mathrm{\underline{x}}}\ {\mathrm{z}}{\underline{)}}\ {\mathrm{y}}\ {\}} | lFs ← { x y z w → (w x z) y } |
| 181 | l:V_s := { x_ y z w -> (w x_ y)_ z } | {{}^{\mathrm{l}}\mathrm{\underline{V}s}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{y}}\ {\mathrm{z}}\ {\mathrm{w}}\ {\to}\ {\underline{(}}{\mathrm{w}}\ {\mathrm{\underline{x}}}\ {\mathrm{y}}{\underline{)}}\ {\mathrm{z}}\ {\}} | lVs ← { x y z w → (w x y) z } |
| 184 | l:W_s := { x_ y z -> (y x_ z)_ z } | {{}^{\mathrm{l}}\mathrm{\underline{W}s}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{y}}\ {\mathrm{z}}\ {\to}\ {\underline{(}}{\mathrm{y}}\ {\mathrm{\underline{x}}}\ {\mathrm{z}}{\underline{)}}\ {\mathrm{z}}\ {\}} | lWs ← { x y z → (y x z) z } |
| 189 | l:C_ss := { x_ y z w v -> ((y x_ z)_ v)_ w } | {{}^{\mathrm{l}}\mathrm{\underline{C}ss}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{y}}\ {\mathrm{z}}\ {\mathrm{w}}\ {\mathrm{v}}\ {\to}\ {\underline{(}}{\underline{(}}{\mathrm{y}}\ {\mathrm{\underline{x}}}\ {\mathrm{z}}{\underline{)}}\ {\mathrm{v}}{\underline{)}}\ {\mathrm{w}}\ {\}} | lCss ← { x y z w v → ((y x z) v) w } |
| 192 | l:R_ss := { x_ y z w v -> ((y x_ w)_ v)_ z } | {{}^{\mathrm{l}}\mathrm{\underline{R}ss}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{y}}\ {\mathrm{z}}\ {\mathrm{w}}\ {\mathrm{v}}\ {\to}\ {\underline{(}}{\underline{(}}{\mathrm{y}}\ {\mathrm{\underline{x}}}\ {\mathrm{w}}{\underline{)}}\ {\mathrm{v}}{\underline{)}}\ {\mathrm{z}}\ {\}} | lRss ← { x y z w v → ((y x w) v) z } |
| 195 | l:F_ss := { x_ y z w v -> ((y x_ v)_ w)_ z } | {{}^{\mathrm{l}}\mathrm{\underline{F}ss}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{y}}\ {\mathrm{z}}\ {\mathrm{w}}\ {\mathrm{v}}\ {\to}\ {\underline{(}}{\underline{(}}{\mathrm{y}}\ {\mathrm{\underline{x}}}\ {\mathrm{v}}{\underline{)}}\ {\mathrm{w}}{\underline{)}}\ {\mathrm{z}}\ {\}} | lFss ← { x y z w v → ((y x v) w) z } |
| 198 | l:V_ss := { x_ y z w v -> ((y x_ v)_ z)_ w } | {{}^{\mathrm{l}}\mathrm{\underline{V}ss}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{y}}\ {\mathrm{z}}\ {\mathrm{w}}\ {\mathrm{v}}\ {\to}\ {\underline{(}}{\underline{(}}{\mathrm{y}}\ {\mathrm{\underline{x}}}\ {\mathrm{v}}{\underline{)}}\ {\mathrm{z}}{\underline{)}}\ {\mathrm{w}}\ {\}} | lVss ← { x y z w v → ((y x v) z) w } |
| 201 | l:W_ss := { x_ y z w -> ((y x_ z)_ w)_ w } | {{}^{\mathrm{l}}\mathrm{\underline{W}ss}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{y}}\ {\mathrm{z}}\ {\mathrm{w}}\ {\to}\ {\underline{(}}{\underline{(}}{\mathrm{y}}\ {\mathrm{\underline{x}}}\ {\mathrm{z}}{\underline{)}}\ {\mathrm{w}}{\underline{)}}\ {\mathrm{w}}\ {\}} | lWss ← { x y z w → ((y x z) w) w } |
| 212 | l:Y_ := { f_ -> f_ l:Y_ 'f_ } | {{}^{\mathrm{l}}\mathrm{\underline{Y}}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{f}}}\ {\to}\ {\mathrm{\underline{f}}}\ {{}^{\mathrm{l}}\mathrm{\underline{Y}}}\ {\text{'}}{\mathrm{\underline{f}}}\ {\}} | lY ← { f → f lY ’f } |
| 18 | l:a_ttr := { name value -> " " c_at name c_at "=\"" c_at (l:e_scape value) c_at "\"" } | {{}^{\mathrm{l}}\mathrm{\underline{a}ttr}}\ {\leftarrow}\ {\{}\ {\mathrm{name}}\ {\mathrm{value}}\ {\to}\ {\text{" "}}\ {\mathrm{\underline{c}at}}\ {\mathrm{name}}\ {\mathrm{\underline{c}at}}\ {\text{"=\textbackslash{}""}}\ {\mathrm{\underline{c}at}}\ {(}{{}^{\mathrm{l}}\mathrm{\underline{e}scape}}\ {\mathrm{value}}{)}\ {\mathrm{\underline{c}at}}\ {\text{"\textbackslash{}""}}\ {\}} | lattr ← { name value → " " cat name cat "=\"" cat (lescape value) cat "\"" } |
| 31 | l:e_scape := { t -> | {{}^{\mathrm{l}}\mathrm{\underline{e}scape}}\ {\leftarrow}\ {\{}\ {\mathrm{t}}\ {\to} | lescape ← { t → |
| 32 | 0 = '+ r_/ t m_ember? "&<>\"" ? t | \ \ {0}\ {=}\ {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{t}}\ {\mathrm{\underline{m}ember}{?}}\ {\text{"\&<>\textbackslash{}""}}\ {?}\ {\mathrm{t}} | 0 = ’+ r/ t member? "&<>\"" ? t |
| 33 | h:j_oin 'h:e_sc m_ap t | \ \ {{}^{\mathrm{h}}\mathrm{\underline{j}oin}}\ {\text{'}}{{}^{\mathrm{h}}\mathrm{\underline{e}sc}}\ {\mathrm{\underline{m}ap}}\ {\mathrm{t}} | hjoin ’hesc map t |
| 34 | } | {\}} | } |
| 40 | l:f_ill := { color -> "fill" l:a_ttr color } | {{}^{\mathrm{l}}\mathrm{\underline{f}ill}}\ {\leftarrow}\ {\{}\ {\mathrm{color}}\ {\to}\ {\text{"fill"}}\ {{}^{\mathrm{l}}\mathrm{\underline{a}ttr}}\ {\mathrm{color}}\ {\}} | lfill ← { color → "fill" lattr color } |
| 47 | l:r_gb := { c -> | {{}^{\mathrm{l}}\mathrm{\underline{r}gb}}\ {\leftarrow}\ {\{}\ {\mathrm{c}}\ {\to} | lrgb ← { c → |
| 48 | k := 0 m_ax 255 m_in f_loor 0.5 + f_loat c | \ \ {\mathrm{k}}\ {\leftarrow}\ {0}\ {\mathrm{\underline{m}ax}}\ {255}\ {\mathrm{\underline{m}in}}\ {\mathrm{\underline{f}loor}}\ {0.5}\ {+}\ {\mathrm{\underline{f}loat}}\ {\mathrm{c}} | k ← 0 max 255 min floor 0.5 + float c |
| 49 | "rgb(" c_at (f_ormat 1 s_elect k) c_at "," c_at (f_ormat 2 s_elect k) c_at "," c_at (f_ormat 3 s_elect k) c_at ")" | \ \ {\text{"rgb("}}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{f}ormat}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{k}}{)}\ {\mathrm{\underline{c}at}}\ {\text{","}}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{f}ormat}}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{k}}{)}\ {\mathrm{\underline{c}at}}\ {\text{","}}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{f}ormat}}\ {3}\ {\mathrm{\underline{s}elect}}\ {\mathrm{k}}{)}\ {\mathrm{\underline{c}at}}\ {\text{")"}} | "rgb(" cat (format 1 select k) cat "," cat (format 2 select k) cat "," cat (format 3 select k) cat ")" |
| 50 | } | {\}} | } |
| 56 | l:s_troke := { color width -> ("stroke" l:a_ttr color) c_at ("stroke-width" l:a_ttr f_ormat width) c_at " stroke-linejoin=\"round\"" } | {{}^{\mathrm{l}}\mathrm{\underline{s}troke}}\ {\leftarrow}\ {\{}\ {\mathrm{color}}\ {\mathrm{width}}\ {\to}\ {(}{\text{"stroke"}}\ {{}^{\mathrm{l}}\mathrm{\underline{a}ttr}}\ {\mathrm{color}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\text{"stroke-width"}}\ {{}^{\mathrm{l}}\mathrm{\underline{a}ttr}}\ {\mathrm{\underline{f}ormat}}\ {\mathrm{width}}{)}\ {\mathrm{\underline{c}at}}\ {\text{" stroke-linejoin=\textbackslash{}"round\textbackslash{}""}}\ {\}} | lstroke ← { color width → ("stroke" lattr color) cat ("stroke-width" lattr format width) cat " stroke-linejoin=\"round\"" } |
| 65 | l:p_olygon := { attrs points -> "<polygon points=\"" c_at (h:p_airs points) c_at "\"" c_at attrs c_at "/>" } | {{}^{\mathrm{l}}\mathrm{\underline{p}olygon}}\ {\leftarrow}\ {\{}\ {\mathrm{attrs}}\ {\mathrm{points}}\ {\to}\ {\text{"<polygon points=\textbackslash{}""}}\ {\mathrm{\underline{c}at}}\ {(}{{}^{\mathrm{h}}\mathrm{\underline{p}airs}}\ {\mathrm{points}}{)}\ {\mathrm{\underline{c}at}}\ {\text{"\textbackslash{}""}}\ {\mathrm{\underline{c}at}}\ {\mathrm{attrs}}\ {\mathrm{\underline{c}at}}\ {\text{"/>"}}\ {\}} | lpolygon ← { attrs points → "<polygon points=\"" cat (hpairs points) cat "\"" cat attrs cat "/>" } |
| 71 | l:p_olyline := { attrs points -> "<polyline points=\"" c_at (h:p_airs points) c_at "\"" c_at attrs c_at "/>" } | {{}^{\mathrm{l}}\mathrm{\underline{p}olyline}}\ {\leftarrow}\ {\{}\ {\mathrm{attrs}}\ {\mathrm{points}}\ {\to}\ {\text{"<polyline points=\textbackslash{}""}}\ {\mathrm{\underline{c}at}}\ {(}{{}^{\mathrm{h}}\mathrm{\underline{p}airs}}\ {\mathrm{points}}{)}\ {\mathrm{\underline{c}at}}\ {\text{"\textbackslash{}""}}\ {\mathrm{\underline{c}at}}\ {\mathrm{attrs}}\ {\mathrm{\underline{c}at}}\ {\text{"/>"}}\ {\}} | lpolyline ← { attrs points → "<polyline points=\"" cat (hpairs points) cat "\"" cat attrs cat "/>" } |
| 77 | l:a_t := { xy -> ("x" l:a_ttr f_ormat 1 s_elect xy) c_at "y" l:a_ttr f_ormat 2 s_elect xy } | {{}^{\mathrm{l}}\mathrm{\underline{a}t}}\ {\leftarrow}\ {\{}\ {\mathrm{xy}}\ {\to}\ {(}{\text{"x"}}\ {{}^{\mathrm{l}}\mathrm{\underline{a}ttr}}\ {\mathrm{\underline{f}ormat}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{xy}}{)}\ {\mathrm{\underline{c}at}}\ {\text{"y"}}\ {{}^{\mathrm{l}}\mathrm{\underline{a}ttr}}\ {\mathrm{\underline{f}ormat}}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{xy}}\ {\}} | lat ← { xy → ("x" lattr format 1 select xy) cat "y" lattr format 2 select xy } |
| 84 | l:t_ext := { attrs t -> "<text" c_at attrs c_at ">" c_at (l:e_scape t) c_at "</text>" } | {{}^{\mathrm{l}}\mathrm{\underline{t}ext}}\ {\leftarrow}\ {\{}\ {\mathrm{attrs}}\ {\mathrm{t}}\ {\to}\ {\text{"<text"}}\ {\mathrm{\underline{c}at}}\ {\mathrm{attrs}}\ {\mathrm{\underline{c}at}}\ {\text{">"}}\ {\mathrm{\underline{c}at}}\ {(}{{}^{\mathrm{l}}\mathrm{\underline{e}scape}}\ {\mathrm{t}}{)}\ {\mathrm{\underline{c}at}}\ {\text{"</text>"}}\ {\}} | ltext ← { attrs t → "<text" cat attrs cat ">" cat (lescape t) cat "</text>" } |
| 91 | l:s_pan := { color t -> "<tspan" c_at (l:f_ill color) c_at ">" c_at (l:e_scape t) c_at "</tspan>" } | {{}^{\mathrm{l}}\mathrm{\underline{s}pan}}\ {\leftarrow}\ {\{}\ {\mathrm{color}}\ {\mathrm{t}}\ {\to}\ {\text{"<tspan"}}\ {\mathrm{\underline{c}at}}\ {(}{{}^{\mathrm{l}}\mathrm{\underline{f}ill}}\ {\mathrm{color}}{)}\ {\mathrm{\underline{c}at}}\ {\text{">"}}\ {\mathrm{\underline{c}at}}\ {(}{{}^{\mathrm{l}}\mathrm{\underline{e}scape}}\ {\mathrm{t}}{)}\ {\mathrm{\underline{c}at}}\ {\text{"</tspan>"}}\ {\}} | lspan ← { color t → "<tspan" cat (lfill color) cat ">" cat (lescape t) cat "</tspan>" } |
| 98 | l:s_ized := { size inner -> "<tspan" c_at ("font-size" l:a_ttr f_ormat size) c_at ">" c_at inner c_at "</tspan>" } | {{}^{\mathrm{l}}\mathrm{\underline{s}ized}}\ {\leftarrow}\ {\{}\ {\mathrm{size}}\ {\mathrm{inner}}\ {\to}\ {\text{"<tspan"}}\ {\mathrm{\underline{c}at}}\ {(}{\text{"font-size"}}\ {{}^{\mathrm{l}}\mathrm{\underline{a}ttr}}\ {\mathrm{\underline{f}ormat}}\ {\mathrm{size}}{)}\ {\mathrm{\underline{c}at}}\ {\text{">"}}\ {\mathrm{\underline{c}at}}\ {\mathrm{inner}}\ {\mathrm{\underline{c}at}}\ {\text{"</tspan>"}}\ {\}} | lsized ← { size inner → "<tspan" cat ("font-size" lattr format size) cat ">" cat inner cat "</tspan>" } |
| 105 | l:m_arkup := { attrs inner -> "<text" c_at attrs c_at ">" c_at inner c_at "</text>" } | {{}^{\mathrm{l}}\mathrm{\underline{m}arkup}}\ {\leftarrow}\ {\{}\ {\mathrm{attrs}}\ {\mathrm{inner}}\ {\to}\ {\text{"<text"}}\ {\mathrm{\underline{c}at}}\ {\mathrm{attrs}}\ {\mathrm{\underline{c}at}}\ {\text{">"}}\ {\mathrm{\underline{c}at}}\ {\mathrm{inner}}\ {\mathrm{\underline{c}at}}\ {\text{"</text>"}}\ {\}} | lmarkup ← { attrs inner → "<text" cat attrs cat ">" cat inner cat "</text>" } |
| 114 | l:g_roup := { attrs elements -> "<g" c_at attrs c_at ">" c_at elements c_at "</g>" } | {{}^{\mathrm{l}}\mathrm{\underline{g}roup}}\ {\leftarrow}\ {\{}\ {\mathrm{attrs}}\ {\mathrm{elements}}\ {\to}\ {\text{"<g"}}\ {\mathrm{\underline{c}at}}\ {\mathrm{attrs}}\ {\mathrm{\underline{c}at}}\ {\text{">"}}\ {\mathrm{\underline{c}at}}\ {\mathrm{elements}}\ {\mathrm{\underline{c}at}}\ {\text{"</g>"}}\ {\}} | lgroup ← { attrs elements → "<g" cat attrs cat ">" cat elements cat "</g>" } |
| 120 | l:t_ranslate := { d -> "transform" l:a_ttr "translate(" c_at (f_ormat 1 s_elect d) c_at " " c_at (f_ormat 2 s_elect d) c_at ")" } | {{}^{\mathrm{l}}\mathrm{\underline{t}ranslate}}\ {\leftarrow}\ {\{}\ {\mathrm{d}}\ {\to}\ {\text{"transform"}}\ {{}^{\mathrm{l}}\mathrm{\underline{a}ttr}}\ {\text{"translate("}}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{f}ormat}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{d}}{)}\ {\mathrm{\underline{c}at}}\ {\text{" "}}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{f}ormat}}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{d}}{)}\ {\mathrm{\underline{c}at}}\ {\text{")"}}\ {\}} | ltranslate ← { d → "transform" lattr "translate(" cat (format 1 select d) cat " " cat (format 2 select d) cat ")" } |
| 127 | l:r_otate := { d -> "transform" l:a_ttr "rotate(" c_at (f_ormat d) c_at ")" } | {{}^{\mathrm{l}}\mathrm{\underline{r}otate}}\ {\leftarrow}\ {\{}\ {\mathrm{d}}\ {\to}\ {\text{"transform"}}\ {{}^{\mathrm{l}}\mathrm{\underline{a}ttr}}\ {\text{"rotate("}}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{f}ormat}}\ {\mathrm{d}}{)}\ {\mathrm{\underline{c}at}}\ {\text{")"}}\ {\}} | lrotate ← { d → "transform" lattr "rotate(" cat (format d) cat ")" } |
| 137 | l:m_atrix := { c -> | {{}^{\mathrm{l}}\mathrm{\underline{m}atrix}}\ {\leftarrow}\ {\{}\ {\mathrm{c}}\ {\to} | lmatrix ← { c → |
| 138 | tl := 1 s_elect_2 c | \ \ {\mathrm{tl}}\ {\leftarrow}\ {1}\ {{\mathrm{\underline{s}elect}}_{2}}\ {\mathrm{c}} | tl ← 1 select2 c |
| 139 | tr := (2 s_elect_2 c) - tl | \ \ {\mathrm{tr}}\ {\leftarrow}\ {(}{2}\ {{\mathrm{\underline{s}elect}}_{2}}\ {\mathrm{c}}{)}\ {-}\ {\mathrm{tl}} | tr ← (2 select2 c) − tl |
| 140 | bl := (3 s_elect_2 c) - tl | \ \ {\mathrm{bl}}\ {\leftarrow}\ {(}{3}\ {{\mathrm{\underline{s}elect}}_{2}}\ {\mathrm{c}}{)}\ {-}\ {\mathrm{tl}} | bl ← (3 select2 c) − tl |
| 141 | "transform" l:a_ttr "matrix(" c_at (f_ormat tr) c_at " " c_at (f_ormat bl) c_at " " c_at (f_ormat tl) c_at ")" | \ \ {\text{"transform"}}\ {{}^{\mathrm{l}}\mathrm{\underline{a}ttr}}\ {\text{"matrix("}}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{f}ormat}}\ {\mathrm{tr}}{)}\ {\mathrm{\underline{c}at}}\ {\text{" "}}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{f}ormat}}\ {\mathrm{bl}}{)}\ {\mathrm{\underline{c}at}}\ {\text{" "}}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{f}ormat}}\ {\mathrm{tl}}{)}\ {\mathrm{\underline{c}at}}\ {\text{")"}} | "transform" lattr "matrix(" cat (format tr) cat " " cat (format bl) cat " " cat (format tl) cat ")" |
| 142 | } | {\}} | } |
| 148 | l:s_cale := { k -> "transform" l:a_ttr "scale(" c_at (f_ormat k) c_at ")" } | {{}^{\mathrm{l}}\mathrm{\underline{s}cale}}\ {\leftarrow}\ {\{}\ {\mathrm{k}}\ {\to}\ {\text{"transform"}}\ {{}^{\mathrm{l}}\mathrm{\underline{a}ttr}}\ {\text{"scale("}}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{f}ormat}}\ {\mathrm{k}}{)}\ {\mathrm{\underline{c}at}}\ {\text{")"}}\ {\}} | lscale ← { k → "transform" lattr "scale(" cat (format k) cat ")" } |
| 158 | l:c_lip := { id points -> "<clipPath" c_at ("id" l:a_ttr id) c_at ">" c_at ("" l:p_olygon points) c_at "</clipPath>" } | {{}^{\mathrm{l}}\mathrm{\underline{c}lip}}\ {\leftarrow}\ {\{}\ {\mathrm{id}}\ {\mathrm{points}}\ {\to}\ {\text{"<clipPath"}}\ {\mathrm{\underline{c}at}}\ {(}{\text{"id"}}\ {{}^{\mathrm{l}}\mathrm{\underline{a}ttr}}\ {\mathrm{id}}{)}\ {\mathrm{\underline{c}at}}\ {\text{">"}}\ {\mathrm{\underline{c}at}}\ {(}{\text{""}}\ {{}^{\mathrm{l}}\mathrm{\underline{p}olygon}}\ {\mathrm{points}}{)}\ {\mathrm{\underline{c}at}}\ {\text{"</clipPath>"}}\ {\}} | lclip ← { id points → "<clipPath" cat ("id" lattr id) cat ">" cat ("" lpolygon points) cat "</clipPath>" } |
| 164 | l:c_lipped := { id elements -> ("clip-path" l:a_ttr "url(#" c_at id c_at ")") l:g_roup elements } | {{}^{\mathrm{l}}\mathrm{\underline{c}lipped}}\ {\leftarrow}\ {\{}\ {\mathrm{id}}\ {\mathrm{elements}}\ {\to}\ {(}{\text{"clip-path"}}\ {{}^{\mathrm{l}}\mathrm{\underline{a}ttr}}\ {\text{"url(\#"}}\ {\mathrm{\underline{c}at}}\ {\mathrm{id}}\ {\mathrm{\underline{c}at}}\ {\text{")"}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{g}roup}}\ {\mathrm{elements}}\ {\}} | lclipped ← { id elements → ("clip-path" lattr "url(#" cat id cat ")") lgroup elements } |
| 171 | l:g_radient := { id colors -> | {{}^{\mathrm{l}}\mathrm{\underline{g}radient}}\ {\leftarrow}\ {\{}\ {\mathrm{id}}\ {\mathrm{colors}}\ {\to} | lgradient ← { id colors → |
| 172 | top := d_isclose 1 s_elect colors | \ \ {\mathrm{top}}\ {\leftarrow}\ {\mathrm{\underline{d}isclose}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{colors}} | top ← disclose 1 select colors |
| 173 | bottom := d_isclose 2 s_elect colors | \ \ {\mathrm{bottom}}\ {\leftarrow}\ {\mathrm{\underline{d}isclose}}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{colors}} | bottom ← disclose 2 select colors |
| 174 | "<linearGradient" c_at ("id" l:a_ttr id) c_at " x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\"><stop offset=\"0\"" c_at ("stop-color" l:a_ttr top) c_at "/><stop offset=\"1\"" c_at ("stop-color" l:a_ttr bottom) c_at "/></linearGradient>" | \ \ {\text{"<linearGradient"}}\ {\mathrm{\underline{c}at}}\ {(}{\text{"id"}}\ {{}^{\mathrm{l}}\mathrm{\underline{a}ttr}}\ {\mathrm{id}}{)}\ {\mathrm{\underline{c}at}}\ {\text{" x1=\textbackslash{}"0\textbackslash{}" y1=\textbackslash{}"0\textbackslash{}" x2=\textbackslash{}"0\textbackslash{}" y2=\textbackslash{}"1\textbackslash{}"><stop offset=\textbackslash{}"0\textbackslash{}""}}\ {\mathrm{\underline{c}at}}\ {(}{\text{"stop-color"}}\ {{}^{\mathrm{l}}\mathrm{\underline{a}ttr}}\ {\mathrm{top}}{)}\ {\mathrm{\underline{c}at}}\ {\text{"/><stop offset=\textbackslash{}"1\textbackslash{}""}}\ {\mathrm{\underline{c}at}}\ {(}{\text{"stop-color"}}\ {{}^{\mathrm{l}}\mathrm{\underline{a}ttr}}\ {\mathrm{bottom}}{)}\ {\mathrm{\underline{c}at}}\ {\text{"/></linearGradient>"}} | "<linearGradient" cat ("id" lattr id) cat " x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\"><stop offset=\"0\"" cat ("stop-color" lattr top) cat "/><stop offset=\"1\"" cat ("stop-color" lattr bottom) cat "/></linearGradient>" |
| 175 | } | {\}} | } |
| 185 | l:p_icture := { wh elements -> | {{}^{\mathrm{l}}\mathrm{\underline{p}icture}}\ {\leftarrow}\ {\{}\ {\mathrm{wh}}\ {\mathrm{elements}}\ {\to} | lpicture ← { wh elements → |
| 186 | w := f_ormat 1 s_elect wh | \ \ {\mathrm{w}}\ {\leftarrow}\ {\mathrm{\underline{f}ormat}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{wh}} | w ← format 1 select wh |
| 187 | h := f_ormat 2 s_elect wh | \ \ {\mathrm{h}}\ {\leftarrow}\ {\mathrm{\underline{f}ormat}}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{wh}} | h ← format 2 select wh |
| 188 | "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 " c_at w c_at " " c_at h c_at "\"" c_at ("width" l:a_ttr w) c_at ("height" l:a_ttr h) c_at " role=\"img\">" c_at elements c_at "</svg>" | \ \ {\text{"<svg xmlns=\textbackslash{}"http://www.w3.org/2000/svg\textbackslash{}" viewBox=\textbackslash{}"0 0 "}}\ {\mathrm{\underline{c}at}}\ {\mathrm{w}}\ {\mathrm{\underline{c}at}}\ {\text{" "}}\ {\mathrm{\underline{c}at}}\ {\mathrm{h}}\ {\mathrm{\underline{c}at}}\ {\text{"\textbackslash{}""}}\ {\mathrm{\underline{c}at}}\ {(}{\text{"width"}}\ {{}^{\mathrm{l}}\mathrm{\underline{a}ttr}}\ {\mathrm{w}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\text{"height"}}\ {{}^{\mathrm{l}}\mathrm{\underline{a}ttr}}\ {\mathrm{h}}{)}\ {\mathrm{\underline{c}at}}\ {\text{" role=\textbackslash{}"img\textbackslash{}">"}}\ {\mathrm{\underline{c}at}}\ {\mathrm{elements}}\ {\mathrm{\underline{c}at}}\ {\text{"</svg>"}} | "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 " cat w cat " " cat h cat "\"" cat ("width" lattr w) cat ("height" lattr h) cat " role=\"img\">" cat elements cat "</svg>" |
| 189 | } | {\}} | } |
| 197 | l:p_ictureWith := { wh parts -> wh l:p_icture "<defs>" c_at (d_isclose 1 s_elect parts) c_at "</defs>" c_at d_isclose 2 s_elect parts } | {{}^{\mathrm{l}}\mathrm{\underline{p}ictureWith}}\ {\leftarrow}\ {\{}\ {\mathrm{wh}}\ {\mathrm{parts}}\ {\to}\ {\mathrm{wh}}\ {{}^{\mathrm{l}}\mathrm{\underline{p}icture}}\ {\text{"<defs>"}}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{d}isclose}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{parts}}{)}\ {\mathrm{\underline{c}at}}\ {\text{"</defs>"}}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{d}isclose}}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{parts}}\ {\}} | lpictureWith ← { wh parts → wh lpicture "<defs>" cat (disclose 1 select parts) cat "</defs>" cat disclose 2 select parts } |
| 203 | l:GRAY := []S_CALE 1 | {{}^{\mathrm{l}}\mathrm{GRAY}}\ {\leftarrow}\ {\square \mathrm{\underline{S}CALE}}\ {1} | lGRAY ← □SCALE 1 |
| 207 | l:HEAT := []S_CALE 2 | {{}^{\mathrm{l}}\mathrm{HEAT}}\ {\leftarrow}\ {\square \mathrm{\underline{S}CALE}}\ {2} | lHEAT ← □SCALE 2 |
| 214 | l:DIVERGING := []S_CALE 3 | {{}^{\mathrm{l}}\mathrm{DIVERGING}}\ {\leftarrow}\ {\square \mathrm{\underline{S}CALE}}\ {3} | lDIVERGING ← □SCALE 3 |
| 219 | h:e_sc := { c -> c = f_irst "&" ? "&"; c = f_irst "<" ? "<"; c = f_irst ">" ? ">"; c = f_irst "\"" ? """; c } | {{}^{\mathrm{h}}\mathrm{\underline{e}sc}}\ {\leftarrow}\ {\{}\ {\mathrm{c}}\ {\to}\ {\mathrm{c}}\ {=}\ {\mathrm{\underline{f}irst}}\ {\text{"\&"}}\ {?}\ {\text{"\&"}}{\diamond}\ {\mathrm{c}}\ {=}\ {\mathrm{\underline{f}irst}}\ {\text{"<"}}\ {?}\ {\text{"\<"}}{\diamond}\ {\mathrm{c}}\ {=}\ {\mathrm{\underline{f}irst}}\ {\text{">"}}\ {?}\ {\text{"\>"}}{\diamond}\ {\mathrm{c}}\ {=}\ {\mathrm{\underline{f}irst}}\ {\text{"\textbackslash{}""}}\ {?}\ {\text{"\""}}{\diamond}\ {\mathrm{c}}\ {\}} | hesc ← { c → c = first "&" ? "&"⋄ c = first "<" ? "<"⋄ c = first ">" ? ">"⋄ c = first "\"" ? """⋄ c } |
| 222 | h:j_oin := { b -> | {{}^{\mathrm{h}}\mathrm{\underline{j}oin}}\ {\leftarrow}\ {\{}\ {\mathrm{b}}\ {\to} | hjoin ← { b → |
| 223 | 0 = t_ally b ? "" | \ \ {0}\ {=}\ {\mathrm{\underline{t}ally}}\ {\mathrm{b}}\ {?}\ {\text{""}} | 0 = tally b ? "" |
| 224 | d_isclose '{ x y -> e_nclose (d_isclose x) c_at d_isclose y } r_/ b | \ \ {\mathrm{\underline{d}isclose}}\ {\text{'}}{\{}\ {\mathrm{x}}\ {\mathrm{y}}\ {\to}\ {\mathrm{\underline{e}nclose}}\ {(}{\mathrm{\underline{d}isclose}}\ {\mathrm{x}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{d}isclose}}\ {\mathrm{y}}\ {\}}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{b}} | disclose ’{ x y → enclose (disclose x) cat disclose y } r/ b |
| 225 | } | {\}} | } |
| 228 | h:p_airs := { points -> | {{}^{\mathrm{h}}\mathrm{\underline{p}airs}}\ {\leftarrow}\ {\{}\ {\mathrm{points}}\ {\to} | hpairs ← { points → |
| 229 | xs := 'f_ormat m_ap 1 s_elect points | \ \ {\mathrm{xs}}\ {\leftarrow}\ {\text{'}}{\mathrm{\underline{f}ormat}}\ {\mathrm{\underline{m}ap}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{points}} | xs ← ’format map 1 select points |
| 230 | ys := 'f_ormat m_ap 2 s_elect points | \ \ {\mathrm{ys}}\ {\leftarrow}\ {\text{'}}{\mathrm{\underline{f}ormat}}\ {\mathrm{\underline{m}ap}}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{points}} | ys ← ’format map 2 select points |
| 231 | ps := xs '{ x y -> e_nclose (d_isclose x) c_at "," c_at d_isclose y } e_ach ys | \ \ {\mathrm{ps}}\ {\leftarrow}\ {\mathrm{xs}}\ {\text{'}}{\{}\ {\mathrm{x}}\ {\mathrm{y}}\ {\to}\ {\mathrm{\underline{e}nclose}}\ {(}{\mathrm{\underline{d}isclose}}\ {\mathrm{x}}{)}\ {\mathrm{\underline{c}at}}\ {\text{","}}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{d}isclose}}\ {\mathrm{y}}\ {\}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{ys}} | ps ← xs ’{ x y → enclose (disclose x) cat "," cat disclose y } each ys |
| 232 | d_isclose '{ x y -> e_nclose (d_isclose x) c_at " " c_at d_isclose y } r_/ ps | \ \ {\mathrm{\underline{d}isclose}}\ {\text{'}}{\{}\ {\mathrm{x}}\ {\mathrm{y}}\ {\to}\ {\mathrm{\underline{e}nclose}}\ {(}{\mathrm{\underline{d}isclose}}\ {\mathrm{x}}{)}\ {\mathrm{\underline{c}at}}\ {\text{" "}}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{d}isclose}}\ {\mathrm{y}}\ {\}}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{ps}} | disclose ’{ x y → enclose (disclose x) cat " " cat disclose y } r/ ps |
| 233 | } | {\}} | } |
| 22 | l:s_how := { s -> 3 6 r_eshape (1 + (s + 2) '* t_able 0 1) s_elect " O.X" } | {{}^{\mathrm{l}}\mathrm{\underline{s}how}}\ {\leftarrow}\ {\{}\ {\mathrm{s}}\ {\to}\ {3}\ {6}\ {\mathrm{\underline{r}eshape}}\ {(}{1}\ {+}\ {(}{\mathrm{s}}\ {+}\ {2}{)}\ {\text{'}}{\times}\ {\mathrm{\underline{t}able}}\ {0}\ {1}{)}\ {\mathrm{\underline{s}elect}}\ {\text{" O.X"}}\ {\}} | lshow ← { s → 3 6 reshape (1 + (s + 2) ’× table 0 1) select " O.X" } |
| 26 | l:lines := 8 9 r_eshape 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 1 0 0 0 1 0 0 0 1 0 0 1 0 1 0 1 0 0 | {{}^{\mathrm{l}}\mathrm{lines}}\ {\leftarrow}\ {8}\ {9}\ {\mathrm{\underline{r}eshape}}\ {1}\ {1}\ {1}\ {0}\ {0}\ {0}\ {0}\ {0}\ {0}\ {0}\ {0}\ {0}\ {1}\ {1}\ {1}\ {0}\ {0}\ {0}\ {0}\ {0}\ {0}\ {0}\ {0}\ {0}\ {1}\ {1}\ {1}\ {1}\ {0}\ {0}\ {1}\ {0}\ {0}\ {1}\ {0}\ {0}\ {0}\ {1}\ {0}\ {0}\ {1}\ {0}\ {0}\ {1}\ {0}\ {0}\ {0}\ {1}\ {0}\ {0}\ {1}\ {0}\ {0}\ {1}\ {1}\ {0}\ {0}\ {0}\ {1}\ {0}\ {0}\ {0}\ {1}\ {0}\ {0}\ {1}\ {0}\ {1}\ {0}\ {1}\ {0}\ {0} | llines ← 8 9 reshape 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0 0 1 0 0 1 0 0 1 1 0 0 0 1 0 0 0 1 0 0 1 0 1 0 1 0 0 |
| 37 | l:o_utcome := { s -> | {{}^{\mathrm{l}}\mathrm{\underline{o}utcome}}\ {\leftarrow}\ {\{}\ {\mathrm{s}}\ {\to} | loutcome ← { s → |
| 38 | l := l:lines '+ '* i_nner s | \ \ {\mathrm{l}}\ {\leftarrow}\ {{}^{\mathrm{l}}\mathrm{lines}}\ {\text{'}}{+}\ {\text{'}}{\times}\ {\mathrm{\underline{i}nner}}\ {\mathrm{s}} | l ← llines ’+ ’× inner s |
| 39 | 3 m_ember? l ? 1; -3 m_ember? l ? -1; 0 m_ember? s ? 0; 2 | \ \ {3}\ {\mathrm{\underline{m}ember}{?}}\ {\mathrm{l}}\ {?}\ {1}{\diamond}\ {-3}\ {\mathrm{\underline{m}ember}{?}}\ {\mathrm{l}}\ {?}\ {-1}{\diamond}\ {0}\ {\mathrm{\underline{m}ember}{?}}\ {\mathrm{s}}\ {?}\ {0}{\diamond}\ {2} | 3 member? l ? 1⋄ −3 member? l ? −1⋄ 0 member? s ? 0⋄ 2 |
| 40 | } | {\}} | } |
| 46 | l:symmetries := 8 9 r_eshape 1 2 3 4 5 6 7 8 9 7 4 1 8 5 2 9 6 3 9 8 7 6 5 4 3 2 1 3 6 9 2 5 8 1 4 7 3 2 1 6 5 4 9 8 7 7 8 9 4 5 6 1 2 3 1 4 7 2 5 8 3 6 9 9 6 3 8 5 2 7 4 1 | {{}^{\mathrm{l}}\mathrm{symmetries}}\ {\leftarrow}\ {8}\ {9}\ {\mathrm{\underline{r}eshape}}\ {1}\ {2}\ {3}\ {4}\ {5}\ {6}\ {7}\ {8}\ {9}\ {7}\ {4}\ {1}\ {8}\ {5}\ {2}\ {9}\ {6}\ {3}\ {9}\ {8}\ {7}\ {6}\ {5}\ {4}\ {3}\ {2}\ {1}\ {3}\ {6}\ {9}\ {2}\ {5}\ {8}\ {1}\ {4}\ {7}\ {3}\ {2}\ {1}\ {6}\ {5}\ {4}\ {9}\ {8}\ {7}\ {7}\ {8}\ {9}\ {4}\ {5}\ {6}\ {1}\ {2}\ {3}\ {1}\ {4}\ {7}\ {2}\ {5}\ {8}\ {3}\ {6}\ {9}\ {9}\ {6}\ {3}\ {8}\ {5}\ {2}\ {7}\ {4}\ {1} | lsymmetries ← 8 9 reshape 1 2 3 4 5 6 7 8 9 7 4 1 8 5 2 9 6 3 9 8 7 6 5 4 3 2 1 3 6 9 2 5 8 1 4 7 3 2 1 6 5 4 9 8 7 7 8 9 4 5 6 1 2 3 1 4 7 2 5 8 3 6 9 9 6 3 8 5 2 7 4 1 |
| 55 | l:c_ode := { s -> 'm_in r_/ 3 d_ecode o_\ 1 + l:symmetries s_elect s } | {{}^{\mathrm{l}}\mathrm{\underline{c}ode}}\ {\leftarrow}\ {\{}\ {\mathrm{s}}\ {\to}\ {\text{'}}{\mathrm{\underline{m}in}}\ {\mathrm{\underline{r}}{/}}\ {3}\ {\mathrm{\underline{d}ecode}}\ {\mathrm{\underline{o}}{\backslash}}\ {1}\ {+}\ {{}^{\mathrm{l}}\mathrm{symmetries}}\ {\mathrm{\underline{s}elect}}\ {\mathrm{s}}\ {\}} | lcode ← { s → ’min r/ 3 decode o\ 1 + lsymmetries select s } |
| 62 | l:empty := 2 0 r_eshape 0.5 | {{}^{\mathrm{l}}\mathrm{empty}}\ {\leftarrow}\ {2}\ {0}\ {\mathrm{\underline{r}eshape}}\ {0.5} | lempty ← 2 0 reshape 0.5 |
| 69 | l:v_alues := { m c -> ((1 s_elect m) i_ndexOf c) s_elect (2 s_elect m) c_at 0.5 } | {{}^{\mathrm{l}}\mathrm{\underline{v}alues}}\ {\leftarrow}\ {\{}\ {\mathrm{m}}\ {\mathrm{c}}\ {\to}\ {(}{(}{1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{m}}{)}\ {\mathrm{\underline{i}ndexOf}}\ {\mathrm{c}}{)}\ {\mathrm{\underline{s}elect}}\ {(}{2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{m}}{)}\ {\mathrm{\underline{c}at}}\ {0.5}\ {\}} | lvalues ← { m c → ((1 select m) indexOf c) select (2 select m) cat 0.5 } |
| 75 | l:v_alue := { m s -> m l:v_alues f_loat l:c_ode s } | {{}^{\mathrm{l}}\mathrm{\underline{v}alue}}\ {\leftarrow}\ {\{}\ {\mathrm{m}}\ {\mathrm{s}}\ {\to}\ {\mathrm{m}}\ {{}^{\mathrm{l}}\mathrm{\underline{v}alues}}\ {\mathrm{\underline{f}loat}}\ {{}^{\mathrm{l}}\mathrm{\underline{c}ode}}\ {\mathrm{s}}\ {\}} | lvalue ← { m s → m lvalues float lcode s } |
| 82 | l:a_fter := { s a -> s + (1 - 2 * '+ r_/ s) * (r_ange 9) = a } | {{}^{\mathrm{l}}\mathrm{\underline{a}fter}}\ {\leftarrow}\ {\{}\ {\mathrm{s}}\ {\mathrm{a}}\ {\to}\ {\mathrm{s}}\ {+}\ {(}{1}\ {-}\ {2}\ {\times}\ {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{s}}{)}\ {\times}\ {(}{\mathrm{\underline{r}ange}}\ {9}{)}\ {=}\ {\mathrm{a}}\ {\}} | lafter ← { s a → s + (1 − 2 × ’+ r/ s) × (range 9) = a } |
| 88 | l:c_hoose := { m s -> | {{}^{\mathrm{l}}\mathrm{\underline{c}hoose}}\ {\leftarrow}\ {\{}\ {\mathrm{m}}\ {\mathrm{s}}\ {\to} | lchoose ← { m s → |
| 89 | p := w_here s = 0 | \ \ {\mathrm{p}}\ {\leftarrow}\ {\mathrm{\underline{w}here}}\ {\mathrm{s}}\ {=}\ {0} | p ← where s = 0 |
| 90 | v := m l:v_alues '{ a -> f_loat l:c_ode s l:a_fter a } e_ach p | \ \ {\mathrm{v}}\ {\leftarrow}\ {\mathrm{m}}\ {{}^{\mathrm{l}}\mathrm{\underline{v}alues}}\ {\text{'}}{\{}\ {\mathrm{a}}\ {\to}\ {\mathrm{\underline{f}loat}}\ {{}^{\mathrm{l}}\mathrm{\underline{c}ode}}\ {\mathrm{s}}\ {{}^{\mathrm{l}}\mathrm{\underline{a}fter}}\ {\mathrm{a}}\ {\}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{p}} | v ← m lvalues ’{ a → float lcode s lafter a } each p |
| 91 | (v i_ndexOf 'm_ax r_/ v) s_elect p | \ \ {(}{\mathrm{v}}\ {\mathrm{\underline{i}ndexOf}}\ {\text{'}}{\mathrm{\underline{m}ax}}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{v}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{p}} | (v indexOf ’max r/ v) select p |
| 92 | } | {\}} | } |
| 97 | h:p_ick! := { m s -> | {{}^{\mathrm{h}}\mathrm{\underline{p}ick}{!}}\ {\leftarrow}\ {\{}\ {\mathrm{m}}\ {\mathrm{s}}\ {\to} | hpick! ← { m s → |
| 98 | p := w_here s = 0 | \ \ {\mathrm{p}}\ {\leftarrow}\ {\mathrm{\underline{w}here}}\ {\mathrm{s}}\ {=}\ {0} | p ← where s = 0 |
| 99 | (r_oll! 10) = 1 ? (r_oll! t_ally p) s_elect p; m l:c_hoose s | \ \ {(}{\mathrm{\underline{r}oll}{!}}\ {10}{)}\ {=}\ {1}\ {?}\ {(}{\mathrm{\underline{r}oll}{!}}\ {\mathrm{\underline{t}ally}}\ {\mathrm{p}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{p}}{\diamond}\ {\mathrm{m}}\ {{}^{\mathrm{l}}\mathrm{\underline{c}hoose}}\ {\mathrm{s}} | (roll! 10) = 1 ? (roll! tally p) select p⋄ m lchoose s |
| 100 | } | {\}} | } |
| 103 | h:p_lay! := { m g -> | {{}^{\mathrm{h}}\mathrm{\underline{p}lay}{!}}\ {\leftarrow}\ {\{}\ {\mathrm{m}}\ {\mathrm{g}}\ {\to} | hplay! ← { m g → |
| 104 | s := (t_ally g) s_elect g | \ \ {\mathrm{s}}\ {\leftarrow}\ {(}{\mathrm{\underline{t}ally}}\ {\mathrm{g}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{g}} | s ← (tally g) select g |
| 105 | played := g c_at 1 9 r_eshape s l:a_fter m h:p_ick! s | \ \ {\mathrm{played}}\ {\leftarrow}\ {\mathrm{g}}\ {\mathrm{\underline{c}at}}\ {1}\ {9}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{s}}\ {{}^{\mathrm{l}}\mathrm{\underline{a}fter}}\ {\mathrm{m}}\ {{}^{\mathrm{h}}\mathrm{\underline{p}ick}{!}}\ {\mathrm{s}} | played ← g cat 1 9 reshape s lafter m hpick! s |
| 106 | 0 = l:o_utcome (t_ally played) s_elect played ? m h:p_lay! played; played | \ \ {0}\ {=}\ {{}^{\mathrm{l}}\mathrm{\underline{o}utcome}}\ {(}{\mathrm{\underline{t}ally}}\ {\mathrm{played}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{played}}\ {?}\ {\mathrm{m}}\ {{}^{\mathrm{h}}\mathrm{\underline{p}lay}{!}}\ {\mathrm{played}}{\diamond}\ {\mathrm{played}} | 0 = loutcome (tally played) select played ? m hplay! played⋄ played |
| 107 | } | {\}} | } |
| 110 | l:g_ame! := { m -> m h:p_lay! 1 9 r_eshape 0 } | {{}^{\mathrm{l}}\mathrm{\underline{g}ame}{!}}\ {\leftarrow}\ {\{}\ {\mathrm{m}}\ {\to}\ {\mathrm{m}}\ {{}^{\mathrm{h}}\mathrm{\underline{p}lay}{!}}\ {1}\ {9}\ {\mathrm{\underline{r}eshape}}\ {0}\ {\}} | lgame! ← { m → m hplay! 1 9 reshape 0 } |
| 116 | h:r_esult := { g j -> | {{}^{\mathrm{h}}\mathrm{\underline{r}esult}}\ {\leftarrow}\ {\{}\ {\mathrm{g}}\ {\mathrm{j}}\ {\to} | hresult ← { g j → |
| 117 | w := l:o_utcome (t_ally g) s_elect g | \ \ {\mathrm{w}}\ {\leftarrow}\ {{}^{\mathrm{l}}\mathrm{\underline{o}utcome}}\ {(}{\mathrm{\underline{t}ally}}\ {\mathrm{g}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{g}} | w ← loutcome (tally g) select g |
| 118 | x := '+ r_/ (j + 1) s_elect g | \ \ {\mathrm{x}}\ {\leftarrow}\ {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {(}{\mathrm{j}}\ {+}\ {1}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{g}} | x ← ’+ r/ (j + 1) select g |
| 119 | (0.5 * f_loat w = 2) + f_loat w = (2 * x) - 1 | \ \ {(}{0.5}\ {\times}\ {\mathrm{\underline{f}loat}}\ {\mathrm{w}}\ {=}\ {2}{)}\ {+}\ {\mathrm{\underline{f}loat}}\ {\mathrm{w}}\ {=}\ {(}{2}\ {\times}\ {\mathrm{x}}{)}\ {-}\ {1} | (0.5 × float w = 2) + float w = (2 × x) − 1 |
| 120 | } | {\}} | } |
| 124 | h:t_arget := { g m j -> | {{}^{\mathrm{h}}\mathrm{\underline{t}arget}}\ {\leftarrow}\ {\{}\ {\mathrm{g}}\ {\mathrm{m}}\ {\mathrm{j}}\ {\to} | htarget ← { g m j → |
| 125 | j >= (t_ally g) - 2 ? g h:r_esult j; 0.9 * m l:v_alue (j + 3) s_elect g | \ \ {\mathrm{j}}\ {\geq}\ {(}{\mathrm{\underline{t}ally}}\ {\mathrm{g}}{)}\ {-}\ {2}\ {?}\ {\mathrm{g}}\ {{}^{\mathrm{h}}\mathrm{\underline{r}esult}}\ {\mathrm{j}}{\diamond}\ {0.9}\ {\times}\ {\mathrm{m}}\ {{}^{\mathrm{l}}\mathrm{\underline{v}alue}}\ {(}{\mathrm{j}}\ {+}\ {3}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{g}} | j ≥ (tally g) − 2 ? g hresult j⋄ 0.9 × m lvalue (j + 3) select g |
| 126 | } | {\}} | } |
| 129 | h:b_ack := { g m j -> | {{}^{\mathrm{h}}\mathrm{\underline{b}ack}}\ {\leftarrow}\ {\{}\ {\mathrm{g}}\ {\mathrm{m}}\ {\mathrm{j}}\ {\to} | hback ← { g m j → |
| 130 | k := (1 s_elect m) i_ndexOf f_loat l:c_ode (j + 1) s_elect g | \ \ {\mathrm{k}}\ {\leftarrow}\ {(}{1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{m}}{)}\ {\mathrm{\underline{i}ndexOf}}\ {\mathrm{\underline{f}loat}}\ {{}^{\mathrm{l}}\mathrm{\underline{c}ode}}\ {(}{\mathrm{j}}\ {+}\ {1}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{g}} | k ← (1 select m) indexOf float lcode (j + 1) select g |
| 131 | d := 0.2 * ((g h:t_arget m)_ j) - m l:v_alue (j + 1) s_elect g | \ \ {\mathrm{d}}\ {\leftarrow}\ {0.2}\ {\times}\ {(}{\underline{(}}{\mathrm{g}}\ {{}^{\mathrm{h}}\mathrm{\underline{t}arget}}\ {\mathrm{m}}{\underline{)}}\ {\mathrm{j}}{)}\ {-}\ {\mathrm{m}}\ {{}^{\mathrm{l}}\mathrm{\underline{v}alue}}\ {(}{\mathrm{j}}\ {+}\ {1}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{g}} | d ← 0.2 × ((g htarget m) j) − m lvalue (j + 1) select g |
| 132 | learned := m + (0.0 c_at d) '* t_able f_loat (r_ange t_ally 1 s_elect m) = k | \ \ {\mathrm{learned}}\ {\leftarrow}\ {\mathrm{m}}\ {+}\ {(}{0.0}\ {\mathrm{\underline{c}at}}\ {\mathrm{d}}{)}\ {\text{'}}{\times}\ {\mathrm{\underline{t}able}}\ {\mathrm{\underline{f}loat}}\ {(}{\mathrm{\underline{r}ange}}\ {\mathrm{\underline{t}ally}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{m}}{)}\ {=}\ {\mathrm{k}} | learned ← m + (0.0 cat d) ’× table float (range tally 1 select m) = k |
| 133 | j = 1 ? learned; (g h:b_ack learned)_ j - 1 | \ \ {\mathrm{j}}\ {=}\ {1}\ {?}\ {\mathrm{learned}}{\diamond}\ {\underline{(}}{\mathrm{g}}\ {{}^{\mathrm{h}}\mathrm{\underline{b}ack}}\ {\mathrm{learned}}{\underline{)}}\ {\mathrm{j}}\ {-}\ {1} | j = 1 ? learned⋄ (g hback learned) j − 1 |
| 134 | } | {\}} | } |
| 137 | h:m_eet := { m g -> | {{}^{\mathrm{h}}\mathrm{\underline{m}eet}}\ {\leftarrow}\ {\{}\ {\mathrm{m}}\ {\mathrm{g}}\ {\to} | hmeet ← { m g → |
| 138 | c := u_nique '{ j -> f_loat l:c_ode j s_elect g } e_ach 1 d_rop r_ange t_ally g | \ \ {\mathrm{c}}\ {\leftarrow}\ {\mathrm{\underline{u}nique}}\ {\text{'}}{\{}\ {\mathrm{j}}\ {\to}\ {\mathrm{\underline{f}loat}}\ {{}^{\mathrm{l}}\mathrm{\underline{c}ode}}\ {\mathrm{j}}\ {\mathrm{\underline{s}elect}}\ {\mathrm{g}}\ {\}}\ {\mathrm{\underline{e}ach}}\ {1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{\underline{r}ange}}\ {\mathrm{\underline{t}ally}}\ {\mathrm{g}} | c ← unique ’{ j → float lcode j select g } each 1 drop range tally g |
| 139 | n := (w_here 0 = c m_ember? 1 s_elect m) s_elect c | \ \ {\mathrm{n}}\ {\leftarrow}\ {(}{\mathrm{\underline{w}here}}\ {0}\ {=}\ {\mathrm{c}}\ {\mathrm{\underline{m}ember}{?}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{m}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{c}} | n ← (where 0 = c member? 1 select m) select c |
| 140 | k := (t_ally 1 s_elect m) + t_ally n | \ \ {\mathrm{k}}\ {\leftarrow}\ {(}{\mathrm{\underline{t}ally}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{m}}{)}\ {+}\ {\mathrm{\underline{t}ally}}\ {\mathrm{n}} | k ← (tally 1 select m) + tally n |
| 141 | (2 c_at k) r_eshape ((1 s_elect m) c_at n) c_at (2 s_elect m) c_at 0.5 + 0.0 * n | \ \ {(}{2}\ {\mathrm{\underline{c}at}}\ {\mathrm{k}}{)}\ {\mathrm{\underline{r}eshape}}\ {(}{(}{1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{m}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{n}}{)}\ {\mathrm{\underline{c}at}}\ {(}{2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{m}}{)}\ {\mathrm{\underline{c}at}}\ {0.5}\ {+}\ {0.0}\ {\times}\ {\mathrm{n}} | (2 cat k) reshape ((1 select m) cat n) cat (2 select m) cat 0.5 + 0.0 × n |
| 142 | } | {\}} | } |
| 149 | l:l_earn := { m g -> (g h:b_ack m h:m_eet g)_ (t_ally g) - 1 } | {{}^{\mathrm{l}}\mathrm{\underline{l}earn}}\ {\leftarrow}\ {\{}\ {\mathrm{m}}\ {\mathrm{g}}\ {\to}\ {\underline{(}}{\mathrm{g}}\ {{}^{\mathrm{h}}\mathrm{\underline{b}ack}}\ {\mathrm{m}}\ {{}^{\mathrm{h}}\mathrm{\underline{m}eet}}\ {\mathrm{g}}{\underline{)}}\ {(}{\mathrm{\underline{t}ally}}\ {\mathrm{g}}{)}\ {-}\ {1}\ {\}} | llearn ← { m g → (g hback m hmeet g) (tally g) − 1 } |
| 160 | h:r_ound! := { m -> m l:l_earn l:g_ame! m } | {{}^{\mathrm{h}}\mathrm{\underline{r}ound}{!}}\ {\leftarrow}\ {\{}\ {\mathrm{m}}\ {\to}\ {\mathrm{m}}\ {{}^{\mathrm{l}}\mathrm{\underline{l}earn}}\ {{}^{\mathrm{l}}\mathrm{\underline{g}ame}{!}}\ {\mathrm{m}}\ {\}} | hround! ← { m → m llearn lgame! m } |
| 163 | h:l_oop! := { n m -> | {{}^{\mathrm{h}}\mathrm{\underline{l}oop}{!}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\mathrm{m}}\ {\to} | hloop! ← { n m → |
| 164 | k := 250 m_in n | \ \ {\mathrm{k}}\ {\leftarrow}\ {250}\ {\mathrm{\underline{m}in}}\ {\mathrm{n}} | k ← 250 min n |
| 165 | trained := k 'h:r_ound! p_ower m | \ \ {\mathrm{trained}}\ {\leftarrow}\ {\mathrm{k}}\ {\text{'}}{{}^{\mathrm{h}}\mathrm{\underline{r}ound}{!}}\ {\mathrm{\underline{p}ower}}\ {\mathrm{m}} | trained ← k ’hround! power m |
| 166 | _ := p_rint! (n - k) c_at t_ally 1 s_elect trained | \ \ {\_}\ {\leftarrow}\ {\mathrm{\underline{p}rint}{!}}\ {(}{\mathrm{n}}\ {-}\ {\mathrm{k}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{t}ally}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{trained}} | _ ← print! (n − k) cat tally 1 select trained |
| 167 | n = k ? trained; (n - k) h:l_oop! trained | \ \ {\mathrm{n}}\ {=}\ {\mathrm{k}}\ {?}\ {\mathrm{trained}}{\diamond}\ {(}{\mathrm{n}}\ {-}\ {\mathrm{k}}{)}\ {{}^{\mathrm{h}}\mathrm{\underline{l}oop}{!}}\ {\mathrm{trained}} | n = k ? trained⋄ (n − k) hloop! trained |
| 168 | } | {\}} | } |
| 173 | l:t_rain! := { n m -> | {{}^{\mathrm{l}}\mathrm{\underline{t}rain}{!}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\mathrm{m}}\ {\to} | ltrain! ← { n m → |
| 174 | _ := p_rint! "games to go, positions known:" | \ \ {\_}\ {\leftarrow}\ {\mathrm{\underline{p}rint}{!}}\ {\text{"games to go, positions known:"}} | _ ← print! "games to go, positions known:" |
| 175 | n h:l_oop! m | \ \ {\mathrm{n}}\ {{}^{\mathrm{h}}\mathrm{\underline{l}oop}{!}}\ {\mathrm{m}} | n hloop! m |
| 176 | } | {\}} | } |
| 183 | h:t_urn! := { m side s -> | {{}^{\mathrm{h}}\mathrm{\underline{t}urn}{!}}\ {\leftarrow}\ {\{}\ {\mathrm{m}}\ {\mathrm{side}}\ {\mathrm{s}}\ {\to} | hturn! ← { m side s → |
| 184 | p := w_here s = 0 | \ \ {\mathrm{p}}\ {\leftarrow}\ {\mathrm{\underline{w}here}}\ {\mathrm{s}}\ {=}\ {0} | p ← where s = 0 |
| 185 | (1 - 2 * '+ r_/ s) = side ? m l:c_hoose s; (r_oll! t_ally p) s_elect p | \ \ {(}{1}\ {-}\ {2}\ {\times}\ {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{s}}{)}\ {=}\ {\mathrm{side}}\ {?}\ {\mathrm{m}}\ {{}^{\mathrm{l}}\mathrm{\underline{c}hoose}}\ {\mathrm{s}}{\diamond}\ {(}{\mathrm{\underline{r}oll}{!}}\ {\mathrm{\underline{t}ally}}\ {\mathrm{p}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{p}} | (1 − 2 × ’+ r/ s) = side ? m lchoose s⋄ (roll! tally p) select p |
| 186 | } | {\}} | } |
| 189 | h:v_ersus! := { m side s -> | {{}^{\mathrm{h}}\mathrm{\underline{v}ersus}{!}}\ {\leftarrow}\ {\{}\ {\mathrm{m}}\ {\mathrm{side}}\ {\mathrm{s}}\ {\to} | hversus! ← { m side s → |
| 190 | played := s l:a_fter ((m h:t_urn! side)_ s) | \ \ {\mathrm{played}}\ {\leftarrow}\ {\mathrm{s}}\ {{}^{\mathrm{l}}\mathrm{\underline{a}fter}}\ {(}{\underline{(}}{\mathrm{m}}\ {{}^{\mathrm{h}}\mathrm{\underline{t}urn}{!}}\ {\mathrm{side}}{\underline{)}}\ {\mathrm{s}}{)} | played ← s lafter ((m hturn! side) s) |
| 191 | w := l:o_utcome played | \ \ {\mathrm{w}}\ {\leftarrow}\ {{}^{\mathrm{l}}\mathrm{\underline{o}utcome}}\ {\mathrm{played}} | w ← loutcome played |
| 192 | w = 0 ? ((m h:v_ersus! side)_ played); w | \ \ {\mathrm{w}}\ {=}\ {0}\ {?}\ {(}{\underline{(}}{\mathrm{m}}\ {{}^{\mathrm{h}}\mathrm{\underline{v}ersus}{!}}\ {\mathrm{side}}{\underline{)}}\ {\mathrm{played}}{)}{\diamond}\ {\mathrm{w}} | w = 0 ? ((m hversus! side) played)⋄ w |
| 193 | } | {\}} | } |
| 196 | h:c_ount! := { m side n -> | {{}^{\mathrm{h}}\mathrm{\underline{c}ount}{!}}\ {\leftarrow}\ {\{}\ {\mathrm{m}}\ {\mathrm{side}}\ {\mathrm{n}}\ {\to} | hcount! ← { m side n → |
| 197 | w := '{ _u -> ((m h:v_ersus! side)_ 9 r_eshape 0) } e_ach r_ange n | \ \ {\mathrm{w}}\ {\leftarrow}\ {\text{'}}{\{}\ {\_\mathrm{u}}\ {\to}\ {(}{\underline{(}}{\mathrm{m}}\ {{}^{\mathrm{h}}\mathrm{\underline{v}ersus}{!}}\ {\mathrm{side}}{\underline{)}}\ {9}\ {\mathrm{\underline{r}eshape}}\ {0}{)}\ {\}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{\underline{r}ange}}\ {\mathrm{n}} | w ← ’{ _u → ((m hversus! side) 9 reshape 0) } each range n |
| 198 | '+ r_/ w '= t_able side c_at (0 - side) c_at 2 | \ \ {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{w}}\ {\text{'}}{=}\ {\mathrm{\underline{t}able}}\ {\mathrm{side}}\ {\mathrm{\underline{c}at}}\ {(}{0}\ {-}\ {\mathrm{side}}{)}\ {\mathrm{\underline{c}at}}\ {2} | ’+ r/ w ’= table side cat (0 − side) cat 2 |
| 199 | } | {\}} | } |
| 202 | l:t_rial! := { n m -> 2 3 r_eshape ((m h:c_ount! 1)_ n) c_at (m h:c_ount! -1)_ n } | {{}^{\mathrm{l}}\mathrm{\underline{t}rial}{!}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\mathrm{m}}\ {\to}\ {2}\ {3}\ {\mathrm{\underline{r}eshape}}\ {(}{\underline{(}}{\mathrm{m}}\ {{}^{\mathrm{h}}\mathrm{\underline{c}ount}{!}}\ {1}{\underline{)}}\ {\mathrm{n}}{)}\ {\mathrm{\underline{c}at}}\ {\underline{(}}{\mathrm{m}}\ {{}^{\mathrm{h}}\mathrm{\underline{c}ount}{!}}\ {-1}{\underline{)}}\ {\mathrm{n}}\ {\}} | ltrial! ← { n m → 2 3 reshape ((m hcount! 1) n) cat (m hcount! −1) n } |
| 208 | h:g_reedy := { m g -> | {{}^{\mathrm{h}}\mathrm{\underline{g}reedy}}\ {\leftarrow}\ {\{}\ {\mathrm{m}}\ {\mathrm{g}}\ {\to} | hgreedy ← { m g → |
| 209 | s := (t_ally g) s_elect g | \ \ {\mathrm{s}}\ {\leftarrow}\ {(}{\mathrm{\underline{t}ally}}\ {\mathrm{g}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{g}} | s ← (tally g) select g |
| 210 | played := g c_at 1 9 r_eshape s l:a_fter m l:c_hoose s | \ \ {\mathrm{played}}\ {\leftarrow}\ {\mathrm{g}}\ {\mathrm{\underline{c}at}}\ {1}\ {9}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{s}}\ {{}^{\mathrm{l}}\mathrm{\underline{a}fter}}\ {\mathrm{m}}\ {{}^{\mathrm{l}}\mathrm{\underline{c}hoose}}\ {\mathrm{s}} | played ← g cat 1 9 reshape s lafter m lchoose s |
| 211 | 0 = l:o_utcome (t_ally played) s_elect played ? m h:g_reedy played; played | \ \ {0}\ {=}\ {{}^{\mathrm{l}}\mathrm{\underline{o}utcome}}\ {(}{\mathrm{\underline{t}ally}}\ {\mathrm{played}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{played}}\ {?}\ {\mathrm{m}}\ {{}^{\mathrm{h}}\mathrm{\underline{g}reedy}}\ {\mathrm{played}}{\diamond}\ {\mathrm{played}} | 0 = loutcome (tally played) select played ? m hgreedy played⋄ played |
| 212 | } | {\}} | } |
| 215 | l:b_est := { m -> m h:g_reedy 1 9 r_eshape 0 } | {{}^{\mathrm{l}}\mathrm{\underline{b}est}}\ {\leftarrow}\ {\{}\ {\mathrm{m}}\ {\to}\ {\mathrm{m}}\ {{}^{\mathrm{h}}\mathrm{\underline{g}reedy}}\ {1}\ {9}\ {\mathrm{\underline{r}eshape}}\ {0}\ {\}} | lbest ← { m → m hgreedy 1 9 reshape 0 } |
| 219 | l:b_oards := { g -> | {{}^{\mathrm{l}}\mathrm{\underline{b}oards}}\ {\leftarrow}\ {\{}\ {\mathrm{g}}\ {\to} | lboards ← { g → |
| 220 | k := t_ally g | \ \ {\mathrm{k}}\ {\leftarrow}\ {\mathrm{\underline{t}ally}}\ {\mathrm{g}} | k ← tally g |
| 221 | rows := (3 * (r_ange 3) - 1) '+ t_able 9 * (r_ange k) - 1 | \ \ {\mathrm{rows}}\ {\leftarrow}\ {(}{3}\ {\times}\ {(}{\mathrm{\underline{r}ange}}\ {3}{)}\ {-}\ {1}{)}\ {\text{'}}{+}\ {\mathrm{\underline{t}able}}\ {9}\ {\times}\ {(}{\mathrm{\underline{r}ange}}\ {\mathrm{k}}{)}\ {-}\ {1} | rows ← (3 × (range 3) − 1) ’+ table 9 × (range k) − 1 |
| 222 | at := (1 + 9 * k) m_in rows '+ t_able 1 2 3 99 | \ \ {\mathrm{at}}\ {\leftarrow}\ {(}{1}\ {+}\ {9}\ {\times}\ {\mathrm{k}}{)}\ {\mathrm{\underline{m}in}}\ {\mathrm{rows}}\ {\text{'}}{+}\ {\mathrm{\underline{t}able}}\ {1}\ {2}\ {3}\ {99} | at ← (1 + 9 × k) min rows ’+ table 1 2 3 99 |
| 223 | squares := at s_elect (r_avel g) c_at 3 | \ \ {\mathrm{squares}}\ {\leftarrow}\ {\mathrm{at}}\ {\mathrm{\underline{s}elect}}\ {(}{\mathrm{\underline{r}avel}}\ {\mathrm{g}}{)}\ {\mathrm{\underline{c}at}}\ {3} | squares ← at select (ravel g) cat 3 |
| 224 | (3 c_at 8 * k) r_eshape (1 + (squares + 2) '* t_able 0 1) s_elect " O.X " | \ \ {(}{3}\ {\mathrm{\underline{c}at}}\ {8}\ {\times}\ {\mathrm{k}}{)}\ {\mathrm{\underline{r}eshape}}\ {(}{1}\ {+}\ {(}{\mathrm{squares}}\ {+}\ {2}{)}\ {\text{'}}{\times}\ {\mathrm{\underline{t}able}}\ {0}\ {1}{)}\ {\mathrm{\underline{s}elect}}\ {\text{" O.X "}} | (3 cat 8 × k) reshape (1 + (squares + 2) ’× table 0 1) select " O.X " |
| 225 | } | {\}} | } |
| 229 | h:o_pening! := { @ -> 2 9 r_eshape (9 r_eshape 0) c_at 1 * (r_ange 9) = r_oll! 9 } | {{}^{\mathrm{h}}\mathrm{\underline{o}pening}{!}}\ {\leftarrow}\ {\{}\ {@}\ {\to}\ {2}\ {9}\ {\mathrm{\underline{r}eshape}}\ {(}{9}\ {\mathrm{\underline{r}eshape}}\ {0}{)}\ {\mathrm{\underline{c}at}}\ {1}\ {\times}\ {(}{\mathrm{\underline{r}ange}}\ {9}{)}\ {=}\ {\mathrm{\underline{r}oll}{!}}\ {9}\ {\}} | hopening! ← { @ → 2 9 reshape (9 reshape 0) cat 1 × (range 9) = roll! 9 } |
| 231 | h:f_inal := { g -> l:o_utcome (t_ally g) s_elect g } | {{}^{\mathrm{h}}\mathrm{\underline{f}inal}}\ {\leftarrow}\ {\{}\ {\mathrm{g}}\ {\to}\ {{}^{\mathrm{l}}\mathrm{\underline{o}utcome}}\ {(}{\mathrm{\underline{t}ally}}\ {\mathrm{g}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{g}}\ {\}} | hfinal ← { g → loutcome (tally g) select g } |
| 237 | l:s_elfTrial! := { n m -> | {{}^{\mathrm{l}}\mathrm{\underline{s}elfTrial}{!}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\mathrm{m}}\ {\to} | lselfTrial! ← { n m → |
| 238 | w := '{ _u -> h:f_inal m h:g_reedy h:o_pening! @ } e_ach r_ange n | \ \ {\mathrm{w}}\ {\leftarrow}\ {\text{'}}{\{}\ {\_\mathrm{u}}\ {\to}\ {{}^{\mathrm{h}}\mathrm{\underline{f}inal}}\ {\mathrm{m}}\ {{}^{\mathrm{h}}\mathrm{\underline{g}reedy}}\ {{}^{\mathrm{h}}\mathrm{\underline{o}pening}{!}}\ {@}\ {\}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{\underline{r}ange}}\ {\mathrm{n}} | w ← ’{ _u → hfinal m hgreedy hopening! @ } each range n |
| 239 | '+ r_/ w '= t_able 1 -1 2 | \ \ {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{w}}\ {\text{'}}{=}\ {\mathrm{\underline{t}able}}\ {1}\ {-1}\ {2} | ’+ r/ w ’= table 1 −1 2 |
| 240 | } | {\}} | } |
| 33 | u:n_ext := { _r + -1 o_- _r } | {{}^{\mathrm{u}}\mathrm{\underline{n}ext}}\ {\leftarrow}\ {\{}\ {\_\mathrm{r}}\ {+}\ {-1}\ {\mathrm{\underline{o}}{-}}\ {\_\mathrm{r}}\ {\}} | unext ← { _r + −1 o− _r } |
| 34 | u:n_ext 1 0 0 0 0 | {{}^{\mathrm{u}}\mathrm{\underline{n}ext}}\ {1}\ {0}\ {0}\ {0}\ {0} | unext 1 0 0 0 0 |
| 52 | u:r_ows := { n r -> | {{}^{\mathrm{u}}\mathrm{\underline{r}ows}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\mathrm{r}}\ {\to} | urows ← { n r → |
| 53 | n = 1 ? (1 c_at s_hape r) r_eshape r | \ \ {\mathrm{n}}\ {=}\ {1}\ {?}\ {(}{1}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{s}hape}}\ {\mathrm{r}}{)}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{r}} | n = 1 ? (1 cat shape r) reshape r |
| 54 | r c_at (n - 1) u:r_ows u:n_ext r | \ \ {\mathrm{r}}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{n}}\ {-}\ {1}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{r}ows}}\ {{}^{\mathrm{u}}\mathrm{\underline{n}ext}}\ {\mathrm{r}} | r cat (n − 1) urows unext r |
| 55 | } | {\}} | } |
| 56 | 6 u:r_ows 6 t_ake 1 | {6}\ {{}^{\mathrm{u}}\mathrm{\underline{r}ows}}\ {6}\ {\mathrm{\underline{t}ake}}\ {1} | 6 urows 6 take 1 |
| 75 | sierpinski := []S_HOW []G_RID (32 u:r_ows 32 t_ake 1) m_od 2 | {\mathrm{sierpinski}}\ {\leftarrow}\ {\square \mathrm{\underline{S}HOW}}\ {\square \mathrm{\underline{G}RID}}\ {(}{32}\ {{}^{\mathrm{u}}\mathrm{\underline{r}ows}}\ {32}\ {\mathrm{\underline{t}ake}}\ {1}{)}\ {\mathrm{\underline{m}od}}\ {2} | sierpinski ← □SHOW □GRID (32 urows 32 take 1) mod 2 |
| 89 | colors := []S_HOW []G_RID 16 u:r_ows 16 t_ake 1 | {\mathrm{colors}}\ {\leftarrow}\ {\square \mathrm{\underline{S}HOW}}\ {\square \mathrm{\underline{G}RID}}\ {16}\ {{}^{\mathrm{u}}\mathrm{\underline{r}ows}}\ {16}\ {\mathrm{\underline{t}ake}}\ {1} | colors ← □SHOW □GRID 16 urows 16 take 1 |
| 114 | u:s_ieve := { v -> | {{}^{\mathrm{u}}\mathrm{\underline{s}ieve}}\ {\leftarrow}\ {\{}\ {\mathrm{v}}\ {\to} | usieve ← { v → |
| 115 | 0 = t_ally v ? v | \ \ {0}\ {=}\ {\mathrm{\underline{t}ally}}\ {\mathrm{v}}\ {?}\ {\mathrm{v}} | 0 = tally v ? v |
| 116 | p := f_irst v | \ \ {\mathrm{p}}\ {\leftarrow}\ {\mathrm{\underline{f}irst}}\ {\mathrm{v}} | p ← first v |
| 117 | (p * p) > 'm_ax r_/ v ? v | \ \ {(}{\mathrm{p}}\ {\times}\ {\mathrm{p}}{)}\ {>}\ {\text{'}}{\mathrm{\underline{m}ax}}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{v}}\ {?}\ {\mathrm{v}} | (p × p) > ’max r/ v ? v |
| 118 | rest := 1 d_rop v | \ \ {\mathrm{rest}}\ {\leftarrow}\ {1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{v}} | rest ← 1 drop v |
| 119 | p c_at u:s_ieve (w_here 0 != rest m_od p) s_elect rest | \ \ {\mathrm{p}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{u}}\mathrm{\underline{s}ieve}}\ {(}{\mathrm{\underline{w}here}}\ {0}\ {\neq}\ {\mathrm{rest}}\ {\mathrm{\underline{m}od}}\ {\mathrm{p}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{rest}} | p cat usieve (where 0 = rest mod p) select rest |
| 120 | } | {\}} | } |
| 121 | u:s_ieve 1 d_rop r_ange 60 | {{}^{\mathrm{u}}\mathrm{\underline{s}ieve}}\ {1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{\underline{r}ange}}\ {60} | usieve 1 drop range 60 |
| 138 | a := r_ange 30 | {\mathrm{a}}\ {\leftarrow}\ {\mathrm{\underline{r}ange}}\ {30} | a ← range 30 |
| 139 | divides := []S_HOW []G_RID 0 = a 'm_od t_able a | {\mathrm{divides}}\ {\leftarrow}\ {\square \mathrm{\underline{S}HOW}}\ {\square \mathrm{\underline{G}RID}}\ {0}\ {=}\ {\mathrm{a}}\ {\text{'}}{\mathrm{\underline{m}od}}\ {\mathrm{\underline{t}able}}\ {\mathrm{a}} | divides ← □SHOW □GRID 0 = a ’mod table a |
| 150 | (w_here 2 = '+ r_/_2 0 = a 'm_od t_able a) s_elect a | {(}{\mathrm{\underline{w}here}}\ {2}\ {=}\ {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{2}}\ {0}\ {=}\ {\mathrm{a}}\ {\text{'}}{\mathrm{\underline{m}od}}\ {\mathrm{\underline{t}able}}\ {\mathrm{a}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{a}} | (where 2 = ’+ r/2 0 = a ’mod table a) select a |
| 166 | u:g_cd := { a b -> b = 0 ? a; b u:g_cd a m_od b } | {{}^{\mathrm{u}}\mathrm{\underline{g}cd}}\ {\leftarrow}\ {\{}\ {\mathrm{a}}\ {\mathrm{b}}\ {\to}\ {\mathrm{b}}\ {=}\ {0}\ {?}\ {\mathrm{a}}{\diamond}\ {\mathrm{b}}\ {{}^{\mathrm{u}}\mathrm{\underline{g}cd}}\ {\mathrm{a}}\ {\mathrm{\underline{m}od}}\ {\mathrm{b}}\ {\}} | ugcd ← { a b → b = 0 ? a⋄ b ugcd a mod b } |
| 167 | 'u:g_cd r_/ 84 126 210 | {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{g}cd}}\ {\mathrm{\underline{r}}{/}}\ {84}\ {126}\ {210} | ’ugcd r/ 84 126 210 |
| 183 | u:h_ail := { n -> 0 = n m_od 2 ? n d_iv 2; 1 + 3 * n } | {{}^{\mathrm{u}}\mathrm{\underline{h}ail}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\to}\ {0}\ {=}\ {\mathrm{n}}\ {\mathrm{\underline{m}od}}\ {2}\ {?}\ {\mathrm{n}}\ {\mathrm{\underline{d}iv}}\ {2}{\diamond}\ {1}\ {+}\ {3}\ {\times}\ {\mathrm{n}}\ {\}} | uhail ← { n → 0 = n mod 2 ? n div 2⋄ 1 + 3 × n } |
| 184 | u:c_ollatz := { n -> n = 1 ? 1 r_eshape 1; n c_at u:c_ollatz u:h_ail n } | {{}^{\mathrm{u}}\mathrm{\underline{c}ollatz}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\to}\ {\mathrm{n}}\ {=}\ {1}\ {?}\ {1}\ {\mathrm{\underline{r}eshape}}\ {1}{\diamond}\ {\mathrm{n}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{u}}\mathrm{\underline{c}ollatz}}\ {{}^{\mathrm{u}}\mathrm{\underline{h}ail}}\ {\mathrm{n}}\ {\}} | ucollatz ← { n → n = 1 ? 1 reshape 1⋄ n cat ucollatz uhail n } |
| 185 | '{ (t_ally u:c_ollatz _r) - 1 } e_ach r_ange 30 | {\text{'}}{\{}\ {(}{\mathrm{\underline{t}ally}}\ {{}^{\mathrm{u}}\mathrm{\underline{c}ollatz}}\ {\_\mathrm{r}}{)}\ {-}\ {1}\ {\}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{\underline{r}ange}}\ {30} | ’{ (tally ucollatz _r) − 1 } each range 30 |
| 211 | u:q_sort := { v -> | {{}^{\mathrm{u}}\mathrm{\underline{q}sort}}\ {\leftarrow}\ {\{}\ {\mathrm{v}}\ {\to} | uqsort ← { v → |
| 212 | 2 > t_ally v ? v | \ \ {2}\ {>}\ {\mathrm{\underline{t}ally}}\ {\mathrm{v}}\ {?}\ {\mathrm{v}} | 2 > tally v ? v |
| 213 | p := f_irst v | \ \ {\mathrm{p}}\ {\leftarrow}\ {\mathrm{\underline{f}irst}}\ {\mathrm{v}} | p ← first v |
| 214 | below := (w_here v < p) s_elect v | \ \ {\mathrm{below}}\ {\leftarrow}\ {(}{\mathrm{\underline{w}here}}\ {\mathrm{v}}\ {<}\ {\mathrm{p}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{v}} | below ← (where v < p) select v |
| 215 | same := (w_here v = p) s_elect v | \ \ {\mathrm{same}}\ {\leftarrow}\ {(}{\mathrm{\underline{w}here}}\ {\mathrm{v}}\ {=}\ {\mathrm{p}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{v}} | same ← (where v = p) select v |
| 216 | above := (w_here v > p) s_elect v | \ \ {\mathrm{above}}\ {\leftarrow}\ {(}{\mathrm{\underline{w}here}}\ {\mathrm{v}}\ {>}\ {\mathrm{p}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{v}} | above ← (where v > p) select v |
| 217 | (u:q_sort below) c_at same c_at u:q_sort above | \ \ {(}{{}^{\mathrm{u}}\mathrm{\underline{q}sort}}\ {\mathrm{below}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{same}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{u}}\mathrm{\underline{q}sort}}\ {\mathrm{above}} | (uqsort below) cat same cat uqsort above |
| 218 | } | {\}} | } |
| 219 | u:q_sort 3 1 4 1 5 9 2 6 5 3 5 | {{}^{\mathrm{u}}\mathrm{\underline{q}sort}}\ {3}\ {1}\ {4}\ {1}\ {5}\ {9}\ {2}\ {6}\ {5}\ {3}\ {5} | uqsort 3 1 4 1 5 9 2 6 5 3 5 |
| 240 | u:h_anoi := { n pegs -> | {{}^{\mathrm{u}}\mathrm{\underline{h}anoi}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\mathrm{pegs}}\ {\to} | uhanoi ← { n pegs → |
| 241 | n = 0 ? 0 2 r_eshape 0 | \ \ {\mathrm{n}}\ {=}\ {0}\ {?}\ {0}\ {2}\ {\mathrm{\underline{r}eshape}}\ {0} | n = 0 ? 0 2 reshape 0 |
| 242 | first := (n - 1) u:h_anoi 1 3 2 s_elect pegs | \ \ {\mathrm{first}}\ {\leftarrow}\ {(}{\mathrm{n}}\ {-}\ {1}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{h}anoi}}\ {1}\ {3}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{pegs}} | first ← (n − 1) uhanoi 1 3 2 select pegs |
| 243 | last := (n - 1) u:h_anoi 3 2 1 s_elect pegs | \ \ {\mathrm{last}}\ {\leftarrow}\ {(}{\mathrm{n}}\ {-}\ {1}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{h}anoi}}\ {3}\ {2}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{pegs}} | last ← (n − 1) uhanoi 3 2 1 select pegs |
| 244 | first c_at (1 2 r_eshape 2 t_ake pegs) c_at last | \ \ {\mathrm{first}}\ {\mathrm{\underline{c}at}}\ {(}{1}\ {2}\ {\mathrm{\underline{r}eshape}}\ {2}\ {\mathrm{\underline{t}ake}}\ {\mathrm{pegs}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{last}} | first cat (1 2 reshape 2 take pegs) cat last |
| 245 | } | {\}} | } |
| 246 | 3 u:h_anoi 1 3 2 | {3}\ {{}^{\mathrm{u}}\mathrm{\underline{h}anoi}}\ {1}\ {3}\ {2} | 3 uhanoi 1 3 2 |
| 289 | u:m_ove := { p m -> | {{}^{\mathrm{u}}\mathrm{\underline{m}ove}}\ {\leftarrow}\ {\{}\ {\mathrm{p}}\ {\mathrm{m}}\ {\to} | umove ← { p m → |
| 290 | from := 1 s_elect m | \ \ {\mathrm{from}}\ {\leftarrow}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{m}} | from ← 1 select m |
| 291 | disk := p i_ndexOf from | \ \ {\mathrm{disk}}\ {\leftarrow}\ {\mathrm{p}}\ {\mathrm{\underline{i}ndexOf}}\ {\mathrm{from}} | disk ← p indexOf from |
| 292 | p + ((2 s_elect m) - from) * disk = r_ange t_ally p | \ \ {\mathrm{p}}\ {+}\ {(}{(}{2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{m}}{)}\ {-}\ {\mathrm{from}}{)}\ {\times}\ {\mathrm{disk}}\ {=}\ {\mathrm{\underline{r}ange}}\ {\mathrm{\underline{t}ally}}\ {\mathrm{p}} | p + ((2 select m) − from) × disk = range tally p |
| 293 | } | {\}} | } |
| 294 | u:s_lots := { p -> | {{}^{\mathrm{u}}\mathrm{\underline{s}lots}}\ {\leftarrow}\ {\{}\ {\mathrm{p}}\ {\to} | uslots ← { p → |
| 295 | n := t_ally p | \ \ {\mathrm{n}}\ {\leftarrow}\ {\mathrm{\underline{t}ally}}\ {\mathrm{p}} | n ← tally p |
| 296 | (r_ange n) '{ r j -> r s_elect (0 - n) t_ake 0 c_at w_here p = j } t_able 1 2 3 | \ \ {(}{\mathrm{\underline{r}ange}}\ {\mathrm{n}}{)}\ {\text{'}}{\{}\ {\mathrm{r}}\ {\mathrm{j}}\ {\to}\ {\mathrm{r}}\ {\mathrm{\underline{s}elect}}\ {(}{0}\ {-}\ {\mathrm{n}}{)}\ {\mathrm{\underline{t}ake}}\ {0}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{w}here}}\ {\mathrm{p}}\ {=}\ {\mathrm{j}}\ {\}}\ {\mathrm{\underline{t}able}}\ {1}\ {2}\ {3} | (range n) ’{ r j → r select (0 − n) take 0 cat where p = j } table 1 2 3 |
| 297 | } | {\}} | } |
| 298 | u:p_icture := { p -> | {{}^{\mathrm{u}}\mathrm{\underline{p}icture}}\ {\leftarrow}\ {\{}\ {\mathrm{p}}\ {\to} | upicture ← { p → |
| 299 | n := t_ally p | \ \ {\mathrm{n}}\ {\leftarrow}\ {\mathrm{\underline{t}ally}}\ {\mathrm{p}} | n ← tally p |
| 300 | w := 1 + 2 * n | \ \ {\mathrm{w}}\ {\leftarrow}\ {1}\ {+}\ {2}\ {\times}\ {\mathrm{n}} | w ← 1 + 2 × n |
| 301 | bars := (u:s_lots p) '{ s x -> s > a_bs x } t_able (o_ffsets w) - n | \ \ {\mathrm{bars}}\ {\leftarrow}\ {(}{{}^{\mathrm{u}}\mathrm{\underline{s}lots}}\ {\mathrm{p}}{)}\ {\text{'}}{\{}\ {\mathrm{s}}\ {\mathrm{x}}\ {\to}\ {\mathrm{s}}\ {>}\ {\mathrm{\underline{a}bs}}\ {\mathrm{x}}\ {\}}\ {\mathrm{\underline{t}able}}\ {(}{\mathrm{\underline{o}ffsets}}\ {\mathrm{w}}{)}\ {-}\ {\mathrm{n}} | bars ← (uslots p) ’{ s x → s > abs x } table (offsets w) − n |
| 302 | (n c_at 3 * w) r_eshape r_avel bars | \ \ {(}{\mathrm{n}}\ {\mathrm{\underline{c}at}}\ {3}\ {\times}\ {\mathrm{w}}{)}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{\underline{r}avel}}\ {\mathrm{bars}} | (n cat 3 × w) reshape ravel bars |
| 303 | } | {\}} | } |
| 304 | u:p_lane := { m -> (1 c_at s_hape m) r_eshape m } | {{}^{\mathrm{u}}\mathrm{\underline{p}lane}}\ {\leftarrow}\ {\{}\ {\mathrm{m}}\ {\to}\ {(}{1}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{s}hape}}\ {\mathrm{m}}{)}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{m}}\ {\}} | uplane ← { m → (1 cat shape m) reshape m } |
| 305 | u:p_lay := { p moves -> | {{}^{\mathrm{u}}\mathrm{\underline{p}lay}}\ {\leftarrow}\ {\{}\ {\mathrm{p}}\ {\mathrm{moves}}\ {\to} | uplay ← { p moves → |
| 306 | frame := u:p_lane u:p_icture p | \ \ {\mathrm{frame}}\ {\leftarrow}\ {{}^{\mathrm{u}}\mathrm{\underline{p}lane}}\ {{}^{\mathrm{u}}\mathrm{\underline{p}icture}}\ {\mathrm{p}} | frame ← uplane upicture p |
| 307 | 0 = t_ally moves ? frame | \ \ {0}\ {=}\ {\mathrm{\underline{t}ally}}\ {\mathrm{moves}}\ {?}\ {\mathrm{frame}} | 0 = tally moves ? frame |
| 308 | frame c_at (p u:m_ove f_irst moves) u:p_lay 1 d_rop moves | \ \ {\mathrm{frame}}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{p}}\ {{}^{\mathrm{u}}\mathrm{\underline{m}ove}}\ {\mathrm{\underline{f}irst}}\ {\mathrm{moves}}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{p}lay}}\ {1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{moves}} | frame cat (p umove first moves) uplay 1 drop moves |
| 309 | } | {\}} | } |
| 323 | _ := []S_HOW []G_RID (4 r_eshape 1) u:p_lay 4 u:h_anoi 1 3 2 | {\_}\ {\leftarrow}\ {\square \mathrm{\underline{S}HOW}}\ {\square \mathrm{\underline{G}RID}}\ {(}{4}\ {\mathrm{\underline{r}eshape}}\ {1}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{p}lay}}\ {4}\ {{}^{\mathrm{u}}\mathrm{\underline{h}anoi}}\ {1}\ {3}\ {2} | _ ← □SHOW □GRID (4 reshape 1) uplay 4 uhanoi 1 3 2 |
| 348 | edges := 4 4 r_eshape 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 | {\mathrm{edges}}\ {\leftarrow}\ {4}\ {4}\ {\mathrm{\underline{r}eshape}}\ {0}\ {1}\ {0}\ {0}\ \ {0}\ {0}\ {1}\ {0}\ \ {0}\ {0}\ {0}\ {1}\ \ {0}\ {0}\ {0}\ {0} | edges ← 4 4 reshape 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 |
| 349 | u:c_losure := { r -> | {{}^{\mathrm{u}}\mathrm{\underline{c}losure}}\ {\leftarrow}\ {\{}\ {\mathrm{r}}\ {\to} | uclosure ← { r → |
| 350 | next := r | r '| '& i_nner r | \ \ {\mathrm{next}}\ {\leftarrow}\ {\mathrm{r}}\ {\vee}\ {\mathrm{r}}\ {\text{'}}{\vee}\ {\text{'}}{\wedge}\ {\mathrm{\underline{i}nner}}\ {\mathrm{r}} | next ← r ∨ r ’∨ ’∧ inner r |
| 351 | (next m_atch r) ? r | \ \ {(}{\mathrm{next}}\ {\mathrm{\underline{m}atch}}\ {\mathrm{r}}{)}\ {?}\ {\mathrm{r}} | (next match r) ? r |
| 352 | u:c_losure next | \ \ {{}^{\mathrm{u}}\mathrm{\underline{c}losure}}\ {\mathrm{next}} | uclosure next |
| 353 | } | {\}} | } |
| 354 | u:c_losure edges | {{}^{\mathrm{u}}\mathrm{\underline{c}losure}}\ {\mathrm{edges}} | uclosure edges |
| 380 | u:w_arshallSteps := { r k -> | {{}^{\mathrm{u}}\mathrm{\underline{w}arshallSteps}}\ {\leftarrow}\ {\{}\ {\mathrm{r}}\ {\mathrm{k}}\ {\to} | uwarshallSteps ← { r k → |
| 381 | k > t_ally r ? u:p_lane r | \ \ {\mathrm{k}}\ {>}\ {\mathrm{\underline{t}ally}}\ {\mathrm{r}}\ {?}\ {{}^{\mathrm{u}}\mathrm{\underline{p}lane}}\ {\mathrm{r}} | k > tally r ? uplane r |
| 382 | through := (k s_elect_2 r) '& t_able k s_elect r | \ \ {\mathrm{through}}\ {\leftarrow}\ {(}{\mathrm{k}}\ {{\mathrm{\underline{s}elect}}_{2}}\ {\mathrm{r}}{)}\ {\text{'}}{\wedge}\ {\mathrm{\underline{t}able}}\ {\mathrm{k}}\ {\mathrm{\underline{s}elect}}\ {\mathrm{r}} | through ← (k select2 r) ’∧ table k select r |
| 383 | (u:p_lane r) c_at (r | through) u:w_arshallSteps k + 1 | \ \ {(}{{}^{\mathrm{u}}\mathrm{\underline{p}lane}}\ {\mathrm{r}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{r}}\ {\vee}\ {\mathrm{through}}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{w}arshallSteps}}\ {\mathrm{k}}\ {+}\ {1} | (uplane r) cat (r ∨ through) uwarshallSteps k + 1 |
| 384 | } | {\}} | } |
| 385 | g := 8 8 r_eshape 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 | {\mathrm{g}}\ {\leftarrow}\ {8}\ {8}\ {\mathrm{\underline{r}eshape}}\ {0}\ {1}\ {0}\ {0}\ {0}\ {0}\ {0}\ {0}\ \ {0}\ {0}\ {1}\ {0}\ {0}\ {0}\ {0}\ {0}\ \ {1}\ {0}\ {0}\ {1}\ {0}\ {0}\ {0}\ {0}\ \ {0}\ {0}\ {0}\ {0}\ {1}\ {0}\ {0}\ {0}\ \ {0}\ {0}\ {0}\ {0}\ {0}\ {1}\ {0}\ {0}\ \ {0}\ {0}\ {0}\ {0}\ {0}\ {0}\ {1}\ {0}\ \ {0}\ {0}\ {0}\ {0}\ {0}\ {0}\ {0}\ {1}\ \ {0}\ {0}\ {0}\ {0}\ {1}\ {0}\ {0}\ {0} | g ← 8 8 reshape 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 |
| 395 | _ := []S_HOW []G_RID g u:w_arshallSteps 1 | {\_}\ {\leftarrow}\ {\square \mathrm{\underline{S}HOW}}\ {\square \mathrm{\underline{G}RID}}\ {\mathrm{g}}\ {{}^{\mathrm{u}}\mathrm{\underline{w}arshallSteps}}\ {1} | _ ← □SHOW □GRID g uwarshallSteps 1 |
| 416 | w := 4 4 r_eshape 0 3 999 7 8 0 2 999 5 999 0 1 2 999 999 0 | {\mathrm{w}}\ {\leftarrow}\ {4}\ {4}\ {\mathrm{\underline{r}eshape}}\ {0}\ {3}\ {999}\ {7}\ \ {8}\ {0}\ {2}\ {999}\ \ {5}\ {999}\ {0}\ {1}\ \ {2}\ {999}\ {999}\ {0} | w ← 4 4 reshape 0 3 999 7 8 0 2 999 5 999 0 1 2 999 999 0 |
| 417 | u:s_hortest := { d -> | {{}^{\mathrm{u}}\mathrm{\underline{s}hortest}}\ {\leftarrow}\ {\{}\ {\mathrm{d}}\ {\to} | ushortest ← { d → |
| 418 | e := d 'm_in '+ i_nner d | \ \ {\mathrm{e}}\ {\leftarrow}\ {\mathrm{d}}\ {\text{'}}{\mathrm{\underline{m}in}}\ {\text{'}}{+}\ {\mathrm{\underline{i}nner}}\ {\mathrm{d}} | e ← d ’min ’+ inner d |
| 419 | (e m_atch d) ? d | \ \ {(}{\mathrm{e}}\ {\mathrm{\underline{m}atch}}\ {\mathrm{d}}{)}\ {?}\ {\mathrm{d}} | (e match d) ? d |
| 420 | u:s_hortest e | \ \ {{}^{\mathrm{u}}\mathrm{\underline{s}hortest}}\ {\mathrm{e}} | ushortest e |
| 421 | } | {\}} | } |
| 422 | u:s_hortest w | {{}^{\mathrm{u}}\mathrm{\underline{s}hortest}}\ {\mathrm{w}} | ushortest w |
| 445 | u:d_iff := { v -> (1 d_rop v) - -1 d_rop v } | {{}^{\mathrm{u}}\mathrm{\underline{d}iff}}\ {\leftarrow}\ {\{}\ {\mathrm{v}}\ {\to}\ {(}{1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{v}}{)}\ {-}\ {-1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{v}}\ {\}} | udiff ← { v → (1 drop v) − −1 drop v } |
| 446 | squares := (r_ange 8) ^ 2 | {\mathrm{squares}}\ {\leftarrow}\ {(}{\mathrm{\underline{r}ange}}\ {8}{)}\ {\mathbin{\hat{}}}\ {2} | squares ← (range 8) ^ 2 |
| 447 | u:d_iff squares | {{}^{\mathrm{u}}\mathrm{\underline{d}iff}}\ {\mathrm{squares}} | udiff squares |
| 448 | u:d_iff^2 squares | {{}^{\mathrm{u}}\mathrm{\underline{d}iff}}^{2}\ {\mathrm{squares}} | udiff2 squares |
| 474 | u:b_its := { rule -> (rule d_iv 2 ^ o_ffsets 8) m_od 2 } | {{}^{\mathrm{u}}\mathrm{\underline{b}its}}\ {\leftarrow}\ {\{}\ {\mathrm{rule}}\ {\to}\ {(}{\mathrm{rule}}\ {\mathrm{\underline{d}iv}}\ {2}\ {\mathbin{\hat{}}}\ {\mathrm{\underline{o}ffsets}}\ {8}{)}\ {\mathrm{\underline{m}od}}\ {2}\ {\}} | ubits ← { rule → (rule div 2 ^ offsets 8) mod 2 } |
| 475 | u:s_tep := { bits row -> (1 + (4 * -1 o_- row) + (2 * row) + 1 o_- row) s_elect bits } | {{}^{\mathrm{u}}\mathrm{\underline{s}tep}}\ {\leftarrow}\ {\{}\ {\mathrm{bits}}\ {\mathrm{row}}\ {\to}\ {(}{1}\ {+}\ {(}{4}\ {\times}\ {-1}\ {\mathrm{\underline{o}}{-}}\ {\mathrm{row}}{)}\ {+}\ {(}{2}\ {\times}\ {\mathrm{row}}{)}\ {+}\ {1}\ {\mathrm{\underline{o}}{-}}\ {\mathrm{row}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{bits}}\ {\}} | ustep ← { bits row → (1 + (4 × −1 o− row) + (2 × row) + 1 o− row) select bits } |
| 476 | u:e_volve := { bits rows -> | {{}^{\mathrm{u}}\mathrm{\underline{e}volve}}\ {\leftarrow}\ {\{}\ {\mathrm{bits}}\ {\mathrm{rows}}\ {\to} | uevolve ← { bits rows → |
| 477 | (t_ally rows) >= t_ally f_irst rows ? rows | \ \ {(}{\mathrm{\underline{t}ally}}\ {\mathrm{rows}}{)}\ {\geq}\ {\mathrm{\underline{t}ally}}\ {\mathrm{\underline{f}irst}}\ {\mathrm{rows}}\ {?}\ {\mathrm{rows}} | (tally rows) ≥ tally first rows ? rows |
| 478 | next := bits u:s_tep r_avel -1 t_ake rows | \ \ {\mathrm{next}}\ {\leftarrow}\ {\mathrm{bits}}\ {{}^{\mathrm{u}}\mathrm{\underline{s}tep}}\ {\mathrm{\underline{r}avel}}\ {-1}\ {\mathrm{\underline{t}ake}}\ {\mathrm{rows}} | next ← bits ustep ravel −1 take rows |
| 479 | bits u:e_volve rows c_at next | \ \ {\mathrm{bits}}\ {{}^{\mathrm{u}}\mathrm{\underline{e}volve}}\ {\mathrm{rows}}\ {\mathrm{\underline{c}at}}\ {\mathrm{next}} | bits uevolve rows cat next |
| 480 | } | {\}} | } |
| 481 | u:s_tart := { w -> (1 c_at w) r_eshape ((w d_iv 2) r_eshape 0) c_at 1 c_at (w - 1 + w d_iv 2) r_eshape 0 } | {{}^{\mathrm{u}}\mathrm{\underline{s}tart}}\ {\leftarrow}\ {\{}\ {\mathrm{w}}\ {\to}\ {(}{1}\ {\mathrm{\underline{c}at}}\ {\mathrm{w}}{)}\ {\mathrm{\underline{r}eshape}}\ {(}{(}{\mathrm{w}}\ {\mathrm{\underline{d}iv}}\ {2}{)}\ {\mathrm{\underline{r}eshape}}\ {0}{)}\ {\mathrm{\underline{c}at}}\ {1}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{w}}\ {-}\ {1}\ {+}\ {\mathrm{w}}\ {\mathrm{\underline{d}iv}}\ {2}{)}\ {\mathrm{\underline{r}eshape}}\ {0}\ {\}} | ustart ← { w → (1 cat w) reshape ((w div 2) reshape 0) cat 1 cat (w − 1 + w div 2) reshape 0 } |
| 482 | u:b_its 90 | {{}^{\mathrm{u}}\mathrm{\underline{b}its}}\ {90} | ubits 90 |
| 493 | ninety := []S_HOW []G_RID 32 t_ake (u:b_its 90) u:e_volve u:s_tart 63 | {\mathrm{ninety}}\ {\leftarrow}\ {\square \mathrm{\underline{S}HOW}}\ {\square \mathrm{\underline{G}RID}}\ {32}\ {\mathrm{\underline{t}ake}}\ {(}{{}^{\mathrm{u}}\mathrm{\underline{b}its}}\ {90}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{e}volve}}\ {{}^{\mathrm{u}}\mathrm{\underline{s}tart}}\ {63} | ninety ← □SHOW □GRID 32 take (ubits 90) uevolve ustart 63 |
| 514 | text := "the quick brown fox jumps over the lazy dog and the cat" | {\mathrm{text}}\ {\leftarrow}\ {\text{"the quick brown fox jumps over the lazy dog and the cat"}} | text ← "the quick brown fox jumps over the lazy dog and the cat" |
| 515 | space := f_irst " " | {\mathrm{space}}\ {\leftarrow}\ {\mathrm{\underline{f}irst}}\ {\text{" "}} | space ← first " " |
| 516 | letters := s_ort u_nique (w_here text != space) s_elect text | {\mathrm{letters}}\ {\leftarrow}\ {\mathrm{\underline{s}ort}}\ {\mathrm{\underline{u}nique}}\ {(}{\mathrm{\underline{w}here}}\ {\mathrm{text}}\ {\neq}\ {\mathrm{space}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{text}} | letters ← sort unique (where text = space) select text |
| 517 | n := '+ r_/_2 letters '= t_able text | {\mathrm{n}}\ {\leftarrow}\ {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{2}}\ {\mathrm{letters}}\ {\text{'}}{=}\ {\mathrm{\underline{t}able}}\ {\mathrm{text}} | n ← ’+ r/2 letters ’= table text |
| 518 | n | {\mathrm{n}} | n |
| 530 | tall := (r_ev r_ange 'm_ax r_/ n) '<= t_able n | {\mathrm{tall}}\ {\leftarrow}\ {(}{\mathrm{\underline{r}ev}}\ {\mathrm{\underline{r}ange}}\ {\text{'}}{\mathrm{\underline{m}ax}}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{n}}{)}\ {\text{'}}{\leq}\ {\mathrm{\underline{t}able}}\ {\mathrm{n}} | tall ← (rev range ’max r/ n) ’≤ table n |
| 531 | _ := []S_HOW []G_RID tall | {\_}\ {\leftarrow}\ {\square \mathrm{\underline{S}HOW}}\ {\square \mathrm{\underline{G}RID}}\ {\mathrm{tall}} | _ ← □SHOW □GRID tall |
| 549 | v := "aaabccddddde" | {\mathrm{v}}\ {\leftarrow}\ {\text{"aaabccddddde"}} | v ← "aaabccddddde" |
| 550 | p := w_here 1 c_at (1 d_rop v) != -1 d_rop v | {\mathrm{p}}\ {\leftarrow}\ {\mathrm{\underline{w}here}}\ {1}\ {\mathrm{\underline{c}at}}\ {(}{1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{v}}{)}\ {\neq}\ {-1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{v}} | p ← where 1 cat (1 drop v) = −1 drop v |
| 551 | p s_elect v | {\mathrm{p}}\ {\mathrm{\underline{s}elect}}\ {\mathrm{v}} | p select v |
| 552 | ((1 d_rop p) c_at 1 + t_ally v) - p | {(}{(}{1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{p}}{)}\ {\mathrm{\underline{c}at}}\ {1}\ {+}\ {\mathrm{\underline{t}ally}}\ {\mathrm{v}}{)}\ {-}\ {\mathrm{p}} | ((1 drop p) cat 1 + tally v) − p |
| 571 | u:l_ife := { ('+ r_/_12 -1 0 1 o_-_12 _r) { (_l = 3) + _r * _l = 4 } _r } | {{}^{\mathrm{u}}\mathrm{\underline{l}ife}}\ {\leftarrow}\ {\{}\ {(}{\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{12}}\ {-1}\ {0}\ {1}\ {{\mathrm{\underline{o}}{-}}_{12}}\ {\_\mathrm{r}}{)}\ {\{}\ {(}{\_\mathrm{l}}\ {=}\ {3}{)}\ {+}\ {\_\mathrm{r}}\ {\times}\ {\_\mathrm{l}}\ {=}\ {4}\ {\}}\ {\_\mathrm{r}}\ {\}} | ulife ← { (’+ r/12 −1 0 1 o−12 _r) { (_l = 3) + _r × _l = 4 } _r } |
| 588 | u:f_rames := { n b -> | {{}^{\mathrm{u}}\mathrm{\underline{f}rames}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\mathrm{b}}\ {\to} | uframes ← { n b → |
| 589 | n = 1 ? (1 c_at s_hape b) r_eshape b | \ \ {\mathrm{n}}\ {=}\ {1}\ {?}\ {(}{1}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{s}hape}}\ {\mathrm{b}}{)}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{b}} | n = 1 ? (1 cat shape b) reshape b |
| 590 | b c_at (n - 1) u:f_rames u:l_ife b | \ \ {\mathrm{b}}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{n}}\ {-}\ {1}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{f}rames}}\ {{}^{\mathrm{u}}\mathrm{\underline{l}ife}}\ {\mathrm{b}} | b cat (n − 1) uframes ulife b |
| 591 | } | {\}} | } |
| 606 | glider := 10 t_ake 10 t_ake_2 3 3 r_eshape 0 1 0 0 0 1 1 1 1 | {\mathrm{glider}}\ {\leftarrow}\ {10}\ {\mathrm{\underline{t}ake}}\ {10}\ {{\mathrm{\underline{t}ake}}_{2}}\ {3}\ {3}\ {\mathrm{\underline{r}eshape}}\ {0}\ {1}\ {0}\ {0}\ {0}\ {1}\ {1}\ {1}\ {1} | glider ← 10 take 10 take2 3 3 reshape 0 1 0 0 0 1 1 1 1 |
| 607 | (u:l_ife^40 glider) m_atch glider | {(}{{}^{\mathrm{u}}\mathrm{\underline{l}ife}}^{40}\ {\mathrm{glider}}{)}\ {\mathrm{\underline{m}atch}}\ {\mathrm{glider}} | (ulife40 glider) match glider |
| 620 | torus := []S_HOW []G_RID 40 u:f_rames glider | {\mathrm{torus}}\ {\leftarrow}\ {\square \mathrm{\underline{S}HOW}}\ {\square \mathrm{\underline{G}RID}}\ {40}\ {{}^{\mathrm{u}}\mathrm{\underline{f}rames}}\ {\mathrm{glider}} | torus ← □SHOW □GRID 40 uframes glider |
| 643 | row := 0 c_at (10 r_eshape 1) c_at 0 | {\mathrm{row}}\ {\leftarrow}\ {0}\ {\mathrm{\underline{c}at}}\ {(}{10}\ {\mathrm{\underline{r}eshape}}\ {1}{)}\ {\mathrm{\underline{c}at}}\ {0} | row ← 0 cat (10 reshape 1) cat 0 |
| 644 | mask := row '* t_able row | {\mathrm{mask}}\ {\leftarrow}\ {\mathrm{row}}\ {\text{'}}{\times}\ {\mathrm{\underline{t}able}}\ {\mathrm{row}} | mask ← row ’× table row |
| 645 | u:b_oxed := { mask * u:l_ife _r } | {{}^{\mathrm{u}}\mathrm{\underline{b}oxed}}\ {\leftarrow}\ {\{}\ {\mathrm{mask}}\ {\times}\ {{}^{\mathrm{u}}\mathrm{\underline{l}ife}}\ {\_\mathrm{r}}\ {\}} | uboxed ← { mask × ulife _r } |
| 646 | u:b_oxedFrames := { n b -> | {{}^{\mathrm{u}}\mathrm{\underline{b}oxedFrames}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\mathrm{b}}\ {\to} | uboxedFrames ← { n b → |
| 647 | n = 1 ? (1 c_at s_hape b) r_eshape b | \ \ {\mathrm{n}}\ {=}\ {1}\ {?}\ {(}{1}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{s}hape}}\ {\mathrm{b}}{)}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{b}} | n = 1 ? (1 cat shape b) reshape b |
| 648 | b c_at (n - 1) u:b_oxedFrames u:b_oxed b | \ \ {\mathrm{b}}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{n}}\ {-}\ {1}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{b}oxedFrames}}\ {{}^{\mathrm{u}}\mathrm{\underline{b}oxed}}\ {\mathrm{b}} | b cat (n − 1) uboxedFrames uboxed b |
| 649 | } | {\}} | } |
| 650 | start := -1 o_- -1 o_-_2 12 t_ake 12 t_ake_2 3 3 r_eshape 0 1 0 0 0 1 1 1 1 | {\mathrm{start}}\ {\leftarrow}\ {-1}\ {\mathrm{\underline{o}}{-}}\ {-1}\ {{\mathrm{\underline{o}}{-}}_{2}}\ {12}\ {\mathrm{\underline{t}ake}}\ {12}\ {{\mathrm{\underline{t}ake}}_{2}}\ {3}\ {3}\ {\mathrm{\underline{r}eshape}}\ {0}\ {1}\ {0}\ {0}\ {0}\ {1}\ {1}\ {1}\ {1} | start ← −1 o− −1 o−2 12 take 12 take2 3 3 reshape 0 1 0 0 0 1 1 1 1 |
| 651 | '+ r_/_12 u:b_oxed^40 start | {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{12}}\ {{}^{\mathrm{u}}\mathrm{\underline{b}oxed}}^{40}\ {\mathrm{start}} | ’+ r/12 uboxed40 start |
| 665 | boxed := []S_HOW []G_RID 40 u:b_oxedFrames start | {\mathrm{boxed}}\ {\leftarrow}\ {\square \mathrm{\underline{S}HOW}}\ {\square \mathrm{\underline{G}RID}}\ {40}\ {{}^{\mathrm{u}}\mathrm{\underline{b}oxedFrames}}\ {\mathrm{start}} | boxed ← □SHOW □GRID 40 uboxedFrames start |
| 684 | "t:" u_se< "Turtle" | {\text{"t:"}}\ {\mathrm{\underline{u}se}{<}}\ {\text{"Turtle"}} | "t:" use< "Turtle" |
| 685 | f_loor 0.5 + t:p_oints 0 90 90 90 | {\mathrm{\underline{f}loor}}\ {0.5}\ {+}\ {{}^{\mathrm{t}}\mathrm{\underline{p}oints}}\ {0}\ {90}\ {90}\ {90} | floor 0.5 + tpoints 0 90 90 90 |
| 707 | u:k_och := { n -> | {{}^{\mathrm{u}}\mathrm{\underline{k}och}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\to} | ukoch ← { n → |
| 708 | n = 0 ? 1 r_eshape 0 | \ \ {\mathrm{n}}\ {=}\ {0}\ {?}\ {1}\ {\mathrm{\underline{r}eshape}}\ {0} | n = 0 ? 1 reshape 0 |
| 709 | k := u:k_och n - 1 | \ \ {\mathrm{k}}\ {\leftarrow}\ {{}^{\mathrm{u}}\mathrm{\underline{k}och}}\ {\mathrm{n}}\ {-}\ {1} | k ← ukoch n − 1 |
| 710 | k c_at (60 t:t_urn k) c_at (-120 t:t_urn k) c_at 60 t:t_urn k | \ \ {\mathrm{k}}\ {\mathrm{\underline{c}at}}\ {(}{60}\ {{}^{\mathrm{t}}\mathrm{\underline{t}urn}}\ {\mathrm{k}}{)}\ {\mathrm{\underline{c}at}}\ {(}{-120}\ {{}^{\mathrm{t}}\mathrm{\underline{t}urn}}\ {\mathrm{k}}{)}\ {\mathrm{\underline{c}at}}\ {60}\ {{}^{\mathrm{t}}\mathrm{\underline{t}urn}}\ {\mathrm{k}} | k cat (60 tturn k) cat (−120 tturn k) cat 60 tturn k |
| 711 | } | {\}} | } |
| 712 | side := u:k_och 3 | {\mathrm{side}}\ {\leftarrow}\ {{}^{\mathrm{u}}\mathrm{\underline{k}och}}\ {3} | side ← ukoch 3 |
| 713 | t_ally side | {\mathrm{\underline{t}ally}}\ {\mathrm{side}} | tally side |
| 724 | snowflake := []S_HOW []P_ATH t:p_oints side c_at (-120 t:t_urn side) c_at -120 t:t_urn side | {\mathrm{snowflake}}\ {\leftarrow}\ {\square \mathrm{\underline{S}HOW}}\ {\square \mathrm{\underline{P}ATH}}\ {{}^{\mathrm{t}}\mathrm{\underline{p}oints}}\ {\mathrm{side}}\ {\mathrm{\underline{c}at}}\ {(}{-120}\ {{}^{\mathrm{t}}\mathrm{\underline{t}urn}}\ {\mathrm{side}}{)}\ {\mathrm{\underline{c}at}}\ {-120}\ {{}^{\mathrm{t}}\mathrm{\underline{t}urn}}\ {\mathrm{side}} | snowflake ← □SHOW □PATH tpoints side cat (−120 tturn side) cat −120 tturn side |
| 752 | u:a_rrow := { n s -> | {{}^{\mathrm{u}}\mathrm{\underline{a}rrow}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\mathrm{s}}\ {\to} | uarrow ← { n s → |
| 753 | n = 0 ? 1 r_eshape 0 | \ \ {\mathrm{n}}\ {=}\ {0}\ {?}\ {1}\ {\mathrm{\underline{r}eshape}}\ {0} | n = 0 ? 1 reshape 0 |
| 754 | outer := (n - 1) u:a_rrow n_eg s | \ \ {\mathrm{outer}}\ {\leftarrow}\ {(}{\mathrm{n}}\ {-}\ {1}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{a}rrow}}\ {\mathrm{\underline{n}eg}}\ {\mathrm{s}} | outer ← (n − 1) uarrow neg s |
| 755 | outer c_at ((60 * s) t:t_urn (n - 1) u:a_rrow s) c_at (60 * s) t:t_urn outer | \ \ {\mathrm{outer}}\ {\mathrm{\underline{c}at}}\ {(}{(}{60}\ {\times}\ {\mathrm{s}}{)}\ {{}^{\mathrm{t}}\mathrm{\underline{t}urn}}\ {(}{\mathrm{n}}\ {-}\ {1}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{a}rrow}}\ {\mathrm{s}}{)}\ {\mathrm{\underline{c}at}}\ {(}{60}\ {\times}\ {\mathrm{s}}{)}\ {{}^{\mathrm{t}}\mathrm{\underline{t}urn}}\ {\mathrm{outer}} | outer cat ((60 × s) tturn (n − 1) uarrow s) cat (60 × s) tturn outer |
| 756 | } | {\}} | } |
| 757 | arrowhead := t:p_oints 5 u:a_rrow 1 | {\mathrm{arrowhead}}\ {\leftarrow}\ {{}^{\mathrm{t}}\mathrm{\underline{p}oints}}\ {5}\ {{}^{\mathrm{u}}\mathrm{\underline{a}rrow}}\ {1} | arrowhead ← tpoints 5 uarrow 1 |
| 758 | size := 1 s_elect 1 d_rop s_hape arrowhead | {\mathrm{size}}\ {\leftarrow}\ {1}\ {\mathrm{\underline{s}elect}}\ {1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{\underline{s}hape}}\ {\mathrm{arrowhead}} | size ← 1 select 1 drop shape arrowhead |
| 759 | u:u_pTo := { k -> ((f_loor k * size / 24) m_in r_ange size) s_elect_2 arrowhead } | {{}^{\mathrm{u}}\mathrm{\underline{u}pTo}}\ {\leftarrow}\ {\{}\ {\mathrm{k}}\ {\to}\ {(}{(}{\mathrm{\underline{f}loor}}\ {\mathrm{k}}\ {\times}\ {\mathrm{size}}\ {\div}\ {24}{)}\ {\mathrm{\underline{m}in}}\ {\mathrm{\underline{r}ange}}\ {\mathrm{size}}{)}\ {{\mathrm{\underline{s}elect}}_{2}}\ {\mathrm{arrowhead}}\ {\}} | uupTo ← { k → ((floor k × size ÷ 24) min range size) select2 arrowhead } |
| 760 | u:d_rawing := { k -> | {{}^{\mathrm{u}}\mathrm{\underline{d}rawing}}\ {\leftarrow}\ {\{}\ {\mathrm{k}}\ {\to} | udrawing ← { k → |
| 761 | k = 1 ? (1 c_at s_hape u:u_pTo 1) r_eshape u:u_pTo 1 | \ \ {\mathrm{k}}\ {=}\ {1}\ {?}\ {(}{1}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{s}hape}}\ {{}^{\mathrm{u}}\mathrm{\underline{u}pTo}}\ {1}{)}\ {\mathrm{\underline{r}eshape}}\ {{}^{\mathrm{u}}\mathrm{\underline{u}pTo}}\ {1} | k = 1 ? (1 cat shape uupTo 1) reshape uupTo 1 |
| 762 | (u:d_rawing k - 1) c_at u:u_pTo k | \ \ {(}{{}^{\mathrm{u}}\mathrm{\underline{d}rawing}}\ {\mathrm{k}}\ {-}\ {1}{)}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{u}}\mathrm{\underline{u}pTo}}\ {\mathrm{k}} | (udrawing k − 1) cat uupTo k |
| 763 | } | {\}} | } |
| 764 | size | {\mathrm{size}} | size |
| 775 | drawing := []S_HOW []P_ATH u:d_rawing 24 | {\mathrm{drawing}}\ {\leftarrow}\ {\square \mathrm{\underline{S}HOW}}\ {\square \mathrm{\underline{P}ATH}}\ {{}^{\mathrm{u}}\mathrm{\underline{d}rawing}}\ {24} | drawing ← □SHOW □PATH udrawing 24 |
| 36 | 42 # an Int | {42} | 42 |
| 47 | -3 2.5 # a negative literal; a strand has one type (Float) | {-3}\ {2.5} | −3 2.5 |
| 59 | x := 3 # `:=` binds; `=` is always equality | {\mathrm{x}}\ {\leftarrow}\ {3} | x ← 3 |
| 60 | x^2 # a literal exponent touches its value: superscript | {\mathrm{x}}^{2} | x2 |
| 71 | 4^-1 # a negative exponent gives a Float (a literal base) | {4}^{-1} | 4−1 |
| 82 | 2 ^ 10 # spaced `^` is the power function (computed exponents) | {2}\ {\mathbin{\hat{}}}\ {10} | 2 ^ 10 |
| 93 | 7 / 2 # `/` always gives a Float | {7}\ {\div}\ {2} | 7 ÷ 2 |
| 104 | 7 d_iv 2; 7 m_od 3 # integer quotient and remainder; `;` separates statements | {7}\ {\mathrm{\underline{d}iv}}\ {2}{\diamond}\ {7}\ {\mathrm{\underline{m}od}}\ {3} | 7 div 2⋄ 7 mod 3 |
| 116 | (0.1 + 0.2) = 0.3 # `=` is exact: 0 (false) | {(}{0.1}\ {+}\ {0.2}{)}\ {=}\ {0.3} | (0.1 + 0.2) = 0.3 |
| 127 | (0.1 + 0.2) e_q~ 0.3 # tolerant equality: 1 | {(}{0.1}\ {+}\ {0.2}{)}\ {\mathrm{\underline{e}q}{\sim}}\ {0.3} | (0.1 + 0.2) eq∼ 0.3 |
| 138 | (3 < 4) & 2 != 2 # Bool (`& | !=`); no precedence: parenthesize the left | {(}{3}\ {<}\ {4}{)}\ {\wedge}\ {2}\ {\neq}\ {2} | (3 < 4) ∧ 2 = 2 |
| 149 | f_loat 3 # Int to Float | {\mathrm{\underline{f}loat}}\ {3} | float 3 |
| 163 | s_in (p_i @) / 2 # trigonometry in radians; `p_i @` is pi (niladic) | {\mathrm{\underline{s}in}}\ {(}{\mathrm{\underline{p}i}}\ {@}{)}\ {\div}\ {2} | sin (pi @) ÷ 2 |
| 174 | a_tan 1 # and c_os | {\mathrm{\underline{a}tan}}\ {1} | atan 1 |
| 193 | count! := 0 # only names ending in ! (like `count!`) may be reassigned | {\mathrm{count}!}\ {\leftarrow}\ {0} | count! ← 0 |
| 194 | count! := count! + 1 | {\mathrm{count}!}\ {\leftarrow}\ {\mathrm{count}!}\ {+}\ {1} | count! ← count! + 1 |
| 195 | count! | {\mathrm{count}!} | count! |
| 211 | "hello" | {\text{"hello"}} | "hello" |
| 222 | "abc" = "abd" # item by item | {\text{"abc"}}\ {=}\ {\text{"abd"}} | "abc" = "abd" |
| 233 | 3 t_ake "hello" | {3}\ {\mathrm{\underline{t}ake}}\ {\text{"hello"}} | 3 take "hello" |
| 247 | "hello X̲ᵉTᵃL" # strings and comments may hold any Unicode (code may not) | {\text{"hello \underline{X}ᵉTᵃL"}} | "hello XᵉTᵃL" |
| 266 | m := 2 3 r_eshape r_ange 6 # 1-origin: `r_ange 6` is 1 2 3 4 5 6 | {\mathrm{m}}\ {\leftarrow}\ {2}\ {3}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{\underline{r}ange}}\ {6} | m ← 2 3 reshape range 6 |
| 267 | m | {\mathrm{m}} | m |
| 279 | s_hape m; t_ally m | {\mathrm{\underline{s}hape}}\ {\mathrm{m}}{\diamond}\ {\mathrm{\underline{t}ally}}\ {\mathrm{m}} | shape m⋄ tally m |
| 291 | m * 10 # a scalar extends to every item | {\mathrm{m}}\ {\times}\ {10} | m × 10 |
| 303 | 2 s_elect m # the 2nd major cell (row) | {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{m}} | 2 select m |
| 314 | -1 t_ake m; 1 d_rop m # take and drop count from the end when negative | {-1}\ {\mathrm{\underline{t}ake}}\ {\mathrm{m}}{\diamond}\ {1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{m}} | −1 take m⋄ 1 drop m |
| 326 | (f_irst m) c_at 7 8 9 # join along the leading axis | {(}{\mathrm{\underline{f}irst}}\ {\mathrm{m}}{)}\ {\mathrm{\underline{c}at}}\ {7}\ {8}\ {9} | (first m) cat 7 8 9 |
| 337 | r_avel m | {\mathrm{\underline{r}avel}}\ {\mathrm{m}} | ravel m |
| 348 | 10 ^ r_ev o_ffsets 3 # `o_ffsets` counts from 0: place values 100 10 1 | {10}\ {\mathbin{\hat{}}}\ {\mathrm{\underline{r}ev}}\ {\mathrm{\underline{o}ffsets}}\ {3} | 10 ^ rev offsets 3 |
| 362 | m c_at_2 0 9 # ... or along axis 2: a column on the right | {\mathrm{m}}\ {{\mathrm{\underline{c}at}}_{2}}\ {0}\ {9} | m cat2 0 9 |
| 374 | 1 0 2 r_eplicate 7 8 9 # replicate: each item, as many times as its count | {1}\ {0}\ {2}\ {\mathrm{\underline{r}eplicate}}\ {7}\ {8}\ {9} | 1 0 2 replicate 7 8 9 |
| 385 | 10 10 10 e_ncode 123 # encode: the digits, in the radices on the left | {10}\ {10}\ {10}\ {\mathrm{\underline{e}ncode}}\ {123} | 10 10 10 encode 123 |
| 396 | 24 60 60 d_ecode 1 2 5 # decode: 1 hour 2 minutes 5 seconds, in seconds | {24}\ {60}\ {60}\ {\mathrm{\underline{d}ecode}}\ {1}\ {2}\ {5} | 24 60 60 decode 1 2 5 |
| 416 | u:s_quare := { _r * _r } # `_r` is the right argument | {{}^{\mathrm{u}}\mathrm{\underline{s}quare}}\ {\leftarrow}\ {\{}\ {\_\mathrm{r}}\ {\times}\ {\_\mathrm{r}}\ {\}} | usquare ← { _r × _r } |
| 417 | u:s_quare 1 2 3 # scalar functions work on arrays unchanged | {{}^{\mathrm{u}}\mathrm{\underline{s}quare}}\ {1}\ {2}\ {3} | usquare 1 2 3 |
| 429 | u:s_ub := { _l - _r } # `_l` is the left argument | {{}^{\mathrm{u}}\mathrm{\underline{s}ub}}\ {\leftarrow}\ {\{}\ {\_\mathrm{l}}\ {-}\ {\_\mathrm{r}}\ {\}} | usub ← { _l − _r } |
| 430 | 10 u:s_ub 3 # dyadic use is currying: `(u:s_ub 10) 3` | {10}\ {{}^{\mathrm{u}}\mathrm{\underline{s}ub}}\ {3} | 10 usub 3 |
| 442 | u:h_yp := { a b -> ((a * a) + b * b) ^ 0.5 } # named parameters before `->` | {{}^{\mathrm{u}}\mathrm{\underline{h}yp}}\ {\leftarrow}\ {\{}\ {\mathrm{a}}\ {\mathrm{b}}\ {\to}\ {(}{(}{\mathrm{a}}\ {\times}\ {\mathrm{a}}{)}\ {+}\ {\mathrm{b}}\ {\times}\ {\mathrm{b}}{)}\ {\mathbin{\hat{}}}\ {0.5}\ {\}} | uhyp ← { a b → ((a × a) + b × b) ^ 0.5 } |
| 443 | 3 u:h_yp 4 | {3}\ {{}^{\mathrm{u}}\mathrm{\underline{h}yp}}\ {4} | 3 uhyp 4 |
| 458 | u:s_ign := { x -> x < 0 ? -1; x = 0 ? 0; 1 } # guards: condition `?` result | {{}^{\mathrm{u}}\mathrm{\underline{s}ign}}\ {\leftarrow}\ {\{}\ {\mathrm{x}}\ {\to}\ {\mathrm{x}}\ {<}\ {0}\ {?}\ {-1}{\diamond}\ {\mathrm{x}}\ {=}\ {0}\ {?}\ {0}{\diamond}\ {1}\ {\}} | usign ← { x → x < 0 ? −1⋄ x = 0 ? 0⋄ 1 } |
| 459 | u:f_act := { n -> | {{}^{\mathrm{u}}\mathrm{\underline{f}act}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\to} | ufact ← { n → |
| 460 | n <= 1 ? 1 | \ \ {\mathrm{n}}\ {\leq}\ {1}\ {?}\ {1} | n ≤ 1 ? 1 |
| 461 | n * u:f_act n - 1 | \ \ {\mathrm{n}}\ {\times}\ {{}^{\mathrm{u}}\mathrm{\underline{f}act}}\ {\mathrm{n}}\ {-}\ {1} | n × ufact n − 1 |
| 462 | } | {\}} | } |
| 472 | u:f_act 10 # recursion | {{}^{\mathrm{u}}\mathrm{\underline{f}act}}\ {10} | ufact 10 |
| 484 | u:t_wo := { @ -> 2 } # a niladic function takes `@` | {{}^{\mathrm{u}}\mathrm{\underline{t}wo}}\ {\leftarrow}\ {\{}\ {@}\ {\to}\ {2}\ {\}} | utwo ← { @ → 2 } |
| 485 | u:t_wo @ | {{}^{\mathrm{u}}\mathrm{\underline{t}wo}}\ {@} | utwo @ |
| 497 | u:k_eep := { a ~_u -> a } # `_u` is a parameter nothing reads; the | {{}^{\mathrm{u}}\mathrm{\underline{k}eep}}\ {\leftarrow}\ {\{}\ {\mathrm{a}}\ {\sim}{\_\mathrm{u}}\ {\to}\ {\mathrm{a}}\ {\}} | ukeep ← { a ∼_u → a } |
| 498 | 7 u:k_eep 1 / 0 # tilde makes it lazy: no division by zero | {7}\ {{}^{\mathrm{u}}\mathrm{\underline{k}eep}}\ {1}\ {\div}\ {0} | 7 ukeep 1 ÷ 0 |
| 509 | (u:s_ub 100)_ 1 # `(expr)_` applies a function value | {\underline{(}}{{}^{\mathrm{u}}\mathrm{\underline{s}ub}}\ {100}{\underline{)}}\ {1} | (usub 100) 1 |
| 521 | u:t_wice := { f_ x -> f_ f_ x } # apply a function parameter two times | {{}^{\mathrm{u}}\mathrm{\underline{t}wice}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{f}}}\ {\mathrm{x}}\ {\to}\ {\mathrm{\underline{f}}}\ {\mathrm{\underline{f}}}\ {\mathrm{x}}\ {\}} | utwice ← { f x → f f x } |
| 522 | '{ _r + 10 } u:t_wice 3 # 3 + 10 + 10 | {\text{'}}{\{}\ {\_\mathrm{r}}\ {+}\ {10}\ {\}}\ {{}^{\mathrm{u}}\mathrm{\underline{t}wice}}\ {3} | ’{ _r + 10 } utwice 3 |
| 533 | 'u:s_quare u:t_wice 3 # square (square 3) = 9 squared | {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{s}quare}}\ {{}^{\mathrm{u}}\mathrm{\underline{t}wice}}\ {3} | ’usquare utwice 3 |
| 552 | '+ r_/ 1 2 3 4 # a quoted function is the operand of `r_/` (reduce) | {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {1}\ {2}\ {3}\ {4} | ’+ r/ 1 2 3 4 |
| 563 | '- r_/ 1 2 3 # reduce folds from the right: 1 - (2 - 3) | {\text{'}}{-}\ {\mathrm{\underline{r}}{/}}\ {1}\ {2}\ {3} | ’− r/ 1 2 3 |
| 574 | '+ s_\ 1 2 3 4 # scan: the prefix reductions | {\text{'}}{+}\ {\mathrm{\underline{s}}{\backslash}}\ {1}\ {2}\ {3}\ {4} | ’+ s\ 1 2 3 4 |
| 585 | '+ r_/ m # the leading axis: column sums | {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{m}} | ’+ r/ m |
| 596 | 'u:s_ign e_ach -5 0 5 # each: apply to every item | {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{s}ign}}\ {\mathrm{\underline{e}ach}}\ {-5}\ {0}\ {5} | ’usign each −5 0 5 |
| 607 | 1 2 3 '= e_ach 1 5 3 # dyadic each is currying | {1}\ {2}\ {3}\ {\text{'}}{=}\ {\mathrm{\underline{e}ach}}\ {1}\ {5}\ {3} | 1 2 3 ’= each 1 5 3 |
| 618 | 1 2 3 '* t_able 1 2 3 # table: the outer product | {1}\ {2}\ {3}\ {\text{'}}{\times}\ {\mathrm{\underline{t}able}}\ {1}\ {2}\ {3} | 1 2 3 ’× table 1 2 3 |
| 631 | m '+ '* i_nner 1 1 1 # inner product: the nearest operand pairs | {\mathrm{m}}\ {\text{'}}{+}\ {\text{'}}{\times}\ {\mathrm{\underline{i}nner}}\ {1}\ {1}\ {1} | m ’+ ’× inner 1 1 1 |
| 642 | 'n_eg 'a_bs c_ompose -4 # compose: the nearest operand applies first | {\text{'}}{\mathrm{\underline{n}eg}}\ {\text{'}}{\mathrm{\underline{a}bs}}\ {\mathrm{\underline{c}ompose}}\ {-4} | ’neg ’abs compose −4 |
| 653 | 2 '/ s_wap 1 # swap the arguments: 1 / 2 | {2}\ {\text{'}}{\div}\ {\mathrm{\underline{s}wap}}\ {1} | 2 ’÷ swap 1 |
| 664 | '{ _l + _r } r_/ 1 2 3 # a quoted lambda is an operand too | {\text{'}}{\{}\ {\_\mathrm{l}}\ {+}\ {\_\mathrm{r}}\ {\}}\ {\mathrm{\underline{r}}{/}}\ {1}\ {2}\ {3} | ’{ _l + _r } r/ 1 2 3 |
| 685 | u:a_vg := ['+ r_/ / t_ally] # fork: `('+ r_/ x) / t_ally x` | {{}^{\mathrm{u}}\mathrm{\underline{a}vg}}\ {\leftarrow}\ {[}{\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\div}\ {\mathrm{\underline{t}ally}}{]} | uavg ← [’+ r/ ÷ tally] |
| 686 | u:a_vg 1 2 3 4 | {{}^{\mathrm{u}}\mathrm{\underline{a}vg}}\ {1}\ {2}\ {3}\ {4} | uavg 1 2 3 4 |
| 687 | { x -> ('+ r_/ x) / t_ally x } 1 2 3 4 # the same, spelled out | {\{}\ {\mathrm{x}}\ {\to}\ {(}{\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{x}}{)}\ {\div}\ {\mathrm{\underline{t}ally}}\ {\mathrm{x}}\ {\}}\ {1}\ {2}\ {3}\ {4} | { x → (’+ r/ x) ÷ tally x } 1 2 3 4 |
| 699 | [n_eg a_bs] -5 # atop: `n_eg a_bs x` | {[}{\mathrm{\underline{n}eg}}\ {\mathrm{\underline{a}bs}}{]}\ {-5} | [neg abs] −5 |
| 710 | 3 [l_eft + r_ight] 4 # dyadic fork: `(x l_eft y) + (x r_ight y)`, so `x + y` | {3}\ {[}{\mathrm{\underline{l}eft}}\ {+}\ {\mathrm{\underline{r}ight}}{]}\ {4} | 3 [left + right] 4 |
| 721 | [i_d - n_eg] 5 # hook: `x - n_eg x` | {[}{\mathrm{\underline{i}d}}\ {-}\ {\mathrm{\underline{n}eg}}{]}\ {5} | [id − neg] 5 |
| 736 | 1 2 [+ * -] 3 4 # dyadic fork: `(x + y) * (x - y)` | {1}\ {2}\ {[}{+}\ {\times}\ {-}{]}\ {3}\ {4} | 1 2 [+ × −] 3 4 |
| 747 | [f_irst c_at 'm_ax r_/ c_at 'm_in r_/] 3 1 4 1 5 # `(f_irst x) c_at ('m_ax r_/ x) c_at 'm_in r_/ x` | {[}{\mathrm{\underline{f}irst}}\ {\mathrm{\underline{c}at}}\ {\text{'}}{\mathrm{\underline{m}ax}}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{\underline{c}at}}\ {\text{'}}{\mathrm{\underline{m}in}}\ {\mathrm{\underline{r}}{/}}{]}\ {3}\ {1}\ {4}\ {1}\ {5} | [first cat ’max r/ cat ’min r/] 3 1 4 1 5 |
| 758 | '[t_ally d_isclose] e_ach "ab" "cde" "f" # each item i: `t_ally d_isclose i` | {\text{'}}{[}{\mathrm{\underline{t}ally}}\ {\mathrm{\underline{d}isclose}}{]}\ {\mathrm{\underline{e}ach}}\ {\text{"ab"}}\ {\text{"cde"}}\ {\text{"f"}} | ’[tally disclose] each "ab" "cde" "f" |
| 776 | 1 o_- 1 2 3 4 # rotate toward the front | {1}\ {\mathrm{\underline{o}}{-}}\ {1}\ {2}\ {3}\ {4} | 1 o− 1 2 3 4 |
| 787 | r_ev "stressed" | {\mathrm{\underline{r}ev}}\ {\text{"stressed"}} | rev "stressed" |
| 820 | '+ r_/ m # implicit: axis 1, so column sums | {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{m}} | ’+ r/ m |
| 831 | '+ r_/_1 m # the same, explicit | {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{1}}\ {\mathrm{m}} | ’+ r/1 m |
| 842 | '+ r_/_2 m # axis 2: row sums | {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{2}}\ {\mathrm{m}} | ’+ r/2 m |
| 853 | '+ s_\_2 m # running sums along each row | {\text{'}}{+}\ {{\mathrm{\underline{s}}{\backslash}}_{2}}\ {\mathrm{m}} | ’+ s\2 m |
| 865 | 1 o_- m # rotate the rows (axis 1) | {1}\ {\mathrm{\underline{o}}{-}}\ {\mathrm{m}} | 1 o− m |
| 877 | 1 o_-_1 m # the same, explicit | {1}\ {{\mathrm{\underline{o}}{-}}_{1}}\ {\mathrm{m}} | 1 o−1 m |
| 889 | 1 o_-_2 m # rotate within each row (axis 2) | {1}\ {{\mathrm{\underline{o}}{-}}_{2}}\ {\mathrm{m}} | 1 o−2 m |
| 901 | r_ev_2 m # reverse each row | {{\mathrm{\underline{r}ev}}_{2}}\ {\mathrm{m}} | rev2 m |
| 913 | '+ r_/_12 m # two axes in turn: the total | {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{12}}\ {\mathrm{m}} | ’+ r/12 m |
| 924 | -1 0 1 o_- 1 2 3 # a list of amounts gives every rotation | {-1}\ {0}\ {1}\ {\mathrm{\underline{o}}{-}}\ {1}\ {2}\ {3} | −1 0 1 o− 1 2 3 |
| 937 | s_hape -1 0 1 o_-_12 m # every combination along both axes: 3 3 2 3 | {\mathrm{\underline{s}hape}}\ {-1}\ {0}\ {1}\ {{\mathrm{\underline{o}}{-}}_{12}}\ {\mathrm{m}} | shape −1 0 1 o−12 m |
| 952 | o_\ m # transpose: rows become columns | {\mathrm{\underline{o}}{\backslash}}\ {\mathrm{m}} | o\ m |
| 968 | a := 2 3 4 r_eshape r_ange 24 | {\mathrm{a}}\ {\leftarrow}\ {2}\ {3}\ {4}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{\underline{r}ange}}\ {24} | a ← 2 3 4 reshape range 24 |
| 969 | s_hape o_\ a # every axis reversed: 4 3 2 | {\mathrm{\underline{s}hape}}\ {\mathrm{\underline{o}}{\backslash}}\ {\mathrm{a}} | shape o\ a |
| 970 | s_hape o_\_23 a # axes 2 and 3 swapped: 2 4 3 | {\mathrm{\underline{s}hape}}\ {{\mathrm{\underline{o}}{\backslash}}_{23}}\ {\mathrm{a}} | shape o\23 a |
| 971 | s_hape 3 1 2 t_ranspose a # axis 1 to 3, 2 to 1, 3 to 2: 3 4 2 | {\mathrm{\underline{s}hape}}\ {3}\ {1}\ {2}\ {\mathrm{\underline{t}ranspose}}\ {\mathrm{a}} | shape 3 1 2 transpose a |
| 991 | v := 3 1 4 1 5 9 2 6 | {\mathrm{v}}\ {\leftarrow}\ {3}\ {1}\ {4}\ {1}\ {5}\ {9}\ {2}\ {6} | v ← 3 1 4 1 5 9 2 6 |
| 992 | s_ort v; g_rade v # sort, and the indices that sort | {\mathrm{\underline{s}ort}}\ {\mathrm{v}}{\diamond}\ {\mathrm{\underline{g}rade}}\ {\mathrm{v}} | sort v⋄ grade v |
| 1004 | u_nique v | {\mathrm{\underline{u}nique}}\ {\mathrm{v}} | unique v |
| 1015 | v i_ndexOf 5 7 # 7 is absent: tally + 1 | {\mathrm{v}}\ {\mathrm{\underline{i}ndexOf}}\ {5}\ {7} | v indexOf 5 7 |
| 1026 | 2 7 m_ember? v | {2}\ {7}\ {\mathrm{\underline{m}ember}{?}}\ {\mathrm{v}} | 2 7 member? v |
| 1037 | w_here v > 4 # indices of the 1s | {\mathrm{\underline{w}here}}\ {\mathrm{v}}\ {>}\ {4} | where v > 4 |
| 1055 | n := "ab" "cde" # a strand of strings: a vector of 2 boxes | {\mathrm{n}}\ {\leftarrow}\ {\text{"ab"}}\ {\text{"cde"}} | n ← "ab" "cde" |
| 1056 | n # nested values print framed (APL2's DISPLAY) | {\mathrm{n}} | n |
| 1071 | t_ally n | {\mathrm{\underline{t}ally}}\ {\mathrm{n}} | tally n |
| 1082 | d_isclose 2 s_elect n # open the 2nd box | {\mathrm{\underline{d}isclose}}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{n}} | disclose 2 select n |
| 1098 | s := "to be or not" | {\mathrm{s}}\ {\leftarrow}\ {\text{"to be or not"}} | s ← "to be or not" |
| 1099 | (s != f_irst " ") p_artition s # cut where the mask is 0: the words, boxed | {(}{\mathrm{s}}\ {\neq}\ {\mathrm{\underline{f}irst}}\ {\text{" "}}{)}\ {\mathrm{\underline{p}artition}}\ {\mathrm{s}} | (s = first " ") partition s |
| 1114 | 'r_ange m_ap 1 2 3 # map: each result boxed, so it may be an array | {\text{'}}{\mathrm{\underline{r}ange}}\ {\mathrm{\underline{m}ap}}\ {1}\ {2}\ {3} | ’range map 1 2 3 |
| 1132 | d_isplay m # any value framed, as a character matrix (xetal --box prints all so) | {\mathrm{\underline{d}isplay}}\ {\mathrm{m}} | display m |
| 1151 | r_oll! 6 6 6 # three dice: random 1..6 each, so every run differs | {\mathrm{\underline{r}oll}{!}}\ {6}\ {6}\ {6} | roll! 6 6 6 |
| 1162 | r_oll! 6 6 6 # (and each line rolls again) | {\mathrm{\underline{r}oll}{!}}\ {6}\ {6}\ {6} | roll! 6 6 6 |
| 1173 | r_oll! 6 6 6 | {\mathrm{\underline{r}oll}{!}}\ {6}\ {6}\ {6} | roll! 6 6 6 |
| 1184 | p_rint! "printed, then returned" # `p_rint!` prints and returns its argument | {\mathrm{\underline{p}rint}{!}}\ {\text{"printed, then returned"}} | print! "printed, then returned" |
| 1203 | 15 t_ake []G_RID 2 2 r_eshape 1 0 0 1 | {15}\ {\mathrm{\underline{t}ake}}\ {\square \mathrm{\underline{G}RID}}\ {2}\ {2}\ {\mathrm{\underline{r}eshape}}\ {1}\ {0}\ {0}\ {1} | 15 take □GRID 2 2 reshape 1 0 0 1 |
| 1222 | "s:" u_se< "Stats" # import a library under an alias of your choosing | {\text{"s:"}}\ {\mathrm{\underline{u}se}{<}}\ {\text{"Stats"}} | "s:" use< "Stats" |
| 1223 | s:m_ean 2 4 4 4 5 5 7 9 # its exported names, used through the alias | {{}^{\mathrm{s}}\mathrm{\underline{m}ean}}\ {2}\ {4}\ {4}\ {4}\ {5}\ {5}\ {7}\ {9} | smean 2 4 4 4 5 5 7 9 |
| 1234 | s:s_d 2 4 4 4 5 5 7 9 # the standard deviation | {{}^{\mathrm{s}}\mathrm{\underline{s}d}}\ {2}\ {4}\ {4}\ {4}\ {5}\ {5}\ {7}\ {9} | ssd 2 4 4 4 5 5 7 9 |
| 1245 | s:s_pread 3 1 4 1 5 # largest minus smallest | {{}^{\mathrm{s}}\mathrm{\underline{s}pread}}\ {3}\ {1}\ {4}\ {1}\ {5} | sspread 3 1 4 1 5 |
| 1259 | "hi:" u_se< "Hello" # a library of your own, found in userlibs/ | {\text{"hi:"}}\ {\mathrm{\underline{u}se}{<}}\ {\text{"Hello"}} | "hi:" use< "Hello" |
| 1260 | hi:h_ello @ # niladic: called with Unit | {{}^{\mathrm{hi}}\mathrm{\underline{h}ello}}\ {@} | hihello @ |
| 1281 | "c:" u_se< "Combinators" # Smullyan's birds, a standard library | {\text{"c:"}}\ {\mathrm{\underline{u}se}{<}}\ {\text{"Combinators"}} | "c:" use< "Combinators" |
| 1282 | 1 c:K_ 2 # K keeps its first argument | {1}\ {{}^{\mathrm{c}}\mathrm{\underline{K}}}\ {2} | 1 cK 2 |
| 1293 | 10 '- c:C_ 3 # C swaps the arguments: 3 - 10 | {10}\ {\text{'}}{-}\ {{}^{\mathrm{c}}\mathrm{\underline{C}}}\ {3} | 10 ’− cC 3 |
| 1304 | 'n_eg 'a_bs c:B_ -5 # B composes, the nearest operand last: a_bs n_eg -5 | {\text{'}}{\mathrm{\underline{n}eg}}\ {\text{'}}{\mathrm{\underline{a}bs}}\ {{}^{\mathrm{c}}\mathrm{\underline{B}}}\ {-5} | ’neg ’abs cB −5 |
| 1315 | '* c:W_ 4 # W uses its argument twice: 4 * 4 | {\text{'}}{\times}\ {{}^{\mathrm{c}}\mathrm{\underline{W}}}\ {4} | ’× cW 4 |
| 1330 | u:t_riangle := { ~s_elf n -> n <= 1 ? 1; n + s_elf n - 1 } | {{}^{\mathrm{u}}\mathrm{\underline{t}riangle}}\ {\leftarrow}\ {\{}\ {\sim}{\mathrm{\underline{s}elf}}\ {\mathrm{n}}\ {\to}\ {\mathrm{n}}\ {\leq}\ {1}\ {?}\ {1}{\diamond}\ {\mathrm{n}}\ {+}\ {\mathrm{\underline{s}elf}}\ {\mathrm{n}}\ {-}\ {1}\ {\}} | utriangle ← { ∼self n → n ≤ 1 ? 1⋄ n + self n − 1 } |
| 1331 | 'u:t_riangle c:Y_ 5 # Y: recursion, from a function handed itself: 1+2+3+4+5 | {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{t}riangle}}\ {{}^{\mathrm{c}}\mathrm{\underline{Y}}}\ {5} | ’utriangle cY 5 |
| 1345 | n_eg^3 5 # a superscript repeats a function: n_eg three times | {\mathrm{\underline{n}eg}}^{3}\ {5} | neg3 5 |
| 1363 | (1 2 3, 4.5, "abc") # a tuple: several values of their own types side by side | {(}{1}\ {2}\ {3}{,}\ {4.5}{,}\ {\text{"abc"}}{)} | (1 2 3, 4.5, "abc") |
| 1380 | u:s_wapped := { (a, b) -> (b, a) } | {{}^{\mathrm{u}}\mathrm{\underline{s}wapped}}\ {\leftarrow}\ {\{}\ {(}{\mathrm{a}}{,}\ {\mathrm{b}}{)}\ {\to}\ {(}{\mathrm{b}}{,}\ {\mathrm{a}}{)}\ {\}} | uswapped ← { (a, b) → (b, a) } |
| 1381 | u:s_wapped (1, "x") | {{}^{\mathrm{u}}\mathrm{\underline{s}wapped}}\ {(}{1}{,}\ {\text{"x"}}{)} | uswapped (1, "x") |
| 1393 | (n, (x, _)) := (3, (2.5, "unused")) # a pattern binds names; _ ignores a part | {(}{\mathrm{n}}{,}\ {(}{\mathrm{x}}{,}\ {\_}{)}{)}\ {\leftarrow}\ {(}{3}{,}\ {(}{2.5}{,}\ {\text{"unused"}}{)}{)} | (n, (x, _)) ← (3, (2.5, "unused")) |
| 1394 | x * f_loat n | {\mathrm{x}}\ {\times}\ {\mathrm{\underline{f}loat}}\ {\mathrm{n}} | x × float n |
| 1411 | u:s_tep := { (w, k) -> (w * 0.5, k + 1) } | {{}^{\mathrm{u}}\mathrm{\underline{s}tep}}\ {\leftarrow}\ {\{}\ {(}{\mathrm{w}}{,}\ {\mathrm{k}}{)}\ {\to}\ {(}{\mathrm{w}}\ {\times}\ {0.5}{,}\ {\mathrm{k}}\ {+}\ {1}{)}\ {\}} | ustep ← { (w, k) → (w × 0.5, k + 1) } |
| 1412 | 3 'u:s_tep p_ower (8.0 4.0, 0) | {3}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{s}tep}}\ {\mathrm{\underline{p}ower}}\ {(}{8.0}\ {4.0}{,}\ {0}{)} | 3 ’ustep power (8.0 4.0, 0) |
| 1428 | (1, 2.5) m_atch (1, 2.5) # m_atch compares tuples part by part | {(}{1}{,}\ {2.5}{)}\ {\mathrm{\underline{m}atch}}\ {(}{1}{,}\ {2.5}{)} | (1, 2.5) match (1, 2.5) |
| 1429 | '{ k -> (k, f_loat k) } m_ap 1 2 # boxed tuples: an array of tuples | {\text{'}}{\{}\ {\mathrm{k}}\ {\to}\ {(}{\mathrm{k}}{,}\ {\mathrm{\underline{f}loat}}\ {\mathrm{k}}{)}\ {\}}\ {\mathrm{\underline{m}ap}}\ {1}\ {2} | ’{ k → (k, float k) } map 1 2 |
| 1453 | u:l_ife := { ('+ r_/_12 -1 0 1 o_-_12 _r) { (_l = 3) + _r * _l = 4 } _r } | {{}^{\mathrm{u}}\mathrm{\underline{l}ife}}\ {\leftarrow}\ {\{}\ {(}{\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{12}}\ {-1}\ {0}\ {1}\ {{\mathrm{\underline{o}}{-}}_{12}}\ {\_\mathrm{r}}{)}\ {\{}\ {(}{\_\mathrm{l}}\ {=}\ {3}{)}\ {+}\ {\_\mathrm{r}}\ {\times}\ {\_\mathrm{l}}\ {=}\ {4}\ {\}}\ {\_\mathrm{r}}\ {\}} | ulife ← { (’+ r/12 −1 0 1 o−12 _r) { (_l = 3) + _r × _l = 4 } _r } |
| 1454 | u:l_ife 5 5 r_eshape 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 | {{}^{\mathrm{u}}\mathrm{\underline{l}ife}}\ {5}\ {5}\ {\mathrm{\underline{r}eshape}}\ {0}\ {0}\ {0}\ {0}\ {0}\ {0}\ {0}\ {1}\ {0}\ {0}\ {0}\ {0}\ {1}\ {0}\ {0}\ {0}\ {0}\ {1}\ {0}\ {0}\ {0}\ {0}\ {0}\ {0}\ {0} | ulife 5 5 reshape 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 |
| 27 | (1 2 3, 4.5, "abc") | {(}{1}\ {2}\ {3}{,}\ {4.5}{,}\ {\text{"abc"}}{)} | (1 2 3, 4.5, "abc") |
| 45 | (n, (x, _)) := (3, (2.5, "unused")) | {(}{\mathrm{n}}{,}\ {(}{\mathrm{x}}{,}\ {\_}{)}{)}\ {\leftarrow}\ {(}{3}{,}\ {(}{2.5}{,}\ {\text{"unused"}}{)}{)} | (n, (x, _)) ← (3, (2.5, "unused")) |
| 46 | x * f_loat n | {\mathrm{x}}\ {\times}\ {\mathrm{\underline{f}loat}}\ {\mathrm{n}} | x × float n |
| 47 | u:s_wapped := { (a, b) -> (b, a) } | {{}^{\mathrm{u}}\mathrm{\underline{s}wapped}}\ {\leftarrow}\ {\{}\ {(}{\mathrm{a}}{,}\ {\mathrm{b}}{)}\ {\to}\ {(}{\mathrm{b}}{,}\ {\mathrm{a}}{)}\ {\}} | uswapped ← { (a, b) → (b, a) } |
| 48 | u:s_wapped (1, "x") | {{}^{\mathrm{u}}\mathrm{\underline{s}wapped}}\ {(}{1}{,}\ {\text{"x"}}{)} | uswapped (1, "x") |
| 73 | target1 := 1.0 2.0 3.0 | {\mathrm{target1}}\ {\leftarrow}\ {1.0}\ {2.0}\ {3.0} | target1 ← 1.0 2.0 3.0 |
| 74 | target2 := 2 2 r_eshape 0.5 -0.5 0.25 -0.25 | {\mathrm{target2}}\ {\leftarrow}\ {2}\ {2}\ {\mathrm{\underline{r}eshape}}\ {0.5}\ {-0.5}\ {0.25}\ {-0.25} | target2 ← 2 2 reshape 0.5 −0.5 0.25 −0.25 |
| 75 | u:g_rad := { W1 W2 -> (e_nclose 2.0 * W1 - target1) c_at e_nclose 2.0 * W2 - target2 } | {{}^{\mathrm{u}}\mathrm{\underline{g}rad}}\ {\leftarrow}\ {\{}\ {\mathrm{W1}}\ {\mathrm{W2}}\ {\to}\ {(}{\mathrm{\underline{e}nclose}}\ {2.0}\ {\times}\ {\mathrm{W1}}\ {-}\ {\mathrm{target1}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{e}nclose}}\ {2.0}\ {\times}\ {\mathrm{W2}}\ {-}\ {\mathrm{target2}}\ {\}} | ugrad ← { W1 W2 → (enclose 2.0 × W1 − target1) cat enclose 2.0 × W2 − target2 } |
| 76 | lr := 0.1 | {\mathrm{lr}}\ {\leftarrow}\ {0.1} | lr ← 0.1 |
| 77 | u:r_ound := { a -> (f_loat f_loor 0.5 + 1000.0 * a) / 1000.0 } | {{}^{\mathrm{u}}\mathrm{\underline{r}ound}}\ {\leftarrow}\ {\{}\ {\mathrm{a}}\ {\to}\ {(}{\mathrm{\underline{f}loat}}\ {\mathrm{\underline{f}loor}}\ {0.5}\ {+}\ {1000.0}\ {\times}\ {\mathrm{a}}{)}\ {\div}\ {1000.0}\ {\}} | uround ← { a → (float floor 0.5 + 1000.0 × a) ÷ 1000.0 } |
| 113 | u:m_oveBy := { mv k -> ((d_isclose 1 s_elect mv) / 1.0 - 0.9 ^ k) / 0.00000001 + ((d_isclose 2 s_elect mv) / 1.0 - 0.999 ^ k) ^ 0.5 } | {{}^{\mathrm{u}}\mathrm{\underline{m}oveBy}}\ {\leftarrow}\ {\{}\ {\mathrm{mv}}\ {\mathrm{k}}\ {\to}\ {(}{(}{\mathrm{\underline{d}isclose}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{mv}}{)}\ {\div}\ {1.0}\ {-}\ {0.9}\ {\mathbin{\hat{}}}\ {\mathrm{k}}{)}\ {\div}\ {0.00000001}\ {+}\ {(}{(}{\mathrm{\underline{d}isclose}}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{mv}}{)}\ {\div}\ {1.0}\ {-}\ {0.999}\ {\mathbin{\hat{}}}\ {\mathrm{k}}{)}\ {\mathbin{\hat{}}}\ {0.5}\ {\}} | umoveBy ← { mv k → ((disclose 1 select mv) ÷ 1.0 − 0.9 ^ k) ÷ 0.00000001 + ((disclose 2 select mv) ÷ 1.0 − 0.999 ^ k) ^ 0.5 } |
| 114 | u:p_acked := { s -> | {{}^{\mathrm{u}}\mathrm{\underline{p}acked}}\ {\leftarrow}\ {\{}\ {\mathrm{s}}\ {\to} | upacked ← { s → |
| 115 | W1 := d_isclose 1 s_elect s | \ \ {\mathrm{W1}}\ {\leftarrow}\ {\mathrm{\underline{d}isclose}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{s}} | W1 ← disclose 1 select s |
| 116 | W2 := d_isclose 2 s_elect s | \ \ {\mathrm{W2}}\ {\leftarrow}\ {\mathrm{\underline{d}isclose}}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{s}} | W2 ← disclose 2 select s |
| 117 | k := 1.0 + d_isclose 7 s_elect s | \ \ {\mathrm{k}}\ {\leftarrow}\ {1.0}\ {+}\ {\mathrm{\underline{d}isclose}}\ {7}\ {\mathrm{\underline{s}elect}}\ {\mathrm{s}} | k ← 1.0 + disclose 7 select s |
| 118 | g := W1 u:g_rad W2 | \ \ {\mathrm{g}}\ {\leftarrow}\ {\mathrm{W1}}\ {{}^{\mathrm{u}}\mathrm{\underline{g}rad}}\ {\mathrm{W2}} | g ← W1 ugrad W2 |
| 119 | G1 := d_isclose 1 s_elect g | \ \ {\mathrm{G1}}\ {\leftarrow}\ {\mathrm{\underline{d}isclose}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{g}} | G1 ← disclose 1 select g |
| 120 | G2 := d_isclose 2 s_elect g | \ \ {\mathrm{G2}}\ {\leftarrow}\ {\mathrm{\underline{d}isclose}}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{g}} | G2 ← disclose 2 select g |
| 121 | M1 := (0.9 * d_isclose 3 s_elect s) + 0.1 * G1 | \ \ {\mathrm{M1}}\ {\leftarrow}\ {(}{0.9}\ {\times}\ {\mathrm{\underline{d}isclose}}\ {3}\ {\mathrm{\underline{s}elect}}\ {\mathrm{s}}{)}\ {+}\ {0.1}\ {\times}\ {\mathrm{G1}} | M1 ← (0.9 × disclose 3 select s) + 0.1 × G1 |
| 122 | M2 := (0.9 * d_isclose 4 s_elect s) + 0.1 * G2 | \ \ {\mathrm{M2}}\ {\leftarrow}\ {(}{0.9}\ {\times}\ {\mathrm{\underline{d}isclose}}\ {4}\ {\mathrm{\underline{s}elect}}\ {\mathrm{s}}{)}\ {+}\ {0.1}\ {\times}\ {\mathrm{G2}} | M2 ← (0.9 × disclose 4 select s) + 0.1 × G2 |
| 123 | V1 := (0.999 * d_isclose 5 s_elect s) + 0.001 * G1 * G1 | \ \ {\mathrm{V1}}\ {\leftarrow}\ {(}{0.999}\ {\times}\ {\mathrm{\underline{d}isclose}}\ {5}\ {\mathrm{\underline{s}elect}}\ {\mathrm{s}}{)}\ {+}\ {0.001}\ {\times}\ {\mathrm{G1}}\ {\times}\ {\mathrm{G1}} | V1 ← (0.999 × disclose 5 select s) + 0.001 × G1 × G1 |
| 124 | V2 := (0.999 * d_isclose 6 s_elect s) + 0.001 * G2 * G2 | \ \ {\mathrm{V2}}\ {\leftarrow}\ {(}{0.999}\ {\times}\ {\mathrm{\underline{d}isclose}}\ {6}\ {\mathrm{\underline{s}elect}}\ {\mathrm{s}}{)}\ {+}\ {0.001}\ {\times}\ {\mathrm{G2}}\ {\times}\ {\mathrm{G2}} | V2 ← (0.999 × disclose 6 select s) + 0.001 × G2 × G2 |
| 125 | N1 := W1 - lr * ((e_nclose M1) c_at e_nclose V1) u:m_oveBy k | \ \ {\mathrm{N1}}\ {\leftarrow}\ {\mathrm{W1}}\ {-}\ {\mathrm{lr}}\ {\times}\ {(}{(}{\mathrm{\underline{e}nclose}}\ {\mathrm{M1}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{e}nclose}}\ {\mathrm{V1}}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{m}oveBy}}\ {\mathrm{k}} | N1 ← W1 − lr × ((enclose M1) cat enclose V1) umoveBy k |
| 126 | N2 := W2 - lr * ((e_nclose M2) c_at e_nclose V2) u:m_oveBy k | \ \ {\mathrm{N2}}\ {\leftarrow}\ {\mathrm{W2}}\ {-}\ {\mathrm{lr}}\ {\times}\ {(}{(}{\mathrm{\underline{e}nclose}}\ {\mathrm{M2}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{e}nclose}}\ {\mathrm{V2}}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{m}oveBy}}\ {\mathrm{k}} | N2 ← W2 − lr × ((enclose M2) cat enclose V2) umoveBy k |
| 127 | (e_nclose N1) c_at (e_nclose N2) c_at (e_nclose M1) c_at (e_nclose M2) c_at (e_nclose V1) c_at (e_nclose V2) c_at e_nclose k | \ \ {(}{\mathrm{\underline{e}nclose}}\ {\mathrm{N1}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{e}nclose}}\ {\mathrm{N2}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{e}nclose}}\ {\mathrm{M1}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{e}nclose}}\ {\mathrm{M2}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{e}nclose}}\ {\mathrm{V1}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{e}nclose}}\ {\mathrm{V2}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{e}nclose}}\ {\mathrm{k}} | (enclose N1) cat (enclose N2) cat (enclose M1) cat (enclose M2) cat (enclose V1) cat (enclose V2) cat enclose k |
| 128 | } | {\}} | } |
| 129 | z1 := 0.0 0.0 0.0 | {\mathrm{z1}}\ {\leftarrow}\ {0.0}\ {0.0}\ {0.0} | z1 ← 0.0 0.0 0.0 |
| 130 | z2 := 2 2 r_eshape 0.0 | {\mathrm{z2}}\ {\leftarrow}\ {2}\ {2}\ {\mathrm{\underline{r}eshape}}\ {0.0} | z2 ← 2 2 reshape 0.0 |
| 131 | p0 := (e_nclose z1) c_at (e_nclose z2) c_at (e_nclose z1) c_at (e_nclose z2) c_at (e_nclose z1) c_at (e_nclose z2) c_at e_nclose 0.0 | {\mathrm{p0}}\ {\leftarrow}\ {(}{\mathrm{\underline{e}nclose}}\ {\mathrm{z1}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{e}nclose}}\ {\mathrm{z2}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{e}nclose}}\ {\mathrm{z1}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{e}nclose}}\ {\mathrm{z2}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{e}nclose}}\ {\mathrm{z1}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{e}nclose}}\ {\mathrm{z2}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{e}nclose}}\ {0.0} | p0 ← (enclose z1) cat (enclose z2) cat (enclose z1) cat (enclose z2) cat (enclose z1) cat (enclose z2) cat enclose 0.0 |
| 132 | p := 200 'u:p_acked p_ower p0 | {\mathrm{p}}\ {\leftarrow}\ {200}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{p}acked}}\ {\mathrm{\underline{p}ower}}\ {\mathrm{p0}} | p ← 200 ’upacked power p0 |
| 133 | u:r_ound d_isclose 1 s_elect p | {{}^{\mathrm{u}}\mathrm{\underline{r}ound}}\ {\mathrm{\underline{d}isclose}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{p}} | uround disclose 1 select p |
| 165 | u:m_ove := { (m, v) k -> (m / 1.0 - 0.9 ^ k) / 0.00000001 + (v / 1.0 - 0.999 ^ k) ^ 0.5 } | {{}^{\mathrm{u}}\mathrm{\underline{m}ove}}\ {\leftarrow}\ {\{}\ {(}{\mathrm{m}}{,}\ {\mathrm{v}}{)}\ {\mathrm{k}}\ {\to}\ {(}{\mathrm{m}}\ {\div}\ {1.0}\ {-}\ {0.9}\ {\mathbin{\hat{}}}\ {\mathrm{k}}{)}\ {\div}\ {0.00000001}\ {+}\ {(}{\mathrm{v}}\ {\div}\ {1.0}\ {-}\ {0.999}\ {\mathbin{\hat{}}}\ {\mathrm{k}}{)}\ {\mathbin{\hat{}}}\ {0.5}\ {\}} | umove ← { (m, v) k → (m ÷ 1.0 − 0.9 ^ k) ÷ 0.00000001 + (v ÷ 1.0 − 0.999 ^ k) ^ 0.5 } |
| 166 | u:a_dam := { (W1, W2, M1, M2, V1, V2, k) -> | {{}^{\mathrm{u}}\mathrm{\underline{a}dam}}\ {\leftarrow}\ {\{}\ {(}{\mathrm{W1}}{,}\ {\mathrm{W2}}{,}\ {\mathrm{M1}}{,}\ {\mathrm{M2}}{,}\ {\mathrm{V1}}{,}\ {\mathrm{V2}}{,}\ {\mathrm{k}}{)}\ {\to} | uadam ← { (W1, W2, M1, M2, V1, V2, k) → |
| 167 | t := 1 + k | \ \ {\mathrm{t}}\ {\leftarrow}\ {1}\ {+}\ {\mathrm{k}} | t ← 1 + k |
| 168 | g := W1 u:g_rad W2 | \ \ {\mathrm{g}}\ {\leftarrow}\ {\mathrm{W1}}\ {{}^{\mathrm{u}}\mathrm{\underline{g}rad}}\ {\mathrm{W2}} | g ← W1 ugrad W2 |
| 169 | (G1, G2) := (d_isclose 1 s_elect g, d_isclose 2 s_elect g) | \ \ {(}{\mathrm{G1}}{,}\ {\mathrm{G2}}{)}\ {\leftarrow}\ {(}{\mathrm{\underline{d}isclose}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{g}}{,}\ {\mathrm{\underline{d}isclose}}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{g}}{)} | (G1, G2) ← (disclose 1 select g, disclose 2 select g) |
| 170 | m1 := (0.9 * M1) + 0.1 * G1 | \ \ {\mathrm{m1}}\ {\leftarrow}\ {(}{0.9}\ {\times}\ {\mathrm{M1}}{)}\ {+}\ {0.1}\ {\times}\ {\mathrm{G1}} | m1 ← (0.9 × M1) + 0.1 × G1 |
| 171 | m2 := (0.9 * M2) + 0.1 * G2 | \ \ {\mathrm{m2}}\ {\leftarrow}\ {(}{0.9}\ {\times}\ {\mathrm{M2}}{)}\ {+}\ {0.1}\ {\times}\ {\mathrm{G2}} | m2 ← (0.9 × M2) + 0.1 × G2 |
| 172 | v1 := (0.999 * V1) + 0.001 * G1 * G1 | \ \ {\mathrm{v1}}\ {\leftarrow}\ {(}{0.999}\ {\times}\ {\mathrm{V1}}{)}\ {+}\ {0.001}\ {\times}\ {\mathrm{G1}}\ {\times}\ {\mathrm{G1}} | v1 ← (0.999 × V1) + 0.001 × G1 × G1 |
| 173 | v2 := (0.999 * V2) + 0.001 * G2 * G2 | \ \ {\mathrm{v2}}\ {\leftarrow}\ {(}{0.999}\ {\times}\ {\mathrm{V2}}{)}\ {+}\ {0.001}\ {\times}\ {\mathrm{G2}}\ {\times}\ {\mathrm{G2}} | v2 ← (0.999 × V2) + 0.001 × G2 × G2 |
| 174 | (W1 - lr * (m1, v1) u:m_ove f_loat t, W2 - lr * (m2, v2) u:m_ove f_loat t, m1, m2, v1, v2, t) | \ \ {(}{\mathrm{W1}}\ {-}\ {\mathrm{lr}}\ {\times}\ {(}{\mathrm{m1}}{,}\ {\mathrm{v1}}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{m}ove}}\ {\mathrm{\underline{f}loat}}\ {\mathrm{t}}{,}\ {\mathrm{W2}}\ {-}\ {\mathrm{lr}}\ {\times}\ {(}{\mathrm{m2}}{,}\ {\mathrm{v2}}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{m}ove}}\ {\mathrm{\underline{f}loat}}\ {\mathrm{t}}{,}\ {\mathrm{m1}}{,}\ {\mathrm{m2}}{,}\ {\mathrm{v1}}{,}\ {\mathrm{v2}}{,}\ {\mathrm{t}}{)} | (W1 − lr × (m1, v1) umove float t, W2 − lr × (m2, v2) umove float t, m1, m2, v1, v2, t) |
| 175 | } | {\}} | } |
| 176 | s0 := (z1, z2, z1, z2, z1, z2, 0) | {\mathrm{s0}}\ {\leftarrow}\ {(}{\mathrm{z1}}{,}\ {\mathrm{z2}}{,}\ {\mathrm{z1}}{,}\ {\mathrm{z2}}{,}\ {\mathrm{z1}}{,}\ {\mathrm{z2}}{,}\ {0}{)} | s0 ← (z1, z2, z1, z2, z1, z2, 0) |
| 177 | (w1, w2, _, _, _, _, steps) := 200 'u:a_dam p_ower s0 | {(}{\mathrm{w1}}{,}\ {\mathrm{w2}}{,}\ {\_}{,}\ {\_}{,}\ {\_}{,}\ {\_}{,}\ {\mathrm{steps}}{)}\ {\leftarrow}\ {200}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}dam}}\ {\mathrm{\underline{p}ower}}\ {\mathrm{s0}} | (w1, w2, _, _, _, _, steps) ← 200 ’uadam power s0 |
| 178 | u:r_ound w1 | {{}^{\mathrm{u}}\mathrm{\underline{r}ound}}\ {\mathrm{w1}} | uround w1 |
| 179 | steps | {\mathrm{steps}} | steps |
| 197 | (u:r_ound w1) m_atch u:r_ound d_isclose 1 s_elect p | {(}{{}^{\mathrm{u}}\mathrm{\underline{r}ound}}\ {\mathrm{w1}}{)}\ {\mathrm{\underline{m}atch}}\ {{}^{\mathrm{u}}\mathrm{\underline{r}ound}}\ {\mathrm{\underline{d}isclose}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{p}} | (uround w1) match uround disclose 1 select p |
| 198 | (u:r_ound w2) m_atch u:r_ound d_isclose 2 s_elect p | {(}{{}^{\mathrm{u}}\mathrm{\underline{r}ound}}\ {\mathrm{w2}}{)}\ {\mathrm{\underline{m}atch}}\ {{}^{\mathrm{u}}\mathrm{\underline{r}ound}}\ {\mathrm{\underline{d}isclose}}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{p}} | (uround w2) match uround disclose 2 select p |
| 239 | "cm:" u_se< "Comparison" | {\text{"cm:"}}\ {\mathrm{\underline{u}se}{<}}\ {\text{"Comparison"}} | "cm:" use< "Comparison" |
| 240 | s := 31 cm:s_tart 7 | {\mathrm{s}}\ {\leftarrow}\ {31}\ {{}^{\mathrm{cm}}\mathrm{\underline{s}tart}}\ {7} | s ← 31 cmstart 7 |
| 241 | s | {\mathrm{s}} | s |
| 242 | cm:TOP cm:s_teps (cm:TOP, 7) cm:c_hoose s | {{}^{\mathrm{cm}}\mathrm{TOP}}\ {{}^{\mathrm{cm}}\mathrm{\underline{s}teps}}\ {(}{{}^{\mathrm{cm}}\mathrm{TOP}}{,}\ {7}{)}\ {{}^{\mathrm{cm}}\mathrm{\underline{c}hoose}}\ {\mathrm{s}} | cmTOP cmsteps (cmTOP, 7) cmchoose s |
| 243 | cm:TOP cm:a_ngle 0.1 cm:t_ick (cm:TOP, 7) cm:c_hoose s | {{}^{\mathrm{cm}}\mathrm{TOP}}\ {{}^{\mathrm{cm}}\mathrm{\underline{a}ngle}}\ {0.1}\ {{}^{\mathrm{cm}}\mathrm{\underline{t}ick}}\ {(}{{}^{\mathrm{cm}}\mathrm{TOP}}{,}\ {7}{)}\ {{}^{\mathrm{cm}}\mathrm{\underline{c}hoose}}\ {\mathrm{s}} | cmTOP cmangle 0.1 cmtick (cmTOP, 7) cmchoose s |
| 272 | '{ k -> (k, f_loat k) } m_ap 1 2 | {\text{'}}{\{}\ {\mathrm{k}}\ {\to}\ {(}{\mathrm{k}}{,}\ {\mathrm{\underline{f}loat}}\ {\mathrm{k}}{)}\ {\}}\ {\mathrm{\underline{m}ap}}\ {1}\ {2} | ’{ k → (k, float k) } map 1 2 |
| 11 | v := 3 1 2 | {\mathrm{v}}\ {\leftarrow}\ {3}\ {1}\ {2} | v ← 3 1 2 |
| 12 | M := 2 3 r_eshape r_ange 6 | {\mathrm{M}}\ {\leftarrow}\ {2}\ {3}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{\underline{r}ange}}\ {6} | M ← 2 3 reshape range 6 |
| 13 | N := 2 3 r_eshape 3 1 2 6 4 5 | {\mathrm{N}}\ {\leftarrow}\ {2}\ {3}\ {\mathrm{\underline{r}eshape}}\ {3}\ {1}\ {2}\ {6}\ {4}\ {5} | N ← 2 3 reshape 3 1 2 6 4 5 |
| 45 | 1 + 2 | {1}\ {+}\ {2} | 1 + 2 |
| 47 | 1 2 3 + 10 | {1}\ {2}\ {3}\ {+}\ {10} | 1 2 3 + 10 |
| 49 | M + 100 | {\mathrm{M}}\ {+}\ {100} | M + 100 |
| 62 | 10 - 3 | {10}\ {-}\ {3} | 10 − 3 |
| 64 | v - 1 | {\mathrm{v}}\ {-}\ {1} | v − 1 |
| 75 | 6 * 7 | {6}\ {\times}\ {7} | 6 × 7 |
| 77 | v * v | {\mathrm{v}}\ {\times}\ {\mathrm{v}} | v × v |
| 88 | 7 / 2 | {7}\ {\div}\ {2} | 7 ÷ 2 |
| 90 | 1 2 3 / 2 | {1}\ {2}\ {3}\ {\div}\ {2} | 1 2 3 ÷ 2 |
| 103 | 2 ^ 10 | {2}\ {\mathbin{\hat{}}}\ {10} | 2 ^ 10 |
| 105 | v ^ 2 | {\mathrm{v}}\ {\mathbin{\hat{}}}\ {2} | v ^ 2 |
| 116 | 3 m_ax 5 | {3}\ {\mathrm{\underline{m}ax}}\ {5} | 3 max 5 |
| 118 | 'm_ax r_/ v | {\text{'}}{\mathrm{\underline{m}ax}}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{v}} | ’max r/ v |
| 129 | 3 m_in 5 | {3}\ {\mathrm{\underline{m}in}}\ {5} | 3 min 5 |
| 131 | 2 m_in v | {2}\ {\mathrm{\underline{m}in}}\ {\mathrm{v}} | 2 min v |
| 142 | 7 d_iv 2 | {7}\ {\mathrm{\underline{d}iv}}\ {2} | 7 div 2 |
| 154 | 7 m_od 3 | {7}\ {\mathrm{\underline{m}od}}\ {3} | 7 mod 3 |
| 156 | (r_ange 6) m_od 2 | {(}{\mathrm{\underline{r}ange}}\ {6}{)}\ {\mathrm{\underline{m}od}}\ {2} | (range 6) mod 2 |
| 167 | n_eg v | {\mathrm{\underline{n}eg}}\ {\mathrm{v}} | neg v |
| 178 | a_bs -3 4 -5 | {\mathrm{\underline{a}bs}}\ {-3}\ {4}\ {-5} | abs −3 4 −5 |
| 189 | f_loor 2.5 -2.5 | {\mathrm{\underline{f}loor}}\ {2.5}\ {-2.5} | floor 2.5 −2.5 |
| 200 | c_eiling 2.5 -2.5 | {\mathrm{\underline{c}eiling}}\ {2.5}\ {-2.5} | ceiling 2.5 −2.5 |
| 211 | e_xp 1 | {\mathrm{\underline{e}xp}}\ {1} | exp 1 |
| 222 | l_og e_xp 2 | {\mathrm{\underline{l}og}}\ {\mathrm{\underline{e}xp}}\ {2} | log exp 2 |
| 235 | f_loat 3 | {\mathrm{\underline{f}loat}}\ {3} | float 3 |
| 237 | 1 / 3 | {1}\ {\div}\ {3} | 1 ÷ 3 |
| 239 | 0.1 + 0.2 | {0.1}\ {+}\ {0.2} | 0.1 + 0.2 |
| 255 | s_in 0 1 | {\mathrm{\underline{s}in}}\ {0}\ {1} | sin 0 1 |
| 266 | c_os p_i @ | {\mathrm{\underline{c}os}}\ {\mathrm{\underline{p}i}}\ {@} | cos pi @ |
| 277 | 4 * a_tan 1 | {4}\ {\times}\ {\mathrm{\underline{a}tan}}\ {1} | 4 × atan 1 |
| 288 | p_i @ | {\mathrm{\underline{p}i}}\ {@} | pi @ |
| 300 | t_anh 0.5 1e-10 1000 | {\mathrm{\underline{t}anh}}\ {0.5}\ {1e-10}\ {1000} | tanh 0.5 1e−10 1000 |
| 312 | s_qrt 2 16 | {\mathrm{\underline{s}qrt}}\ {2}\ {16} | sqrt 2 16 |
| 324 | e_xpm1 1e-10 | {\mathrm{\underline{e}xpm1}}\ {1e-10} | expm1 1e−10 |
| 335 | l_og1p 1e-10 | {\mathrm{\underline{l}og1p}}\ {1e-10} | log1p 1e−10 |
| 347 | e_rf 0 0.5 3 | {\mathrm{\underline{e}rf}}\ {0}\ {0.5}\ {3} | erf 0 0.5 3 |
| 349 | 0.5 * 1 + e_rf 1 / s_qrt 2 | {0.5}\ {\times}\ {1}\ {+}\ {\mathrm{\underline{e}rf}}\ {1}\ {\div}\ {\mathrm{\underline{s}qrt}}\ {2} | 0.5 × 1 + erf 1 ÷ sqrt 2 |
| 361 | e_rfc 0.5 3 | {\mathrm{\underline{e}rfc}}\ {0.5}\ {3} | erfc 0.5 3 |
| 363 | 2 * p_i @ | {2}\ {\times}\ {\mathrm{\underline{p}i}}\ {@} | 2 × pi @ |
| 380 | 3 = 3 | {3}\ {=}\ {3} | 3 = 3 |
| 382 | v = 1 | {\mathrm{v}}\ {=}\ {1} | v = 1 |
| 393 | v != 1 | {\mathrm{v}}\ {\neq}\ {1} | v = 1 |
| 404 | v < 2 | {\mathrm{v}}\ {<}\ {2} | v < 2 |
| 415 | v > 2 | {\mathrm{v}}\ {>}\ {2} | v > 2 |
| 426 | v <= 2 | {\mathrm{v}}\ {\leq}\ {2} | v ≤ 2 |
| 437 | v >= 2 | {\mathrm{v}}\ {\geq}\ {2} | v ≥ 2 |
| 448 | (0.1 + 0.2) e_q~ 0.3 | {(}{0.1}\ {+}\ {0.2}{)}\ {\mathrm{\underline{e}q}{\sim}}\ {0.3} | (0.1 + 0.2) eq∼ 0.3 |
| 459 | 1 1 0 & 1 0 0 | {1}\ {1}\ {0}\ {\wedge}\ {1}\ {0}\ {0} | 1 1 0 ∧ 1 0 0 |
| 470 | 1 1 0 | 1 0 0 | {1}\ {1}\ {0}\ {\vee}\ {1}\ {0}\ {0} | 1 1 0 ∨ 1 0 0 |
| 481 | n_ot 1 0 | {\mathrm{\underline{n}ot}}\ {1}\ {0} | not 1 0 |
| 500 | s_hape v | {\mathrm{\underline{s}hape}}\ {\mathrm{v}} | shape v |
| 502 | s_hape M | {\mathrm{\underline{s}hape}}\ {\mathrm{M}} | shape M |
| 515 | t_ally v | {\mathrm{\underline{t}ally}}\ {\mathrm{v}} | tally v |
| 517 | t_ally M | {\mathrm{\underline{t}ally}}\ {\mathrm{M}} | tally M |
| 519 | t_ally_1 M | {{\mathrm{\underline{t}ally}}_{1}}\ {\mathrm{M}} | tally1 M |
| 521 | t_ally_2 M | {{\mathrm{\underline{t}ally}}_{2}}\ {\mathrm{M}} | tally2 M |
| 532 | r_ange 5 | {\mathrm{\underline{r}ange}}\ {5} | range 5 |
| 543 | o_ffsets 5 | {\mathrm{\underline{o}ffsets}}\ {5} | offsets 5 |
| 555 | 2 3 r_eshape r_ange 6 | {2}\ {3}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{\underline{r}ange}}\ {6} | 2 3 reshape range 6 |
| 558 | 2 2 r_eshape 7 | {2}\ {2}\ {\mathrm{\underline{r}eshape}}\ {7} | 2 2 reshape 7 |
| 571 | r_avel M | {\mathrm{\underline{r}avel}}\ {\mathrm{M}} | ravel M |
| 573 | r_avel_2 M | {{\mathrm{\underline{r}avel}}_{2}}\ {\mathrm{M}} | ravel2 M |
| 585 | f_irst v | {\mathrm{\underline{f}irst}}\ {\mathrm{v}} | first v |
| 587 | f_irst M | {\mathrm{\underline{f}irst}}\ {\mathrm{M}} | first M |
| 589 | f_irst_1 M | {{\mathrm{\underline{f}irst}}_{1}}\ {\mathrm{M}} | first1 M |
| 591 | f_irst_2 M | {{\mathrm{\underline{f}irst}}_{2}}\ {\mathrm{M}} | first2 M |
| 603 | 2 t_ake v | {2}\ {\mathrm{\underline{t}ake}}\ {\mathrm{v}} | 2 take v |
| 605 | -2 t_ake v | {-2}\ {\mathrm{\underline{t}ake}}\ {\mathrm{v}} | −2 take v |
| 607 | 1 t_ake M | {1}\ {\mathrm{\underline{t}ake}}\ {\mathrm{M}} | 1 take M |
| 609 | 1 t_ake_1 M | {1}\ {{\mathrm{\underline{t}ake}}_{1}}\ {\mathrm{M}} | 1 take1 M |
| 611 | 1 t_ake_2 M | {1}\ {{\mathrm{\underline{t}ake}}_{2}}\ {\mathrm{M}} | 1 take2 M |
| 624 | 1 d_rop v | {1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{v}} | 1 drop v |
| 626 | 1 d_rop M | {1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{M}} | 1 drop M |
| 628 | 1 d_rop_1 M | {1}\ {{\mathrm{\underline{d}rop}}_{1}}\ {\mathrm{M}} | 1 drop1 M |
| 630 | 1 d_rop_2 M | {1}\ {{\mathrm{\underline{d}rop}}_{2}}\ {\mathrm{M}} | 1 drop2 M |
| 643 | 3 1 s_elect v | {3}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{v}} | 3 1 select v |
| 645 | 2 s_elect M | {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{M}} | 2 select M |
| 647 | 2 s_elect_1 M | {2}\ {{\mathrm{\underline{s}elect}}_{1}}\ {\mathrm{M}} | 2 select1 M |
| 649 | 2 s_elect_2 M | {2}\ {{\mathrm{\underline{s}elect}}_{2}}\ {\mathrm{M}} | 2 select2 M |
| 665 | v a_mend (1 3, 0 9) | {\mathrm{v}}\ {\mathrm{\underline{a}mend}}\ {(}{1}\ {3}{,}\ {0}\ {9}{)} | v amend (1 3, 0 9) |
| 667 | v a_mend (1 3, 0) | {\mathrm{v}}\ {\mathrm{\underline{a}mend}}\ {(}{1}\ {3}{,}\ {0}{)} | v amend (1 3, 0) |
| 669 | M a_mend (2, 0 0 0) | {\mathrm{M}}\ {\mathrm{\underline{a}mend}}\ {(}{2}{,}\ {0}\ {0}\ {0}{)} | M amend (2, 0 0 0) |
| 672 | M a_mend_2 (3, 0 0) | {\mathrm{M}}\ {{\mathrm{\underline{a}mend}}_{2}}\ {(}{3}{,}\ {0}\ {0}{)} | M amend2 (3, 0 0) |
| 687 | 1 0 2 r_eplicate "abc" | {1}\ {0}\ {2}\ {\mathrm{\underline{r}eplicate}}\ {\text{"abc"}} | 1 0 2 replicate "abc" |
| 689 | (v > 1) r_eplicate v | {(}{\mathrm{v}}\ {>}\ {1}{)}\ {\mathrm{\underline{r}eplicate}}\ {\mathrm{v}} | (v > 1) replicate v |
| 691 | 2 r_eplicate v | {2}\ {\mathrm{\underline{r}eplicate}}\ {\mathrm{v}} | 2 replicate v |
| 693 | 0 2 r_eplicate M | {0}\ {2}\ {\mathrm{\underline{r}eplicate}}\ {\mathrm{M}} | 0 2 replicate M |
| 696 | 1 0 2 r_eplicate_2 M | {1}\ {0}\ {2}\ {{\mathrm{\underline{r}eplicate}}_{2}}\ {\mathrm{M}} | 1 0 2 replicate2 M |
| 699 | 1 -1 2 r_eplicate v | {1}\ {-1}\ {2}\ {\mathrm{\underline{r}eplicate}}\ {\mathrm{v}} | 1 −1 2 replicate v |
| 716 | 2 2 2 2 e_ncode 11 | {2}\ {2}\ {2}\ {2}\ {\mathrm{\underline{e}ncode}}\ {11} | 2 2 2 2 encode 11 |
| 718 | 24 60 60 e_ncode 3725 | {24}\ {60}\ {60}\ {\mathrm{\underline{e}ncode}}\ {3725} | 24 60 60 encode 3725 |
| 720 | 0 10 e_ncode 123 | {0}\ {10}\ {\mathrm{\underline{e}ncode}}\ {123} | 0 10 encode 123 |
| 722 | 2 2 2 e_ncode 0 1 2 3 | {2}\ {2}\ {2}\ {\mathrm{\underline{e}ncode}}\ {0}\ {1}\ {2}\ {3} | 2 2 2 encode 0 1 2 3 |
| 726 | 2 2 2 e_ncode -1 | {2}\ {2}\ {2}\ {\mathrm{\underline{e}ncode}}\ {-1} | 2 2 2 encode −1 |
| 728 | 0 10 e_ncode -123 | {0}\ {10}\ {\mathrm{\underline{e}ncode}}\ {-123} | 0 10 encode −123 |
| 730 | 2 2 e_ncode M | {2}\ {2}\ {\mathrm{\underline{e}ncode}}\ {\mathrm{M}} | 2 2 encode M |
| 745 | 2 d_ecode 1 0 1 1 | {2}\ {\mathrm{\underline{d}ecode}}\ {1}\ {0}\ {1}\ {1} | 2 decode 1 0 1 1 |
| 747 | 10 d_ecode 1 2 3 | {10}\ {\mathrm{\underline{d}ecode}}\ {1}\ {2}\ {3} | 10 decode 1 2 3 |
| 749 | 24 60 60 d_ecode 1 2 5 | {24}\ {60}\ {60}\ {\mathrm{\underline{d}ecode}}\ {1}\ {2}\ {5} | 24 60 60 decode 1 2 5 |
| 751 | 2 d_ecode 2 2 2 e_ncode 0 1 2 3 | {2}\ {\mathrm{\underline{d}ecode}}\ {2}\ {2}\ {2}\ {\mathrm{\underline{e}ncode}}\ {0}\ {1}\ {2}\ {3} | 2 decode 2 2 2 encode 0 1 2 3 |
| 753 | 2.0 d_ecode 3.0 -2.0 1.0 | {2.0}\ {\mathrm{\underline{d}ecode}}\ {3.0}\ {-2.0}\ {1.0} | 2.0 decode 3.0 −2.0 1.0 |
| 755 | 0.5 d_ecode r_ev 1.0 -2.0 3.0 | {0.5}\ {\mathrm{\underline{d}ecode}}\ {\mathrm{\underline{r}ev}}\ {1.0}\ {-2.0}\ {3.0} | 0.5 decode rev 1.0 −2.0 3.0 |
| 757 | 2 2 d_ecode 1 0 1 | {2}\ {2}\ {\mathrm{\underline{d}ecode}}\ {1}\ {0}\ {1} | 2 2 decode 1 0 1 |
| 775 | e_nclose "abc" | {\mathrm{\underline{e}nclose}}\ {\text{"abc"}} | enclose "abc" |
| 781 | "ab" "cde" | {\text{"ab"}}\ {\text{"cde"}} | "ab" "cde" |
| 787 | (e_nclose v) c_at e_nclose 1 2 | {(}{\mathrm{\underline{e}nclose}}\ {\mathrm{v}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{e}nclose}}\ {1}\ {2} | (enclose v) cat enclose 1 2 |
| 793 | t_ally "ab" "cde" | {\mathrm{\underline{t}ally}}\ {\text{"ab"}}\ {\text{"cde"}} | tally "ab" "cde" |
| 795 | e_nclose (1, 2.5) | {\mathrm{\underline{e}nclose}}\ {(}{1}{,}\ {2.5}{)} | enclose (1, 2.5) |
| 808 | d_isclose e_nclose "abc" | {\mathrm{\underline{d}isclose}}\ {\mathrm{\underline{e}nclose}}\ {\text{"abc"}} | disclose enclose "abc" |
| 810 | d_isclose 2 s_elect "ab" "cde" | {\mathrm{\underline{d}isclose}}\ {2}\ {\mathrm{\underline{s}elect}}\ {\text{"ab"}}\ {\text{"cde"}} | disclose 2 select "ab" "cde" |
| 812 | d_isclose "ab" "cde" | {\mathrm{\underline{d}isclose}}\ {\text{"ab"}}\ {\text{"cde"}} | disclose "ab" "cde" |
| 814 | d_isclose e_nclose (1, 2.5) | {\mathrm{\underline{d}isclose}}\ {\mathrm{\underline{e}nclose}}\ {(}{1}{,}\ {2.5}{)} | disclose enclose (1, 2.5) |
| 829 | m_ix '{ r_ange _r } m_ap v | {\mathrm{\underline{m}ix}}\ {\text{'}}{\{}\ {\mathrm{\underline{r}ange}}\ {\_\mathrm{r}}\ {\}}\ {\mathrm{\underline{m}ap}}\ {\mathrm{v}} | mix ’{ range _r } map v |
| 833 | m_ix "ab" "cde" | {\mathrm{\underline{m}ix}}\ {\text{"ab"}}\ {\text{"cde"}} | mix "ab" "cde" |
| 850 | d_isplay M | {\mathrm{\underline{d}isplay}}\ {\mathrm{M}} | display M |
| 855 | d_isplay "abc" | {\mathrm{\underline{d}isplay}}\ {\text{"abc"}} | display "abc" |
| 859 | d_isplay "ab" "cde" | {\mathrm{\underline{d}isplay}}\ {\text{"ab"}}\ {\text{"cde"}} | display "ab" "cde" |
| 865 | s_hape d_isplay v | {\mathrm{\underline{s}hape}}\ {\mathrm{\underline{d}isplay}}\ {\mathrm{v}} | shape display v |
| 867 | d_isplay 5 | {\mathrm{\underline{d}isplay}}\ {5} | display 5 |
| 881 | t_ally (1 1 0 1 1 1 0 1) p_artition "ab cde f" | {\mathrm{\underline{t}ally}}\ {(}{1}\ {1}\ {0}\ {1}\ {1}\ {1}\ {0}\ {1}{)}\ {\mathrm{\underline{p}artition}}\ {\text{"ab cde f"}} | tally (1 1 0 1 1 1 0 1) partition "ab cde f" |
| 883 | d_isclose 2 s_elect (1 1 0 1 1 1 0 1) p_artition "ab cde f" | {\mathrm{\underline{d}isclose}}\ {2}\ {\mathrm{\underline{s}elect}}\ {(}{1}\ {1}\ {0}\ {1}\ {1}\ {1}\ {0}\ {1}{)}\ {\mathrm{\underline{p}artition}}\ {\text{"ab cde f"}} | disclose 2 select (1 1 0 1 1 1 0 1) partition "ab cde f" |
| 885 | '[t_ally d_isclose] e_ach ("a bb ccc" != f_irst " ") p_artition "a bb ccc" | {\text{'}}{[}{\mathrm{\underline{t}ally}}\ {\mathrm{\underline{d}isclose}}{]}\ {\mathrm{\underline{e}ach}}\ {(}{\text{"a bb ccc"}}\ {\neq}\ {\mathrm{\underline{f}irst}}\ {\text{" "}}{)}\ {\mathrm{\underline{p}artition}}\ {\text{"a bb ccc"}} | ’[tally disclose] each ("a bb ccc" = first " ") partition "a bb ccc" |
| 887 | 1 1 p_artition 1 2 3 | {1}\ {1}\ {\mathrm{\underline{p}artition}}\ {1}\ {2}\ {3} | 1 1 partition 1 2 3 |
| 901 | 1 2 c_at 3 4 | {1}\ {2}\ {\mathrm{\underline{c}at}}\ {3}\ {4} | 1 2 cat 3 4 |
| 903 | M c_at M | {\mathrm{M}}\ {\mathrm{\underline{c}at}}\ {\mathrm{M}} | M cat M |
| 908 | M c_at_2 M | {\mathrm{M}}\ {{\mathrm{\underline{c}at}}_{2}}\ {\mathrm{M}} | M cat2 M |
| 911 | M c_at_2 0 9 | {\mathrm{M}}\ {{\mathrm{\underline{c}at}}_{2}}\ {0}\ {9} | M cat2 0 9 |
| 914 | M c_at_2 1 2 3 | {\mathrm{M}}\ {{\mathrm{\underline{c}at}}_{2}}\ {1}\ {2}\ {3} | M cat2 1 2 3 |
| 929 | 2 3 r_equireShape M | {2}\ {3}\ {\mathrm{\underline{r}equireShape}}\ {\mathrm{M}} | 2 3 requireShape M |
| 932 | 3 r_equireShape v | {3}\ {\mathrm{\underline{r}equireShape}}\ {\mathrm{v}} | 3 requireShape v |
| 934 | 3 2 r_equireShape M | {3}\ {2}\ {\mathrm{\underline{r}equireShape}}\ {\mathrm{M}} | 3 2 requireShape M |
| 952 | '+ r_/ v | {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{v}} | ’+ r/ v |
| 954 | '- r_/ 1 2 3 | {\text{'}}{-}\ {\mathrm{\underline{r}}{/}}\ {1}\ {2}\ {3} | ’− r/ 1 2 3 |
| 956 | '+ r_/ M | {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{M}} | ’+ r/ M |
| 958 | '+ r_/_1 M | {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{1}}\ {\mathrm{M}} | ’+ r/1 M |
| 960 | '+ r_/_2 M | {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{2}}\ {\mathrm{M}} | ’+ r/2 M |
| 962 | '+ r_/_12 M | {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{12}}\ {\mathrm{M}} | ’+ r/12 M |
| 964 | 'm_ax r_/_2 M | {\text{'}}{\mathrm{\underline{m}ax}}\ {{\mathrm{\underline{r}}{/}}_{2}}\ {\mathrm{M}} | ’max r/2 M |
| 976 | '+ s_\ v | {\text{'}}{+}\ {\mathrm{\underline{s}}{\backslash}}\ {\mathrm{v}} | ’+ s\ v |
| 978 | '+ s_\ M | {\text{'}}{+}\ {\mathrm{\underline{s}}{\backslash}}\ {\mathrm{M}} | ’+ s\ M |
| 981 | '+ s_\_1 M | {\text{'}}{+}\ {{\mathrm{\underline{s}}{\backslash}}_{1}}\ {\mathrm{M}} | ’+ s\1 M |
| 984 | '+ s_\_2 M | {\text{'}}{+}\ {{\mathrm{\underline{s}}{\backslash}}_{2}}\ {\mathrm{M}} | ’+ s\2 M |
| 997 | 'n_eg e_ach v | {\text{'}}{\mathrm{\underline{n}eg}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{v}} | ’neg each v |
| 999 | '{ _r * 10 } e_ach v | {\text{'}}{\{}\ {\_\mathrm{r}}\ {\times}\ {10}\ {\}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{v}} | ’{ _r × 10 } each v |
| 1001 | 1 2 3 '+ e_ach 10 20 30 | {1}\ {2}\ {3}\ {\text{'}}{+}\ {\mathrm{\underline{e}ach}}\ {10}\ {20}\ {30} | 1 2 3 ’+ each 10 20 30 |
| 1015 | t_ally 'r_ange m_ap 1 2 3 | {\mathrm{\underline{t}ally}}\ {\text{'}}{\mathrm{\underline{r}ange}}\ {\mathrm{\underline{m}ap}}\ {1}\ {2}\ {3} | tally ’range map 1 2 3 |
| 1017 | d_isclose 3 s_elect 'r_ange m_ap 1 2 3 | {\mathrm{\underline{d}isclose}}\ {3}\ {\mathrm{\underline{s}elect}}\ {\text{'}}{\mathrm{\underline{r}ange}}\ {\mathrm{\underline{m}ap}}\ {1}\ {2}\ {3} | disclose 3 select ’range map 1 2 3 |
| 1019 | '[t_ally d_isclose] e_ach 'r_ange m_ap 1 2 3 | {\text{'}}{[}{\mathrm{\underline{t}ally}}\ {\mathrm{\underline{d}isclose}}{]}\ {\mathrm{\underline{e}ach}}\ {\text{'}}{\mathrm{\underline{r}ange}}\ {\mathrm{\underline{m}ap}}\ {1}\ {2}\ {3} | ’[tally disclose] each ’range map 1 2 3 |
| 1021 | '{ k -> (k, f_loat k) } m_ap 1 2 | {\text{'}}{\{}\ {\mathrm{k}}\ {\to}\ {(}{\mathrm{k}}{,}\ {\mathrm{\underline{f}loat}}\ {\mathrm{k}}{)}\ {\}}\ {\mathrm{\underline{m}ap}}\ {1}\ {2} | ’{ k → (k, float k) } map 1 2 |
| 1027 | '{ k -> (k, k) } e_ach 1 2 | {\text{'}}{\{}\ {\mathrm{k}}\ {\to}\ {(}{\mathrm{k}}{,}\ {\mathrm{k}}{)}\ {\}}\ {\mathrm{\underline{e}ach}}\ {1}\ {2} | ’{ k → (k, k) } each 1 2 |
| 1039 | 1 2 3 '* t_able 1 2 3 | {1}\ {2}\ {3}\ {\text{'}}{\times}\ {\mathrm{\underline{t}able}}\ {1}\ {2}\ {3} | 1 2 3 ’× table 1 2 3 |
| 1053 | (2 2 r_eshape 1 2 3 4) '+ '* i_nner 2 2 r_eshape 1 2 3 4 | {(}{2}\ {2}\ {\mathrm{\underline{r}eshape}}\ {1}\ {2}\ {3}\ {4}{)}\ {\text{'}}{+}\ {\text{'}}{\times}\ {\mathrm{\underline{i}nner}}\ {2}\ {2}\ {\mathrm{\underline{r}eshape}}\ {1}\ {2}\ {3}\ {4} | (2 2 reshape 1 2 3 4) ’+ ’× inner 2 2 reshape 1 2 3 4 |
| 1066 | 'n_eg 'a_bs c_ompose -5 | {\text{'}}{\mathrm{\underline{n}eg}}\ {\text{'}}{\mathrm{\underline{a}bs}}\ {\mathrm{\underline{c}ompose}}\ {-5} | ’neg ’abs compose −5 |
| 1068 | [n_eg a_bs] -5 | {[}{\mathrm{\underline{n}eg}}\ {\mathrm{\underline{a}bs}}{]}\ {-5} | [neg abs] −5 |
| 1079 | 10 '- s_wap 3 | {10}\ {\text{'}}{-}\ {\mathrm{\underline{s}wap}}\ {3} | 10 ’− swap 3 |
| 1093 | 3 'n_eg p_ower 5 | {3}\ {\text{'}}{\mathrm{\underline{n}eg}}\ {\mathrm{\underline{p}ower}}\ {5} | 3 ’neg power 5 |
| 1095 | n_eg^3 5 | {\mathrm{\underline{n}eg}}^{3}\ {5} | neg3 5 |
| 1097 | 3 '{ (w, k) -> (w * 0.5, k + 1) } p_ower (8.0 4.0, 0) | {3}\ {\text{'}}{\{}\ {(}{\mathrm{w}}{,}\ {\mathrm{k}}{)}\ {\to}\ {(}{\mathrm{w}}\ {\times}\ {0.5}{,}\ {\mathrm{k}}\ {+}\ {1}{)}\ {\}}\ {\mathrm{\underline{p}ower}}\ {(}{8.0}\ {4.0}{,}\ {0}{)} | 3 ’{ (w, k) → (w × 0.5, k + 1) } power (8.0 4.0, 0) |
| 1113 | 2 '- n_wise 1 4 9 16 | {2}\ {\text{'}}{-}\ {\mathrm{\underline{n}wise}}\ {1}\ {4}\ {9}\ {16} | 2 ’− nwise 1 4 9 16 |
| 1115 | -2 '- n_wise 1 4 9 16 | {-2}\ {\text{'}}{-}\ {\mathrm{\underline{n}wise}}\ {1}\ {4}\ {9}\ {16} | −2 ’− nwise 1 4 9 16 |
| 1117 | 3 '+ n_wise v c_at v | {3}\ {\text{'}}{+}\ {\mathrm{\underline{n}wise}}\ {\mathrm{v}}\ {\mathrm{\underline{c}at}}\ {\mathrm{v}} | 3 ’+ nwise v cat v |
| 1119 | 2 'c_at n_wise "abc" | {2}\ {\text{'}}{\mathrm{\underline{c}at}}\ {\mathrm{\underline{n}wise}}\ {\text{"abc"}} | 2 ’cat nwise "abc" |
| 1135 | 1 'g_rade r_ank N | {1}\ {\text{'}}{\mathrm{\underline{g}rade}}\ {\mathrm{\underline{r}ank}}\ {\mathrm{N}} | 1 ’grade rank N |
| 1138 | 1 'r_ev r_ank M | {1}\ {\text{'}}{\mathrm{\underline{r}ev}}\ {\mathrm{\underline{r}ank}}\ {\mathrm{M}} | 1 ’rev rank M |
| 1141 | -1 '{ '+ r_/ _r } r_ank M | {-1}\ {\text{'}}{\{}\ {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\_\mathrm{r}}\ {\}}\ {\mathrm{\underline{r}ank}}\ {\mathrm{M}} | −1 ’{ ’+ r/ _r } rank M |
| 1157 | 5 6 7 i_ndexOf 7 9 | {5}\ {6}\ {7}\ {\mathrm{\underline{i}ndexOf}}\ {7}\ {9} | 5 6 7 indexOf 7 9 |
| 1159 | M i_ndexOf 4 5 6 | {\mathrm{M}}\ {\mathrm{\underline{i}ndexOf}}\ {4}\ {5}\ {6} | M indexOf 4 5 6 |
| 1170 | 2 9 m_ember? 1 2 3 | {2}\ {9}\ {\mathrm{\underline{m}ember}{?}}\ {1}\ {2}\ {3} | 2 9 member? 1 2 3 |
| 1185 | 1 2 3 m_atch 1 2 3 | {1}\ {2}\ {3}\ {\mathrm{\underline{m}atch}}\ {1}\ {2}\ {3} | 1 2 3 match 1 2 3 |
| 1187 | 1 2 3 m_atch 1 2 4 | {1}\ {2}\ {3}\ {\mathrm{\underline{m}atch}}\ {1}\ {2}\ {4} | 1 2 3 match 1 2 4 |
| 1189 | M m_atch M | {\mathrm{M}}\ {\mathrm{\underline{m}atch}}\ {\mathrm{M}} | M match M |
| 1191 | M m_atch 1 2 3 4 5 6 | {\mathrm{M}}\ {\mathrm{\underline{m}atch}}\ {1}\ {2}\ {3}\ {4}\ {5}\ {6} | M match 1 2 3 4 5 6 |
| 1193 | 1 m_atch 1 s_elect 1 2 3 | {1}\ {\mathrm{\underline{m}atch}}\ {1}\ {\mathrm{\underline{s}elect}}\ {1}\ {2}\ {3} | 1 match 1 select 1 2 3 |
| 1195 | (1 2, 3.5) m_atch (1 2, 3.5) | {(}{1}\ {2}{,}\ {3.5}{)}\ {\mathrm{\underline{m}atch}}\ {(}{1}\ {2}{,}\ {3.5}{)} | (1 2, 3.5) match (1 2, 3.5) |
| 1197 | (1 2, 3.5) m_atch (2 1 r_eshape 1 2, 3.5) | {(}{1}\ {2}{,}\ {3.5}{)}\ {\mathrm{\underline{m}atch}}\ {(}{2}\ {1}\ {\mathrm{\underline{r}eshape}}\ {1}\ {2}{,}\ {3.5}{)} | (1 2, 3.5) match (2 1 reshape 1 2, 3.5) |
| 1199 | (1, 2) = (1, 2) | {(}{1}{,}\ {2}{)}\ {=}\ {(}{1}{,}\ {2}{)} | (1, 2) = (1, 2) |
| 1210 | u_nique 3 1 3 2 1 | {\mathrm{\underline{u}nique}}\ {3}\ {1}\ {3}\ {2}\ {1} | unique 3 1 3 2 1 |
| 1222 | s_ort 3 1 2 | {\mathrm{\underline{s}ort}}\ {3}\ {1}\ {2} | sort 3 1 2 |
| 1224 | s_ort N | {\mathrm{\underline{s}ort}}\ {\mathrm{N}} | sort N |
| 1227 | s_ort_2 N | {{\mathrm{\underline{s}ort}}_{2}}\ {\mathrm{N}} | sort2 N |
| 1240 | g_rade 3 1 2 | {\mathrm{\underline{g}rade}}\ {3}\ {1}\ {2} | grade 3 1 2 |
| 1242 | g_rade_2 N | {{\mathrm{\underline{g}rade}}_{2}}\ {\mathrm{N}} | grade2 N |
| 1253 | w_here 0 1 1 0 | {\mathrm{\underline{w}here}}\ {0}\ {1}\ {1}\ {0} | where 0 1 1 0 |
| 1255 | w_here_2 M | {{\mathrm{\underline{w}here}}_{2}}\ {\mathrm{M}} | where2 M |
| 1271 | 1 o_- v | {1}\ {\mathrm{\underline{o}}{-}}\ {\mathrm{v}} | 1 o− v |
| 1273 | -1 o_- v | {-1}\ {\mathrm{\underline{o}}{-}}\ {\mathrm{v}} | −1 o− v |
| 1275 | 1 o_- M | {1}\ {\mathrm{\underline{o}}{-}}\ {\mathrm{M}} | 1 o− M |
| 1278 | 1 o_-_1 M | {1}\ {{\mathrm{\underline{o}}{-}}_{1}}\ {\mathrm{M}} | 1 o−1 M |
| 1281 | 1 o_-_2 M | {1}\ {{\mathrm{\underline{o}}{-}}_{2}}\ {\mathrm{M}} | 1 o−2 M |
| 1284 | -1 0 1 o_- v | {-1}\ {0}\ {1}\ {\mathrm{\underline{o}}{-}}\ {\mathrm{v}} | −1 0 1 o− v |
| 1298 | r_ev v | {\mathrm{\underline{r}ev}}\ {\mathrm{v}} | rev v |
| 1300 | r_ev M | {\mathrm{\underline{r}ev}}\ {\mathrm{M}} | rev M |
| 1303 | r_ev_1 M | {{\mathrm{\underline{r}ev}}_{1}}\ {\mathrm{M}} | rev1 M |
| 1306 | r_ev_2 M | {{\mathrm{\underline{r}ev}}_{2}}\ {\mathrm{M}} | rev2 M |
| 1320 | o_\ M | {\mathrm{\underline{o}}{\backslash}}\ {\mathrm{M}} | o\ M |
| 1324 | s_hape o_\ 2 3 4 r_eshape 0 | {\mathrm{\underline{s}hape}}\ {\mathrm{\underline{o}}{\backslash}}\ {2}\ {3}\ {4}\ {\mathrm{\underline{r}eshape}}\ {0} | shape o\ 2 3 4 reshape 0 |
| 1326 | s_hape o_\_23 2 3 4 r_eshape 0 | {\mathrm{\underline{s}hape}}\ {{\mathrm{\underline{o}}{\backslash}}_{23}}\ {2}\ {3}\ {4}\ {\mathrm{\underline{r}eshape}}\ {0} | shape o\23 2 3 4 reshape 0 |
| 1328 | o_\_2 M | {{\mathrm{\underline{o}}{\backslash}}_{2}}\ {\mathrm{M}} | o\2 M |
| 1342 | 2 1 t_ranspose M | {2}\ {1}\ {\mathrm{\underline{t}ranspose}}\ {\mathrm{M}} | 2 1 transpose M |
| 1346 | s_hape 3 1 2 t_ranspose 2 3 4 r_eshape 0 | {\mathrm{\underline{s}hape}}\ {3}\ {1}\ {2}\ {\mathrm{\underline{t}ranspose}}\ {2}\ {3}\ {4}\ {\mathrm{\underline{r}eshape}}\ {0} | shape 3 1 2 transpose 2 3 4 reshape 0 |
| 1348 | 1 1 t_ranspose M | {1}\ {1}\ {\mathrm{\underline{t}ranspose}}\ {\mathrm{M}} | 1 1 transpose M |
| 1362 | []A | {\square \mathrm{A}} | □A |
| 1364 | 3 t_ake []A | {3}\ {\mathrm{\underline{t}ake}}\ {\square \mathrm{A}} | 3 take □A |
| 1375 | []D | {\square \mathrm{D}} | □D |
| 1387 | t_ally []AV | {\mathrm{\underline{t}ally}}\ {\square \mathrm{AV}} | tally □AV |
| 1389 | 66 s_elect []AV | {66}\ {\mathrm{\underline{s}elect}}\ {\square \mathrm{AV}} | 66 select □AV |
| 1400 | []IO | {\square \mathrm{IO}} | □IO |
| 1412 | []U_CS "Hi" | {\square \mathrm{\underline{U}CS}}\ {\text{"Hi"}} | □UCS "Hi" |
| 1414 | ([]U_CS "a") - []U_CS "A" | {(}{\square \mathrm{\underline{U}CS}}\ {\text{"a"}}{)}\ {-}\ {\square \mathrm{\underline{U}CS}}\ {\text{"A"}} | (□UCS "a") − □UCS "A" |
| 1425 | []U_CHAR 72 105 | {\square \mathrm{\underline{U}CHAR}}\ {72}\ {105} | □UCHAR 72 105 |
| 1427 | []U_CHAR 1 + []U_CS "HAL" | {\square \mathrm{\underline{U}CHAR}}\ {1}\ {+}\ {\square \mathrm{\underline{U}CS}}\ {\text{"HAL"}} | □UCHAR 1 + □UCS "HAL" |
| 1429 | []U_CHAR 200 | {\square \mathrm{\underline{U}CHAR}}\ {200} | □UCHAR 200 |
| 1442 | s_hape []TS | {\mathrm{\underline{s}hape}}\ {\square \mathrm{TS}} | shape □TS |
| 1444 | 2026 <= 1 s_elect []TS | {2026}\ {\leq}\ {1}\ {\mathrm{\underline{s}elect}}\ {\square \mathrm{TS}} | 2026 ≤ 1 select □TS |
| 1457 | ([]D_L 0.01) >= 0.01 | {(}{\square \mathrm{\underline{D}L}}\ {0.01}{)}\ {\geq}\ {0.01} | (□DL 0.01) ≥ 0.01 |
| 1459 | []D_L -1 | {\square \mathrm{\underline{D}L}}\ {-1} | □DL −1 |
| 1472 | p_rint! v | {\mathrm{\underline{p}rint}{!}}\ {\mathrm{v}} | print! v |
| 1485 | r_oll! 6 6 6 | {\mathrm{\underline{r}oll}{!}}\ {6}\ {6}\ {6} | roll! 6 6 6 |
| 1498 | i_d v | {\mathrm{\underline{i}d}}\ {\mathrm{v}} | id v |
| 1500 | [i_d - n_eg] 5 | {[}{\mathrm{\underline{i}d}}\ {-}\ {\mathrm{\underline{n}eg}}{]}\ {5} | [id − neg] 5 |
| 1512 | 1 l_eft 2 | {1}\ {\mathrm{\underline{l}eft}}\ {2} | 1 left 2 |
| 1514 | 3 [l_eft - r_ight] 4 | {3}\ {[}{\mathrm{\underline{l}eft}}\ {-}\ {\mathrm{\underline{r}ight}}{]}\ {4} | 3 [left − right] 4 |
| 1525 | 1 r_ight 2 | {1}\ {\mathrm{\underline{r}ight}}\ {2} | 1 right 2 |
| 1527 | 1 2 [r_ight c_at l_eft] 3 | {1}\ {2}\ {[}{\mathrm{\underline{r}ight}}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{l}eft}}{]}\ {3} | 1 2 [right cat left] 3 |
| 1538 | f_ormat 3.5 | {\mathrm{\underline{f}ormat}}\ {3.5} | format 3.5 |
| 1540 | t_ally f_ormat 1 2 3 | {\mathrm{\underline{t}ally}}\ {\mathrm{\underline{f}ormat}}\ {1}\ {2}\ {3} | tally format 1 2 3 |
| 1551 | n_umbers "1 2.5 -3" | {\mathrm{\underline{n}umbers}}\ {\text{"1 2.5 -3"}} | numbers "1 2.5 -3" |
| 1563 | "hello" []N_PUT "work/reference.txt" | {\text{"hello"}}\ {\square \mathrm{\underline{N}PUT}}\ {\text{"work/reference.txt"}} | "hello" □NPUT "work/reference.txt" |
| 1574 | []N_GET "work/reference.txt" | {\square \mathrm{\underline{N}GET}}\ {\text{"work/reference.txt"}} | □NGET "work/reference.txt" |
| 1588 | []R_EAD @ | {\square \mathrm{\underline{R}EAD}}\ {@} | □READ @ |
| 1602 | []K_EY @ | {\square \mathrm{\underline{K}EY}}\ {@} | □KEY @ |
| 1613 | []K_CHAR []K_EY @ | {\square \mathrm{\underline{K}CHAR}}\ {\square \mathrm{\underline{K}EY}}\ {@} | □KCHAR □KEY @ |
| 1625 | []K_NAMED 1 | {\square \mathrm{\underline{K}NAMED}}\ {1} | □KNAMED 1 |
| 1642 | []V_IEW "1 + r_ange n" | {\square \mathrm{\underline{V}IEW}}\ {\text{"1 + r\_ange n"}} | □VIEW "1 + r_ange n" |
| 1681 | "reg/fixtures/table.toml" []L_IST "cols" | {\text{"reg/fixtures/table.toml"}}\ {\square \mathrm{\underline{L}IST}}\ {\text{"cols"}} | "reg/fixtures/table.toml" □LIST "cols" |
| 1687 | "reg/fixtures/table.toml" []L_IST "count" | {\text{"reg/fixtures/table.toml"}}\ {\square \mathrm{\underline{L}IST}}\ {\text{"count"}} | "reg/fixtures/table.toml" □LIST "count" |
| 1702 | s_hape ("reg/fixtures/table.toml" "cells") []T_ABLE ("rows" "cols") | {\mathrm{\underline{s}hape}}\ {(}{\text{"reg/fixtures/table.toml"}}\ {\text{"cells"}}{)}\ {\square \mathrm{\underline{T}ABLE}}\ {(}{\text{"rows"}}\ {\text{"cols"}}{)} | shape ("reg/fixtures/table.toml" "cells") □TABLE ("rows" "cols") |
| 1704 | 1 s_elect ("reg/fixtures/table.toml" "cells") []T_ABLE ("rows" "cols") | {1}\ {\mathrm{\underline{s}elect}}\ {(}{\text{"reg/fixtures/table.toml"}}\ {\text{"cells"}}{)}\ {\square \mathrm{\underline{T}ABLE}}\ {(}{\text{"rows"}}\ {\text{"cols"}}{)} | 1 select ("reg/fixtures/table.toml" "cells") □TABLE ("rows" "cols") |
| 1725 | []E_VENT @ | {\square \mathrm{\underline{E}VENT}}\ {@} | □EVENT @ |
| 1738 | []E_KIND []E_VENT @ | {\square \mathrm{\underline{E}KIND}}\ {\square \mathrm{\underline{E}VENT}}\ {@} | □EKIND □EVENT @ |
| 1751 | []E_AT []E_VENT @ | {\square \mathrm{\underline{E}AT}}\ {\square \mathrm{\underline{E}VENT}}\ {@} | □EAT □EVENT @ |
| 1763 | e := []E_VENT @; []K_CHAR []E_KEY []E_VENT @ | {\mathrm{e}}\ {\leftarrow}\ {\square \mathrm{\underline{E}VENT}}\ {@}{\diamond}\ {\square \mathrm{\underline{K}CHAR}}\ {\square \mathrm{\underline{E}KEY}}\ {\square \mathrm{\underline{E}VENT}}\ {@} | e ← □EVENT @⋄ □KCHAR □EKEY □EVENT @ |
| 1765 | []E_KEY []E_VENT @ | {\square \mathrm{\underline{E}KEY}}\ {\square \mathrm{\underline{E}VENT}}\ {@} | □EKEY □EVENT @ |
| 1777 | []C_OLOR 2 | {\square \mathrm{\underline{C}OLOR}}\ {2} | □COLOR 2 |
| 1789 | []S_CALE 3 | {\square \mathrm{\underline{S}CALE}}\ {3} | □SCALE 3 |
| 1802 | t_ally ([]C_OLOR 2) []F_G "hi" | {\mathrm{\underline{t}ally}}\ {(}{\square \mathrm{\underline{C}OLOR}}\ {2}{)}\ {\square \mathrm{\underline{F}G}}\ {\text{"hi"}} | tally (□COLOR 2) □FG "hi" |
| 1813 | t_ally ([]C_OLOR 5) []B_G "hi" | {\mathrm{\underline{t}ally}}\ {(}{\square \mathrm{\underline{C}OLOR}}\ {5}{)}\ {\square \mathrm{\underline{B}G}}\ {\text{"hi"}} | tally (□COLOR 5) □BG "hi" |
| 1824 | t_ally []B_OLD "hi" | {\mathrm{\underline{t}ally}}\ {\square \mathrm{\underline{B}OLD}}\ {\text{"hi"}} | tally □BOLD "hi" |
| 1836 | t_ally 2 5 []A_T "hi" | {\mathrm{\underline{t}ally}}\ {2}\ {5}\ {\square \mathrm{\underline{A}T}}\ {\text{"hi"}} | tally 2 5 □AT "hi" |
| 1847 | t_ally []C_LS @ | {\mathrm{\underline{t}ally}}\ {\square \mathrm{\underline{C}LS}}\ {@} | tally □CLS @ |
| 1859 | []T_E @ | {\square \mathrm{\underline{T}E}}\ {@} | □TE @ |
| 1871 | t_ally []E_RR "careful" | {\mathrm{\underline{t}ally}}\ {\square \mathrm{\underline{E}RR}}\ {\text{"careful"}} | tally □ERR "careful" |
| 1885 | 1 + []P_ANIC "stop here" | {1}\ {+}\ {\square \mathrm{\underline{P}ANIC}}\ {\text{"stop here"}} | 1 + □PANIC "stop here" |
| 1900 | "too-wide" []S_IGNAL "the grid is at most 9 wide" | {\text{"too-wide"}}\ {\square \mathrm{\underline{S}IGNAL}}\ {\text{"the grid is at most 9 wide"}} | "too-wide" □SIGNAL "the grid is at most 9 wide" |
| 1902 | "Bad Code" []S_IGNAL "not a code" | {\text{"Bad Code"}}\ {\square \mathrm{\underline{S}IGNAL}}\ {\text{"not a code"}} | "Bad Code" □SIGNAL "not a code" |
| 1926 | '{ @ -> []N_GET "no/such/file" } []T_RAP '{ e -> []R_ECOVER "" } | {\text{'}}{\{}\ {@}\ {\to}\ {\square \mathrm{\underline{N}GET}}\ {\text{"no/such/file"}}\ {\}}\ {\square \mathrm{\underline{T}RAP}}\ {\text{'}}{\{}\ {\mathrm{e}}\ {\to}\ {\square \mathrm{\underline{R}ECOVER}}\ {\text{""}}\ {\}} | ’{ @ → □NGET "no/such/file" } □TRAP ’{ e → □RECOVER "" } |
| 1928 | '{ @ -> "mine" []S_IGNAL "oops" } []T_RAP '{ e -> []R_ECOVER []E_CODE e } | {\text{'}}{\{}\ {@}\ {\to}\ {\text{"mine"}}\ {\square \mathrm{\underline{S}IGNAL}}\ {\text{"oops"}}\ {\}}\ {\square \mathrm{\underline{T}RAP}}\ {\text{'}}{\{}\ {\mathrm{e}}\ {\to}\ {\square \mathrm{\underline{R}ECOVER}}\ {\square \mathrm{\underline{E}CODE}}\ {\mathrm{e}}\ {\}} | ’{ @ → "mine" □SIGNAL "oops" } □TRAP ’{ e → □RECOVER □ECODE e } |
| 1930 | '{ @ -> 1 + 2 } []T_RAP '{ e -> []R_ECOVER 0 } | {\text{'}}{\{}\ {@}\ {\to}\ {1}\ {+}\ {2}\ {\}}\ {\square \mathrm{\underline{T}RAP}}\ {\text{'}}{\{}\ {\mathrm{e}}\ {\to}\ {\square \mathrm{\underline{R}ECOVER}}\ {0}\ {\}} | ’{ @ → 1 + 2 } □TRAP ’{ e → □RECOVER 0 } |
| 1941 | '{ @ -> f_irst 0 t_ake 1 2 } []T_RAP '{ e -> []R_ECOVER -1 } | {\text{'}}{\{}\ {@}\ {\to}\ {\mathrm{\underline{f}irst}}\ {0}\ {\mathrm{\underline{t}ake}}\ {1}\ {2}\ {\}}\ {\square \mathrm{\underline{T}RAP}}\ {\text{'}}{\{}\ {\mathrm{e}}\ {\to}\ {\square \mathrm{\underline{R}ECOVER}}\ {-1}\ {\}} | ’{ @ → first 0 take 1 2 } □TRAP ’{ e → □RECOVER −1 } |
| 1953 | '{ @ -> "a" []S_IGNAL "b" } []T_RAP '{ e -> ([]E_CODE e) m_atch "io" ? []R_ECOVER 1; []H_ALT e } | {\text{'}}{\{}\ {@}\ {\to}\ {\text{"a"}}\ {\square \mathrm{\underline{S}IGNAL}}\ {\text{"b"}}\ {\}}\ {\square \mathrm{\underline{T}RAP}}\ {\text{'}}{\{}\ {\mathrm{e}}\ {\to}\ {(}{\square \mathrm{\underline{E}CODE}}\ {\mathrm{e}}{)}\ {\mathrm{\underline{m}atch}}\ {\text{"io"}}\ {?}\ {\square \mathrm{\underline{R}ECOVER}}\ {1}{\diamond}\ {\square \mathrm{\underline{H}ALT}}\ {\mathrm{e}}\ {\}} | ’{ @ → "a" □SIGNAL "b" } □TRAP ’{ e → (□ECODE e) match "io" ? □RECOVER 1⋄ □HALT e } |
| 1965 | n! := 0; '{ @ -> n! := n! + 1; n! < 3 ? "again" []S_IGNAL "not yet"; n! } []T_RAP '{ e -> []R_ETRY e } | {\mathrm{n}!}\ {\leftarrow}\ {0}{\diamond}\ {\text{'}}{\{}\ {@}\ {\to}\ {\mathrm{n}!}\ {\leftarrow}\ {\mathrm{n}!}\ {+}\ {1}{\diamond}\ {\mathrm{n}!}\ {<}\ {3}\ {?}\ {\text{"again"}}\ {\square \mathrm{\underline{S}IGNAL}}\ {\text{"not yet"}}{\diamond}\ {\mathrm{n}!}\ {\}}\ {\square \mathrm{\underline{T}RAP}}\ {\text{'}}{\{}\ {\mathrm{e}}\ {\to}\ {\square \mathrm{\underline{R}ETRY}}\ {\mathrm{e}}\ {\}} | n! ← 0⋄ ’{ @ → n! ← n! + 1⋄ n! < 3 ? "again" □SIGNAL "not yet"⋄ n! } □TRAP ’{ e → □RETRY e } |
| 1967 | '{ @ -> "a" []S_IGNAL "b" } []T_RAP '{ e -> []R_ETRY e } | {\text{'}}{\{}\ {@}\ {\to}\ {\text{"a"}}\ {\square \mathrm{\underline{S}IGNAL}}\ {\text{"b"}}\ {\}}\ {\square \mathrm{\underline{T}RAP}}\ {\text{'}}{\{}\ {\mathrm{e}}\ {\to}\ {\square \mathrm{\underline{R}ETRY}}\ {\mathrm{e}}\ {\}} | ’{ @ → "a" □SIGNAL "b" } □TRAP ’{ e → □RETRY e } |
| 1978 | '{ @ -> "mine" []S_IGNAL "oops" } []T_RAP '{ e -> []R_ECOVER []E_CODE e } | {\text{'}}{\{}\ {@}\ {\to}\ {\text{"mine"}}\ {\square \mathrm{\underline{S}IGNAL}}\ {\text{"oops"}}\ {\}}\ {\square \mathrm{\underline{T}RAP}}\ {\text{'}}{\{}\ {\mathrm{e}}\ {\to}\ {\square \mathrm{\underline{R}ECOVER}}\ {\square \mathrm{\underline{E}CODE}}\ {\mathrm{e}}\ {\}} | ’{ @ → "mine" □SIGNAL "oops" } □TRAP ’{ e → □RECOVER □ECODE e } |
| 1989 | '{ @ -> "mine" []S_IGNAL "oops" } []T_RAP '{ e -> []R_ECOVER []E_MESSAGE e } | {\text{'}}{\{}\ {@}\ {\to}\ {\text{"mine"}}\ {\square \mathrm{\underline{S}IGNAL}}\ {\text{"oops"}}\ {\}}\ {\square \mathrm{\underline{T}RAP}}\ {\text{'}}{\{}\ {\mathrm{e}}\ {\to}\ {\square \mathrm{\underline{R}ECOVER}}\ {\square \mathrm{\underline{E}MESSAGE}}\ {\mathrm{e}}\ {\}} | ’{ @ → "mine" □SIGNAL "oops" } □TRAP ’{ e → □RECOVER □EMESSAGE e } |
| 2001 | '{ @ -> "mine" []S_IGNAL "oops" } []T_RAP '{ e -> []R_ECOVER []E_WHERE e } | {\text{'}}{\{}\ {@}\ {\to}\ {\text{"mine"}}\ {\square \mathrm{\underline{S}IGNAL}}\ {\text{"oops"}}\ {\}}\ {\square \mathrm{\underline{T}RAP}}\ {\text{'}}{\{}\ {\mathrm{e}}\ {\to}\ {\square \mathrm{\underline{R}ECOVER}}\ {\square \mathrm{\underline{E}WHERE}}\ {\mathrm{e}}\ {\}} | ’{ @ → "mine" □SIGNAL "oops" } □TRAP ’{ e → □RECOVER □EWHERE e } |
| 2017 | '{ @ -> 10 + (0 []W_ARN "empty" "nothing to add") } []T_RAP '{ e -> []C_ONTINUE e } | {\text{'}}{\{}\ {@}\ {\to}\ {10}\ {+}\ {(}{0}\ {\square \mathrm{\underline{W}ARN}}\ {\text{"empty"}}\ {\text{"nothing to add"}}{)}\ {\}}\ {\square \mathrm{\underline{T}RAP}}\ {\text{'}}{\{}\ {\mathrm{e}}\ {\to}\ {\square \mathrm{\underline{C}ONTINUE}}\ {\mathrm{e}}\ {\}} | ’{ @ → 10 + (0 □WARN "empty" "nothing to add") } □TRAP ’{ e → □CONTINUE e } |
| 2019 | '{ @ -> 10 + (0 []W_ARN "empty" "nothing to add") } []T_RAP '{ e -> []R_ECOVER 99 } | {\text{'}}{\{}\ {@}\ {\to}\ {10}\ {+}\ {(}{0}\ {\square \mathrm{\underline{W}ARN}}\ {\text{"empty"}}\ {\text{"nothing to add"}}{)}\ {\}}\ {\square \mathrm{\underline{T}RAP}}\ {\text{'}}{\{}\ {\mathrm{e}}\ {\to}\ {\square \mathrm{\underline{R}ECOVER}}\ {99}\ {\}} | ’{ @ → 10 + (0 □WARN "empty" "nothing to add") } □TRAP ’{ e → □RECOVER 99 } |
| 2021 | 10 + (0 []W_ARN "empty" "nothing to add") | {10}\ {+}\ {(}{0}\ {\square \mathrm{\underline{W}ARN}}\ {\text{"empty"}}\ {\text{"nothing to add"}}{)} | 10 + (0 □WARN "empty" "nothing to add") |
| 2036 | '{ @ -> '{ @ -> 10 + (0 []W_ARN "empty" "nothing") } []T_RAP '{ e -> []H_ALT e } } []T_RAP '{ e -> []C_ONTINUE e } | {\text{'}}{\{}\ {@}\ {\to}\ {\text{'}}{\{}\ {@}\ {\to}\ {10}\ {+}\ {(}{0}\ {\square \mathrm{\underline{W}ARN}}\ {\text{"empty"}}\ {\text{"nothing"}}{)}\ {\}}\ {\square \mathrm{\underline{T}RAP}}\ {\text{'}}{\{}\ {\mathrm{e}}\ {\to}\ {\square \mathrm{\underline{H}ALT}}\ {\mathrm{e}}\ {\}}\ {\}}\ {\square \mathrm{\underline{T}RAP}}\ {\text{'}}{\{}\ {\mathrm{e}}\ {\to}\ {\square \mathrm{\underline{C}ONTINUE}}\ {\mathrm{e}}\ {\}} | ’{ @ → ’{ @ → 10 + (0 □WARN "empty" "nothing") } □TRAP ’{ e → □HALT e } } □TRAP ’{ e → □CONTINUE e } |
| 2038 | '{ @ -> "a" []S_IGNAL "b" } []T_RAP '{ e -> []C_ONTINUE e } | {\text{'}}{\{}\ {@}\ {\to}\ {\text{"a"}}\ {\square \mathrm{\underline{S}IGNAL}}\ {\text{"b"}}\ {\}}\ {\square \mathrm{\underline{T}RAP}}\ {\text{'}}{\{}\ {\mathrm{e}}\ {\to}\ {\square \mathrm{\underline{C}ONTINUE}}\ {\mathrm{e}}\ {\}} | ’{ @ → "a" □SIGNAL "b" } □TRAP ’{ e → □CONTINUE e } |
| 2051 | '{ @ -> p_rint! 1; 2 } []E_NSURE '{ @ -> p_rint! "cleaned" } | {\text{'}}{\{}\ {@}\ {\to}\ {\mathrm{\underline{p}rint}{!}}\ {1}{\diamond}\ {2}\ {\}}\ {\square \mathrm{\underline{E}NSURE}}\ {\text{'}}{\{}\ {@}\ {\to}\ {\mathrm{\underline{p}rint}{!}}\ {\text{"cleaned"}}\ {\}} | ’{ @ → print! 1⋄ 2 } □ENSURE ’{ @ → print! "cleaned" } |
| 2055 | '{ @ -> "x" []S_IGNAL "y" } []E_NSURE '{ @ -> p_rint! "cleaned" } | {\text{'}}{\{}\ {@}\ {\to}\ {\text{"x"}}\ {\square \mathrm{\underline{S}IGNAL}}\ {\text{"y"}}\ {\}}\ {\square \mathrm{\underline{E}NSURE}}\ {\text{'}}{\{}\ {@}\ {\to}\ {\mathrm{\underline{p}rint}{!}}\ {\text{"cleaned"}}\ {\}} | ’{ @ → "x" □SIGNAL "y" } □ENSURE ’{ @ → print! "cleaned" } |
| 2073 | "bad-macro-argument right" []R_EJECT "no" | {\text{"bad-macro-argument right"}}\ {\square \mathrm{\underline{R}EJECT}}\ {\text{"no"}} | "bad-macro-argument right" □REJECT "no" |
| 2084 | []S_TATEMENT @ | {\square \mathrm{\underline{S}TATEMENT}}\ {@} | □STATEMENT @ |
| 2095 | []F_ILE @ | {\square \mathrm{\underline{F}ILE}}\ {@} | □FILE @ |
| 2106 | []L_INE @ | {\square \mathrm{\underline{L}INE}}\ {@} | □LINE @ |
| 2118 | []I_NCLUDE "data.txt" | {\square \mathrm{\underline{I}NCLUDE}}\ {\text{"data.txt"}} | □INCLUDE "data.txt" |
| 2130 | []C_FG "cli" | {\square \mathrm{\underline{C}FG}}\ {\text{"cli"}} | □CFG "cli" |
| 2145 | []G_ENSYM "t" | {\square \mathrm{\underline{G}ENSYM}}\ {\text{"t"}} | □GENSYM "t" |
| 2166 | []G_RID 1 0 | {\square \mathrm{\underline{G}RID}}\ {1}\ {0} | □GRID 1 0 |
| 2185 | ([]S_CALE 1) []N_GRID 0 9 | {(}{\square \mathrm{\underline{S}CALE}}\ {1}{)}\ {\square \mathrm{\underline{N}GRID}}\ {0}\ {9} | (□SCALE 1) □NGRID 0 9 |
| 2205 | []P_ATH 2 3 r_eshape 0 1 2 0 1 0 | {\square \mathrm{\underline{P}ATH}}\ {2}\ {3}\ {\mathrm{\underline{r}eshape}}\ {0}\ {1}\ {2}\ {0}\ {1}\ {0} | □PATH 2 3 reshape 0 1 2 0 1 0 |
| 2221 | 9 t_ake []S_HOW []G_RID 1 0 | {9}\ {\mathrm{\underline{t}ake}}\ {\square \mathrm{\underline{S}HOW}}\ {\square \mathrm{\underline{G}RID}}\ {1}\ {0} | 9 take □SHOW □GRID 1 0 |