| 11 | u:h_anoi := { n pegs -> | {{}^{\mathrm{u}}\mathrm{\underline{h}anoi}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\mathrm{pegs}}\ {\to} | uhanoi ← { n pegs → |
| 12 | n = 0 ? 0 2 r_eshape 0 | \ \ {\mathrm{n}}\ {=}\ {0}\ {?}\ {0}\ {2}\ {\mathrm{\underline{r}eshape}}\ {0} | n = 0 ? 0 2 reshape 0 |
| 13 | 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 |
| 14 | 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 |
| 15 | 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 |
| 16 | } | {\}} | } |
| 17 | 3 u:h_anoi 1 3 2 | {3}\ {{}^{\mathrm{u}}\mathrm{\underline{h}anoi}}\ {1}\ {3}\ {2} | 3 uhanoi 1 3 2 |
| 18 | '{ t_ally _r u:h_anoi 1 3 2 } e_ach r_ange 10 # 2^n - 1 moves | {\text{'}}{\{}\ {\mathrm{\underline{t}ally}}\ {\_\mathrm{r}}\ {{}^{\mathrm{u}}\mathrm{\underline{h}anoi}}\ {1}\ {3}\ {2}\ {\}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{\underline{r}ange}}\ {10} | ’{ tally _r uhanoi 1 3 2 } each range 10 |
| 27 | u:m_oves := { n -> | {{}^{\mathrm{u}}\mathrm{\underline{m}oves}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\to} | umoves ← { n → |
| 28 | k := r_ange (2 ^ n) - 1 | \ \ {\mathrm{k}}\ {\leftarrow}\ {\mathrm{\underline{r}ange}}\ {(}{2}\ {\mathbin{\hat{}}}\ {\mathrm{n}}{)}\ {-}\ {1} | k ← range (2 ^ n) − 1 |
| 29 | d := 1 + '+ r_/_2 0 = k 'm_od t_able 2 ^ r_ange n | \ \ {\mathrm{d}}\ {\leftarrow}\ {1}\ {+}\ {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{2}}\ {0}\ {=}\ {\mathrm{k}}\ {\text{'}}{\mathrm{\underline{m}od}}\ {\mathrm{\underline{t}able}}\ {2}\ {\mathbin{\hat{}}}\ {\mathrm{\underline{r}ange}}\ {\mathrm{n}} | d ← 1 + ’+ r/2 0 = k ’mod table 2 ^ range n |
| 30 | m := k d_iv 2 ^ d | \ \ {\mathrm{m}}\ {\leftarrow}\ {\mathrm{k}}\ {\mathrm{\underline{d}iv}}\ {2}\ {\mathbin{\hat{}}}\ {\mathrm{d}} | m ← k div 2 ^ d |
| 31 | s := 1 + 0 = (n - d) m_od 2 | \ \ {\mathrm{s}}\ {\leftarrow}\ {1}\ {+}\ {0}\ {=}\ {(}{\mathrm{n}}\ {-}\ {\mathrm{d}}{)}\ {\mathrm{\underline{m}od}}\ {2} | s ← 1 + 0 = (n − d) mod 2 |
| 32 | from := 1 + (s * m) m_od 3 | \ \ {\mathrm{from}}\ {\leftarrow}\ {1}\ {+}\ {(}{\mathrm{s}}\ {\times}\ {\mathrm{m}}{)}\ {\mathrm{\underline{m}od}}\ {3} | from ← 1 + (s × m) mod 3 |
| 33 | to := 1 + (s * m + 1) m_od 3 | \ \ {\mathrm{to}}\ {\leftarrow}\ {1}\ {+}\ {(}{\mathrm{s}}\ {\times}\ {\mathrm{m}}\ {+}\ {1}{)}\ {\mathrm{\underline{m}od}}\ {3} | to ← 1 + (s × m + 1) mod 3 |
| 34 | o_\ (2 c_at t_ally from) r_eshape from c_at to | \ \ {\mathrm{\underline{o}}{\backslash}}\ {(}{2}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{t}ally}}\ {\mathrm{from}}{)}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{from}}\ {\mathrm{\underline{c}at}}\ {\mathrm{to}} | o\ (2 cat tally from) reshape from cat to |
| 35 | } | {\}} | } |
| 36 | u:m_oves 3 | {{}^{\mathrm{u}}\mathrm{\underline{m}oves}}\ {3} | umoves 3 |
| 37 | '{ (u:m_oves _r) m_atch _r u:h_anoi 1 3 2 } e_ach r_ange 10 # the same moves | {\text{'}}{\{}\ {(}{{}^{\mathrm{u}}\mathrm{\underline{m}oves}}\ {\_\mathrm{r}}{)}\ {\mathrm{\underline{m}atch}}\ {\_\mathrm{r}}\ {{}^{\mathrm{u}}\mathrm{\underline{h}anoi}}\ {1}\ {3}\ {2}\ {\}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{\underline{r}ange}}\ {10} | ’{ (umoves _r) match _r uhanoi 1 3 2 } each range 10 |
| 46 | u:m_ove := { p m -> | {{}^{\mathrm{u}}\mathrm{\underline{m}ove}}\ {\leftarrow}\ {\{}\ {\mathrm{p}}\ {\mathrm{m}}\ {\to} | umove ← { p m → |
| 47 | from := 1 s_elect m | \ \ {\mathrm{from}}\ {\leftarrow}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{m}} | from ← 1 select m |
| 48 | disk := p i_ndexOf from | \ \ {\mathrm{disk}}\ {\leftarrow}\ {\mathrm{p}}\ {\mathrm{\underline{i}ndexOf}}\ {\mathrm{from}} | disk ← p indexOf from |
| 49 | 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 |
| 50 | } | {\}} | } |
| 51 | (3 r_eshape 1) u:m_ove 1 3 | {(}{3}\ {\mathrm{\underline{r}eshape}}\ {1}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{m}ove}}\ {1}\ {3} | (3 reshape 1) umove 1 3 |
| 56 | u:s_lots := { p -> | {{}^{\mathrm{u}}\mathrm{\underline{s}lots}}\ {\leftarrow}\ {\{}\ {\mathrm{p}}\ {\to} | uslots ← { p → |
| 57 | n := t_ally p | \ \ {\mathrm{n}}\ {\leftarrow}\ {\mathrm{\underline{t}ally}}\ {\mathrm{p}} | n ← tally p |
| 58 | (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 |
| 59 | } | {\}} | } |
| 60 | u:s_lots 1 2 3 | {{}^{\mathrm{u}}\mathrm{\underline{s}lots}}\ {1}\ {2}\ {3} | uslots 1 2 3 |
| 64 | u:p_icture := { p -> | {{}^{\mathrm{u}}\mathrm{\underline{p}icture}}\ {\leftarrow}\ {\{}\ {\mathrm{p}}\ {\to} | upicture ← { p → |
| 65 | n := t_ally p | \ \ {\mathrm{n}}\ {\leftarrow}\ {\mathrm{\underline{t}ally}}\ {\mathrm{p}} | n ← tally p |
| 66 | w := 1 + 2 * n | \ \ {\mathrm{w}}\ {\leftarrow}\ {1}\ {+}\ {2}\ {\times}\ {\mathrm{n}} | w ← 1 + 2 × n |
| 67 | 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 |
| 68 | (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 |
| 69 | } | {\}} | } |
| 72 | 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 } |
| 73 | u:p_lay := { p moves -> | {{}^{\mathrm{u}}\mathrm{\underline{p}lay}}\ {\leftarrow}\ {\{}\ {\mathrm{p}}\ {\mathrm{moves}}\ {\to} | uplay ← { p moves → |
| 74 | 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 |
| 75 | 0 = t_ally moves ? frame | \ \ {0}\ {=}\ {\mathrm{\underline{t}ally}}\ {\mathrm{moves}}\ {?}\ {\mathrm{frame}} | 0 = tally moves ? frame |
| 76 | 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 |
| 77 | } | {\}} | } |
| 78 | moves := 4 u:h_anoi 1 3 2 | {\mathrm{moves}}\ {\leftarrow}\ {4}\ {{}^{\mathrm{u}}\mathrm{\underline{h}anoi}}\ {1}\ {3}\ {2} | moves ← 4 uhanoi 1 3 2 |
| 79 | s_hape (4 r_eshape 1) u:p_lay moves | {\mathrm{\underline{s}hape}}\ {(}{4}\ {\mathrm{\underline{r}eshape}}\ {1}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{p}lay}}\ {\mathrm{moves}} | shape (4 reshape 1) uplay moves |
| 80 | watched := []S_HOW []G_RID (4 r_eshape 1) u:p_lay moves | {\mathrm{watched}}\ {\leftarrow}\ {\square \mathrm{\underline{S}HOW}}\ {\square \mathrm{\underline{G}RID}}\ {(}{4}\ {\mathrm{\underline{r}eshape}}\ {1}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{p}lay}}\ {\mathrm{moves}} | watched ← □SHOW □GRID (4 reshape 1) uplay moves |
| 7 | secret := 1 1 2 3 | {\mathrm{secret}}\ {\leftarrow}\ {1}\ {1}\ {2}\ {3} | secret ← 1 1 2 3 |
| 8 | guess := 3 1 1 4 | {\mathrm{guess}}\ {\leftarrow}\ {3}\ {1}\ {1}\ {4} | guess ← 3 1 1 4 |
| 9 | '+ r_/ secret = guess # black: equal in place | {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{secret}}\ {=}\ {\mathrm{guess}} | ’+ r/ secret = guess |
| 10 | c := '+ r_/_2 (r_ange 6) '= t_able secret | {\mathrm{c}}\ {\leftarrow}\ {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{2}}\ {(}{\mathrm{\underline{r}ange}}\ {6}{)}\ {\text{'}}{=}\ {\mathrm{\underline{t}able}}\ {\mathrm{secret}} | c ← ’+ r/2 (range 6) ’= table secret |
| 11 | c # how many of each color | {\mathrm{c}} | c |
| 12 | c m_in '+ r_/_2 (r_ange 6) '= t_able guess # colors both have | {\mathrm{c}}\ {\mathrm{\underline{m}in}}\ {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{2}}\ {(}{\mathrm{\underline{r}ange}}\ {6}{)}\ {\text{'}}{=}\ {\mathrm{\underline{t}able}}\ {\mathrm{guess}} | c min ’+ r/2 (range 6) ’= table guess |
| 15 | u:s_core := { s g -> | {{}^{\mathrm{u}}\mathrm{\underline{s}core}}\ {\leftarrow}\ {\{}\ {\mathrm{s}}\ {\mathrm{g}}\ {\to} | uscore ← { s g → |
| 16 | black := '+ r_/ s = g | \ \ {\mathrm{black}}\ {\leftarrow}\ {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{s}}\ {=}\ {\mathrm{g}} | black ← ’+ r/ s = g |
| 17 | both := '+ r_/ ('+ r_/_2 (r_ange 6) '= t_able s) m_in '+ r_/_2 (r_ange 6) '= t_able g | \ \ {\mathrm{both}}\ {\leftarrow}\ {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {(}{\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{2}}\ {(}{\mathrm{\underline{r}ange}}\ {6}{)}\ {\text{'}}{=}\ {\mathrm{\underline{t}able}}\ {\mathrm{s}}{)}\ {\mathrm{\underline{m}in}}\ {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{2}}\ {(}{\mathrm{\underline{r}ange}}\ {6}{)}\ {\text{'}}{=}\ {\mathrm{\underline{t}able}}\ {\mathrm{g}} | both ← ’+ r/ (’+ r/2 (range 6) ’= table s) min ’+ r/2 (range 6) ’= table g |
| 18 | black c_at both - black | \ \ {\mathrm{black}}\ {\mathrm{\underline{c}at}}\ {\mathrm{both}}\ {-}\ {\mathrm{black}} | black cat both − black |
| 19 | } | {\}} | } |
| 20 | secret u:s_core guess | {\mathrm{secret}}\ {{}^{\mathrm{u}}\mathrm{\underline{s}core}}\ {\mathrm{guess}} | secret uscore guess |
| 21 | secret u:s_core secret | {\mathrm{secret}}\ {{}^{\mathrm{u}}\mathrm{\underline{s}core}}\ {\mathrm{secret}} | secret uscore secret |
| 25 | codes := o_\ 1 + 6 6 6 6 e_ncode o_ffsets 1296 | {\mathrm{codes}}\ {\leftarrow}\ {\mathrm{\underline{o}}{\backslash}}\ {1}\ {+}\ {6}\ {6}\ {6}\ {6}\ {\mathrm{\underline{e}ncode}}\ {\mathrm{\underline{o}ffsets}}\ {1296} | codes ← o\ 1 + 6 6 6 6 encode offsets 1296 |
| 26 | t_ally codes | {\mathrm{\underline{t}ally}}\ {\mathrm{codes}} | tally codes |
| 27 | 3 t_ake codes | {3}\ {\mathrm{\underline{t}ake}}\ {\mathrm{codes}} | 3 take codes |
| 30 | u:s_cores := { c g -> | {{}^{\mathrm{u}}\mathrm{\underline{s}cores}}\ {\leftarrow}\ {\{}\ {\mathrm{c}}\ {\mathrm{g}}\ {\to} | uscores ← { c g → |
| 31 | n := t_ally c | \ \ {\mathrm{n}}\ {\leftarrow}\ {\mathrm{\underline{t}ally}}\ {\mathrm{c}} | n ← tally c |
| 32 | black := '+ r_/_2 c = (n c_at 4) r_eshape g | \ \ {\mathrm{black}}\ {\leftarrow}\ {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{2}}\ {\mathrm{c}}\ {=}\ {(}{\mathrm{n}}\ {\mathrm{\underline{c}at}}\ {4}{)}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{g}} | black ← ’+ r/2 c = (n cat 4) reshape g |
| 33 | have := '+ r_/_2 c '= t_able r_ange 6 | \ \ {\mathrm{have}}\ {\leftarrow}\ {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{2}}\ {\mathrm{c}}\ {\text{'}}{=}\ {\mathrm{\underline{t}able}}\ {\mathrm{\underline{r}ange}}\ {6} | have ← ’+ r/2 c ’= table range 6 |
| 34 | want := (n c_at 6) r_eshape '+ r_/_2 (r_ange 6) '= t_able g | \ \ {\mathrm{want}}\ {\leftarrow}\ {(}{\mathrm{n}}\ {\mathrm{\underline{c}at}}\ {6}{)}\ {\mathrm{\underline{r}eshape}}\ {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{2}}\ {(}{\mathrm{\underline{r}ange}}\ {6}{)}\ {\text{'}}{=}\ {\mathrm{\underline{t}able}}\ {\mathrm{g}} | want ← (n cat 6) reshape ’+ r/2 (range 6) ’= table g |
| 35 | both := '+ r_/_2 have m_in want | \ \ {\mathrm{both}}\ {\leftarrow}\ {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{2}}\ {\mathrm{have}}\ {\mathrm{\underline{m}in}}\ {\mathrm{want}} | both ← ’+ r/2 have min want |
| 36 | (10 * black) + both - black | \ \ {(}{10}\ {\times}\ {\mathrm{black}}{)}\ {+}\ {\mathrm{both}}\ {-}\ {\mathrm{black}} | (10 × black) + both − black |
| 37 | } | {\}} | } |
| 38 | x := codes u:s_cores 1 1 2 2 | {\mathrm{x}}\ {\leftarrow}\ {\mathrm{codes}}\ {{}^{\mathrm{u}}\mathrm{\underline{s}cores}}\ {1}\ {1}\ {2}\ {2} | x ← codes uscores 1 1 2 2 |
| 39 | 5 t_ake x | {5}\ {\mathrm{\underline{t}ake}}\ {\mathrm{x}} | 5 take x |
| 40 | u_nique x # the scores 1 1 2 2 can get | {\mathrm{\underline{u}nique}}\ {\mathrm{x}} | unique x |
| 45 | u:s_olve := { c s -> | {{}^{\mathrm{u}}\mathrm{\underline{s}olve}}\ {\leftarrow}\ {\{}\ {\mathrm{c}}\ {\mathrm{s}}\ {\to} | usolve ← { c s → |
| 46 | g := 4 r_eshape 1 s_elect c | \ \ {\mathrm{g}}\ {\leftarrow}\ {4}\ {\mathrm{\underline{r}eshape}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{c}} | g ← 4 reshape 1 select c |
| 47 | r := s u:s_core g | \ \ {\mathrm{r}}\ {\leftarrow}\ {\mathrm{s}}\ {{}^{\mathrm{u}}\mathrm{\underline{s}core}}\ {\mathrm{g}} | r ← s uscore g |
| 48 | row := 1 6 r_eshape g c_at r | \ \ {\mathrm{row}}\ {\leftarrow}\ {1}\ {6}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{g}}\ {\mathrm{\underline{c}at}}\ {\mathrm{r}} | row ← 1 6 reshape g cat r |
| 49 | k := '+ r_/ 10 1 * r | \ \ {\mathrm{k}}\ {\leftarrow}\ {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {10}\ {1}\ {\times}\ {\mathrm{r}} | k ← ’+ r/ 10 1 × r |
| 50 | 4 = f_irst r ? row; row c_at ((w_here k = c u:s_cores g) s_elect c) u:s_olve s | \ \ {4}\ {=}\ {\mathrm{\underline{f}irst}}\ {\mathrm{r}}\ {?}\ {\mathrm{row}}{\diamond}\ {\mathrm{row}}\ {\mathrm{\underline{c}at}}\ {(}{(}{\mathrm{\underline{w}here}}\ {\mathrm{k}}\ {=}\ {\mathrm{c}}\ {{}^{\mathrm{u}}\mathrm{\underline{s}cores}}\ {\mathrm{g}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{c}}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{s}olve}}\ {\mathrm{s}} | 4 = first r ? row⋄ row cat ((where k = c uscores g) select c) usolve s |
| 51 | } | {\}} | } |
| 52 | codes u:s_olve 6 5 3 3 | {\mathrm{codes}}\ {{}^{\mathrm{u}}\mathrm{\underline{s}olve}}\ {6}\ {5}\ {3}\ {3} | codes usolve 6 5 3 3 |
| 53 | secrets := 3 4 r_eshape 4 1 6 2 5 3 3 6 2 4 1 5 | {\mathrm{secrets}}\ {\leftarrow}\ {3}\ {4}\ {\mathrm{\underline{r}eshape}}\ {4}\ {1}\ {6}\ {2}\ {5}\ {3}\ {3}\ {6}\ {2}\ {4}\ {1}\ {5} | secrets ← 3 4 reshape 4 1 6 2 5 3 3 6 2 4 1 5 |
| 54 | '{ t_ally codes u:s_olve 4 r_eshape _r s_elect secrets } e_ach r_ange 3 | {\text{'}}{\{}\ {\mathrm{\underline{t}ally}}\ {\mathrm{codes}}\ {{}^{\mathrm{u}}\mathrm{\underline{s}olve}}\ {4}\ {\mathrm{\underline{r}eshape}}\ {\_\mathrm{r}}\ {\mathrm{\underline{s}elect}}\ {\mathrm{secrets}}\ {\}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{\underline{r}ange}}\ {3} | ’{ tally codes usolve 4 reshape _r select secrets } each range 3 |
| 57 | n := '{ t_ally codes u:s_olve 4 r_eshape (37 * _r) s_elect codes } e_ach r_ange 35 | {\mathrm{n}}\ {\leftarrow}\ {\text{'}}{\{}\ {\mathrm{\underline{t}ally}}\ {\mathrm{codes}}\ {{}^{\mathrm{u}}\mathrm{\underline{s}olve}}\ {4}\ {\mathrm{\underline{r}eshape}}\ {(}{37}\ {\times}\ {\_\mathrm{r}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{codes}}\ {\}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{\underline{r}ange}}\ {35} | n ← ’{ tally codes usolve 4 reshape (37 × _r) select codes } each range 35 |
| 58 | '+ r_/_2 (r_ange 8) '= t_able n # games won in 1, 2, ... 8 | {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{2}}\ {(}{\mathrm{\underline{r}ange}}\ {8}{)}\ {\text{'}}{=}\ {\mathrm{\underline{t}able}}\ {\mathrm{n}} | ’+ r/2 (range 8) ’= table n |
| 59 | (f_loat '+ r_/ n) / f_loat t_ally n # the average | {(}{\mathrm{\underline{f}loat}}\ {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{n}}{)}\ {\div}\ {\mathrm{\underline{f}loat}}\ {\mathrm{\underline{t}ally}}\ {\mathrm{n}} | (float ’+ r/ n) ÷ float tally n |
| 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 -> shown := p_rint! text; st } | {{}^{\mathrm{u}}\mathrm{\underline{s}ay}}\ {\leftarrow}\ {\{}\ {\mathrm{st}}\ {\mathrm{text}}\ {\to}\ {\mathrm{shown}}\ {\leftarrow}\ {\mathrm{\underline{p}rint}{!}}\ {\mathrm{text}}{\diamond}\ {\mathrm{st}}\ {\}} | usay ← { st text → shown ← 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 | echo := p_rint! " " c_at line | \ \ {\mathrm{echo}}\ {\leftarrow}\ {\mathrm{\underline{p}rint}{!}}\ {\text{" "}}\ {\mathrm{\underline{c}at}}\ {\mathrm{line}} | echo ← 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" |
| 12 | x := 5 # typed: x := 5 | {\mathrm{x}}\ {\leftarrow}\ {5} | x ← 5 |
| 16 | count! := 0 # typed: count! := 0 | {\mathrm{count}!}\ {\leftarrow}\ {0} | count! ← 0 |
| 17 | count! := count! + 1 # typed: count! := count! + 1 | {\mathrm{count}!}\ {\leftarrow}\ {\mathrm{count}!}\ {+}\ {1} | count! ← count! + 1 |
| 21 | r_ev 1 2 3 # typed: r_ev 1 2 3 | {\mathrm{\underline{r}ev}}\ {1}\ {2}\ {3} | rev 1 2 3 |
| 25 | u:s_quare := { _r * _r } # typed: u:s_quare := { _r * _r } | {{}^{\mathrm{u}}\mathrm{\underline{s}quare}}\ {\leftarrow}\ {\{}\ {\_\mathrm{r}}\ {\times}\ {\_\mathrm{r}}\ {\}} | usquare ← { _r × _r } |
| 26 | u:s_quare 7 # typed: u:s_quare 7 | {{}^{\mathrm{u}}\mathrm{\underline{s}quare}}\ {7} | usquare 7 |
| 32 | M := 2 3 r_eshape r_ange 6 # typed: 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 |
| 37 | '+ r_/ M # typed: '+ r_/ M | {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{M}} | ’+ r/ M |
| 41 | '+ r_/_1 M # typed: '+ r_/_1 M | {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{1}}\ {\mathrm{M}} | ’+ r/1 M |
| 44 | '+ r_/_2 M # typed: '+ r_/_2 M | {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{2}}\ {\mathrm{M}} | ’+ r/2 M |
| 48 | '+ r_/_12 M # typed: '+ r_/_12 M | {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{12}}\ {\mathrm{M}} | ’+ r/12 M |
| 51 | 'm_ax r_/_2 M # typed: 'm_ax r_/_2 M | {\text{'}}{\mathrm{\underline{m}ax}}\ {{\mathrm{\underline{r}}{/}}_{2}}\ {\mathrm{M}} | ’max r/2 M |
| 55 | '+ s_\ M # typed: '+ s_\ M | {\text{'}}{+}\ {\mathrm{\underline{s}}{\backslash}}\ {\mathrm{M}} | ’+ s\ M |
| 58 | '+ s_\_1 M # typed: '+ s_\_1 M | {\text{'}}{+}\ {{\mathrm{\underline{s}}{\backslash}}_{1}}\ {\mathrm{M}} | ’+ s\1 M |
| 61 | '+ s_\_2 M # typed: '+ s_\_2 M | {\text{'}}{+}\ {{\mathrm{\underline{s}}{\backslash}}_{2}}\ {\mathrm{M}} | ’+ s\2 M |
| 65 | 1 o_- M # typed: 1 o_- M | {1}\ {\mathrm{\underline{o}}{-}}\ {\mathrm{M}} | 1 o− M |
| 68 | 1 o_-_1 M # typed: 1 o_-_1 M | {1}\ {{\mathrm{\underline{o}}{-}}_{1}}\ {\mathrm{M}} | 1 o−1 M |
| 71 | 1 o_-_2 M # typed: 1 o_-_2 M | {1}\ {{\mathrm{\underline{o}}{-}}_{2}}\ {\mathrm{M}} | 1 o−2 M |
| 74 | -1 o_- 1 2 3 # typed: -1 o_- 1 2 3 | {-1}\ {\mathrm{\underline{o}}{-}}\ {1}\ {2}\ {3} | −1 o− 1 2 3 |
| 77 | -1 0 1 o_- 1 2 3 # typed: -1 0 1 o_- 1 2 3 | {-1}\ {0}\ {1}\ {\mathrm{\underline{o}}{-}}\ {1}\ {2}\ {3} | −1 0 1 o− 1 2 3 |
| 80 | r_ev M # typed: r_ev M | {\mathrm{\underline{r}ev}}\ {\mathrm{M}} | rev M |
| 83 | r_ev_1 M # typed: r_ev_1 M | {{\mathrm{\underline{r}ev}}_{1}}\ {\mathrm{M}} | rev1 M |
| 86 | r_ev_2 M # typed: r_ev_2 M | {{\mathrm{\underline{r}ev}}_{2}}\ {\mathrm{M}} | rev2 M |
| 91 | x^2 # typed: x^2 | {\mathrm{x}}^{2} | x2 |
| 95 | (1 9 25)^0.5 # typed: (1 9 25)^0.5 | {(}{1}\ {9}\ {25}{)}^{0.5} | (1 9 25)0.5 |
| 98 | x ^ 3 # typed: x ^ 3 | {\mathrm{x}}\ {\mathbin{\hat{}}}\ {3} | x ^ 3 |
| 102 | n_eg^3 5 # typed: n_eg^3 5 | {\mathrm{\underline{n}eg}}^{3}\ {5} | neg3 5 |
| 107 | -1 0 1 # typed: -1 0 1 | {-1}\ {0}\ {1} | −1 0 1 |
| 110 | 3 - 1 # typed: 3 - 1 | {3}\ {-}\ {1} | 3 − 1 |
| 114 | 3 -1 # typed: 3 -1 | {3}\ {-1} | 3 −1 |
| 117 | x - -3 # typed: x - -3 | {\mathrm{x}}\ {-}\ {-3} | x − −3 |
| 120 | 2.5 * 2 # typed: 2.5 * 2 | {2.5}\ {\times}\ {2} | 2.5 × 2 |
| 125 | x != 3 # typed: x != 3 | {\mathrm{x}}\ {\neq}\ {3} | x = 3 |
| 128 | x <= 5 # typed: x <= 5 | {\mathrm{x}}\ {\leq}\ {5} | x ≤ 5 |
| 132 | (x > 1) & x < 9 # typed: (x > 1) & x < 9 | {(}{\mathrm{x}}\ {>}\ {1}{)}\ {\wedge}\ {\mathrm{x}}\ {<}\ {9} | (x > 1) ∧ x < 9 |
| 133 | (x < 1) | x > 9 # typed: (x < 1) | x > 9 | {(}{\mathrm{x}}\ {<}\ {1}{)}\ {\vee}\ {\mathrm{x}}\ {>}\ {9} | (x < 1) ∨ x > 9 |
| 139 | u:a_dd := { _l + _r } # typed: u:a_dd := { _l + _r } | {{}^{\mathrm{u}}\mathrm{\underline{a}dd}}\ {\leftarrow}\ {\{}\ {\_\mathrm{l}}\ {+}\ {\_\mathrm{r}}\ {\}} | uadd ← { _l + _r } |
| 142 | 2 u:a_dd 3 # typed: 2 u:a_dd 3 | {2}\ {{}^{\mathrm{u}}\mathrm{\underline{a}dd}}\ {3} | 2 uadd 3 |
| 146 | u:s_ign := { n -> n < 0 ? -1; n = 0 ? 0; 1 } | {{}^{\mathrm{u}}\mathrm{\underline{s}ign}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\to}\ {\mathrm{n}}\ {<}\ {0}\ {?}\ {-1}{\diamond}\ {\mathrm{n}}\ {=}\ {0}\ {?}\ {0}{\diamond}\ {1}\ {\}} | usign ← { n → n < 0 ? −1⋄ n = 0 ? 0⋄ 1 } |
| 148 | u:s_ign -4 # typed: u:s_ign -4 | {{}^{\mathrm{u}}\mathrm{\underline{s}ign}}\ {-4} | usign −4 |
| 152 | '{ _r * 10 } e_ach 1 2 # typed: '{ _r * 10 } e_ach 1 2 | {\text{'}}{\{}\ {\_\mathrm{r}}\ {\times}\ {10}\ {\}}\ {\mathrm{\underline{e}ach}}\ {1}\ {2} | ’{ _r × 10 } each 1 2 |
| 156 | u:m_ean := ['+ r_/ / t_ally] # typed: u:m_ean := ['+ r_/ / t_ally] | {{}^{\mathrm{u}}\mathrm{\underline{m}ean}}\ {\leftarrow}\ {[}{\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\div}\ {\mathrm{\underline{t}ally}}{]} | umean ← [’+ r/ ÷ tally] |
| 157 | u:m_ean 1 2 3 4 # typed: u:m_ean 1 2 3 4 | {{}^{\mathrm{u}}\mathrm{\underline{m}ean}}\ {1}\ {2}\ {3}\ {4} | umean 1 2 3 4 |
| 163 | "hello" c_at " world" # typed: "hello" c_at " world" | {\text{"hello"}}\ {\mathrm{\underline{c}at}}\ {\text{" world"}} | "hello" cat " world" |
| 166 | t_ally @ # typed: t_ally @ | {\mathrm{\underline{t}ally}}\ {@} | tally @ |
| 169 | 1 + 1; 2 + 2 # typed: 1 + 1; 2 + 2 | {1}\ {+}\ {1}{\diamond}\ {2}\ {+}\ {2} | 1 + 1⋄ 2 + 2 |
| 176 | "c:" u_se< "Combinators" # typed: "c:" u_se< "Combinators" | {\text{"c:"}}\ {\mathrm{\underline{u}se}{<}}\ {\text{"Combinators"}} | "c:" use< "Combinators" |
| 180 | 1 c:K_ 2 # typed: 1 c:K_ 2 | {1}\ {{}^{\mathrm{c}}\mathrm{\underline{K}}}\ {2} | 1 cK 2 |
| 183 | f_ormat 3.5 # typed: f_ormat 3.5 | {\mathrm{\underline{f}ormat}}\ {3.5} | format 3.5 |
| 188 | "hi" []N_PUT "work/keys.txt" # typed: "hi" []N_PUT "work/keys.txt" | {\text{"hi"}}\ {\square \mathrm{\underline{N}PUT}}\ {\text{"work/keys.txt"}} | "hi" □NPUT "work/keys.txt" |
| 7 | s := "aa123bc42abc9zyz" | {\mathrm{s}}\ {\leftarrow}\ {\text{"aa123bc42abc9zyz"}} | s ← "aa123bc42abc9zyz" |
| 8 | m := 0 + s m_ember? "0123456789" # 1 at each digit (0 + makes it an Int) | {\mathrm{m}}\ {\leftarrow}\ {0}\ {+}\ {\mathrm{s}}\ {\mathrm{\underline{m}ember}{?}}\ {\text{"0123456789"}} | m ← 0 + s member? "0123456789" |
| 9 | m | {\mathrm{m}} | m |
| 13 | (1 + m * r_ange t_ally s) s_elect " " c_at s | {(}{1}\ {+}\ {\mathrm{m}}\ {\times}\ {\mathrm{\underline{r}ange}}\ {\mathrm{\underline{t}ally}}\ {\mathrm{s}}{)}\ {\mathrm{\underline{s}elect}}\ {\text{" "}}\ {\mathrm{\underline{c}at}}\ {\mathrm{s}} | (1 + m × range tally s) select " " cat s |
| 14 | n_umbers (1 + m * r_ange t_ally s) s_elect " " c_at s | {\mathrm{\underline{n}umbers}}\ {(}{1}\ {+}\ {\mathrm{m}}\ {\times}\ {\mathrm{\underline{r}ange}}\ {\mathrm{\underline{t}ally}}\ {\mathrm{s}}{)}\ {\mathrm{\underline{s}elect}}\ {\text{" "}}\ {\mathrm{\underline{c}at}}\ {\mathrm{s}} | numbers (1 + m × range tally s) select " " cat s |
| 20 | d := -1 + "0123456789" i_ndexOf m r_eplicate s | {\mathrm{d}}\ {\leftarrow}\ {-1}\ {+}\ {\text{"0123456789"}}\ {\mathrm{\underline{i}ndexOf}}\ {\mathrm{m}}\ {\mathrm{\underline{r}eplicate}}\ {\mathrm{s}} | d ← −1 + "0123456789" indexOf m replicate s |
| 21 | g := m r_eplicate '+ s_\ m > 0 c_at -1 d_rop m | {\mathrm{g}}\ {\leftarrow}\ {\mathrm{m}}\ {\mathrm{\underline{r}eplicate}}\ {\text{'}}{+}\ {\mathrm{\underline{s}}{\backslash}}\ {\mathrm{m}}\ {>}\ {0}\ {\mathrm{\underline{c}at}}\ {-1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{m}} | g ← m replicate ’+ s\ m > 0 cat −1 drop m |
| 22 | d | {\mathrm{d}} | d |
| 23 | g | {\mathrm{g}} | g |
| 24 | u:n_ums := { s -> | {{}^{\mathrm{u}}\mathrm{\underline{n}ums}}\ {\leftarrow}\ {\{}\ {\mathrm{s}}\ {\to} | unums ← { s → |
| 25 | m := 0 + s m_ember? "0123456789" | \ \ {\mathrm{m}}\ {\leftarrow}\ {0}\ {+}\ {\mathrm{s}}\ {\mathrm{\underline{m}ember}{?}}\ {\text{"0123456789"}} | m ← 0 + s member? "0123456789" |
| 26 | d := -1 + "0123456789" i_ndexOf m r_eplicate s | \ \ {\mathrm{d}}\ {\leftarrow}\ {-1}\ {+}\ {\text{"0123456789"}}\ {\mathrm{\underline{i}ndexOf}}\ {\mathrm{m}}\ {\mathrm{\underline{r}eplicate}}\ {\mathrm{s}} | d ← −1 + "0123456789" indexOf m replicate s |
| 27 | g := m r_eplicate '+ s_\ m > 0 c_at -1 d_rop m | \ \ {\mathrm{g}}\ {\leftarrow}\ {\mathrm{m}}\ {\mathrm{\underline{r}eplicate}}\ {\text{'}}{+}\ {\mathrm{\underline{s}}{\backslash}}\ {\mathrm{m}}\ {>}\ {0}\ {\mathrm{\underline{c}at}}\ {-1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{m}} | g ← m replicate ’+ s\ m > 0 cat −1 drop m |
| 28 | k := '+ r_/ m > 0 c_at -1 d_rop m | \ \ {\mathrm{k}}\ {\leftarrow}\ {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{m}}\ {>}\ {0}\ {\mathrm{\underline{c}at}}\ {-1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{m}} | k ← ’+ r/ m > 0 cat −1 drop m |
| 29 | c := '+ r_/_2 (r_ange k) '= t_able g | \ \ {\mathrm{c}}\ {\leftarrow}\ {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{2}}\ {(}{\mathrm{\underline{r}ange}}\ {\mathrm{k}}{)}\ {\text{'}}{=}\ {\mathrm{\underline{t}able}}\ {\mathrm{g}} | c ← ’+ r/2 (range k) ’= table g |
| 30 | e := (g s_elect '+ s_\ c) - r_ange t_ally g | \ \ {\mathrm{e}}\ {\leftarrow}\ {(}{\mathrm{g}}\ {\mathrm{\underline{s}elect}}\ {\text{'}}{+}\ {\mathrm{\underline{s}}{\backslash}}\ {\mathrm{c}}{)}\ {-}\ {\mathrm{\underline{r}ange}}\ {\mathrm{\underline{t}ally}}\ {\mathrm{g}} | e ← (g select ’+ s\ c) − range tally g |
| 31 | '+ r_/_2 ((r_ange k) '= t_able g) * (k c_at t_ally g) r_eshape d * 10 ^ e | \ \ {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{2}}\ {(}{(}{\mathrm{\underline{r}ange}}\ {\mathrm{k}}{)}\ {\text{'}}{=}\ {\mathrm{\underline{t}able}}\ {\mathrm{g}}{)}\ {\times}\ {(}{\mathrm{k}}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{t}ally}}\ {\mathrm{g}}{)}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{d}}\ {\times}\ {10}\ {\mathbin{\hat{}}}\ {\mathrm{e}} | ’+ r/2 ((range k) ’= table g) × (k cat tally g) reshape d × 10 ^ e |
| 32 | } | {\}} | } |
| 33 | n := u:n_ums s | {\mathrm{n}}\ {\leftarrow}\ {{}^{\mathrm{u}}\mathrm{\underline{n}ums}}\ {\mathrm{s}} | n ← unums s |
| 34 | n | {\mathrm{n}} | n |
| 35 | (f_loor n_umbers (1 + m * r_ange t_ally s) s_elect " " c_at s) m_atch n # the two ways agree | {(}{\mathrm{\underline{f}loor}}\ {\mathrm{\underline{n}umbers}}\ {(}{1}\ {+}\ {\mathrm{m}}\ {\times}\ {\mathrm{\underline{r}ange}}\ {\mathrm{\underline{t}ally}}\ {\mathrm{s}}{)}\ {\mathrm{\underline{s}elect}}\ {\text{" "}}\ {\mathrm{\underline{c}at}}\ {\mathrm{s}}{)}\ {\mathrm{\underline{m}atch}}\ {\mathrm{n}} | (floor numbers (1 + m × range tally s) select " " cat s) match n |
| 38 | t_ally u_nique n | {\mathrm{\underline{t}ally}}\ {\mathrm{\underline{u}nique}}\ {\mathrm{n}} | tally unique n |
| 39 | t_ally u_nique u:n_ums "a123bc34d8ef34" # 123 34 8 34: 3 | {\mathrm{\underline{t}ally}}\ {\mathrm{\underline{u}nique}}\ {{}^{\mathrm{u}}\mathrm{\underline{n}ums}}\ {\text{"a123bc34d8ef34"}} | tally unique unums "a123bc34d8ef34" |
| 40 | t_ally u_nique u:n_ums "leet1234code234" # 2 | {\mathrm{\underline{t}ally}}\ {\mathrm{\underline{u}nique}}\ {{}^{\mathrm{u}}\mathrm{\underline{n}ums}}\ {\text{"leet1234code234"}} | tally unique unums "leet1234code234" |
| 41 | t_ally u_nique u:n_ums "a1b01c001" # 1, 01 and 001 are all 1 | {\mathrm{\underline{t}ally}}\ {\mathrm{\underline{u}nique}}\ {{}^{\mathrm{u}}\mathrm{\underline{n}ums}}\ {\text{"a1b01c001"}} | tally unique unums "a1b01c001" |
| 46 | u:d_ifferent := { s -> | {{}^{\mathrm{u}}\mathrm{\underline{d}ifferent}}\ {\leftarrow}\ {\{}\ {\mathrm{s}}\ {\to} | udifferent ← { s → |
| 47 | runs := (s m_ember? "0123456789") p_artition s | \ \ {\mathrm{runs}}\ {\leftarrow}\ {(}{\mathrm{s}}\ {\mathrm{\underline{m}ember}{?}}\ {\text{"0123456789"}}{)}\ {\mathrm{\underline{p}artition}}\ {\mathrm{s}} | runs ← (s member? "0123456789") partition s |
| 48 | '{ d -> t := d_isclose d; ('| s_\ t != f_irst "0") r_eplicate t } m_ap runs | \ \ {\text{'}}{\{}\ {\mathrm{d}}\ {\to}\ {\mathrm{t}}\ {\leftarrow}\ {\mathrm{\underline{d}isclose}}\ {\mathrm{d}}{\diamond}\ {(}{\text{'}}{\vee}\ {\mathrm{\underline{s}}{\backslash}}\ {\mathrm{t}}\ {\neq}\ {\mathrm{\underline{f}irst}}\ {\text{"0"}}{)}\ {\mathrm{\underline{r}eplicate}}\ {\mathrm{t}}\ {\}}\ {\mathrm{\underline{m}ap}}\ {\mathrm{runs}} | ’{ d → t ← disclose d⋄ (’∨ s\ t = first "0") replicate t } map runs |
| 49 | } | {\}} | } |
| 50 | t_ally u_nique u:d_ifferent "a123bc34d8ef34" # 3 | {\mathrm{\underline{t}ally}}\ {\mathrm{\underline{u}nique}}\ {{}^{\mathrm{u}}\mathrm{\underline{d}ifferent}}\ {\text{"a123bc34d8ef34"}} | tally unique udifferent "a123bc34d8ef34" |
| 51 | t_ally u_nique u:d_ifferent "a1b01c001" # 1 | {\mathrm{\underline{t}ally}}\ {\mathrm{\underline{u}nique}}\ {{}^{\mathrm{u}}\mathrm{\underline{d}ifferent}}\ {\text{"a1b01c001"}} | tally unique udifferent "a1b01c001" |
| 52 | t_ally u_nique u:d_ifferent "x123456789012345678901234567890y0123456789012345678901234567890z" # 1, past any Int | {\mathrm{\underline{t}ally}}\ {\mathrm{\underline{u}nique}}\ {{}^{\mathrm{u}}\mathrm{\underline{d}ifferent}}\ {\text{"x123456789012345678901234567890y0123456789012345678901234567890z"}} | tally unique udifferent "x123456789012345678901234567890y0123456789012345678901234567890z" |
| 55 | 'm_ax r_/ n # the largest | {\text{'}}{\mathrm{\underline{m}ax}}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{n}} | ’max r/ n |
| 56 | '+ r_/ n # the sum | {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{n}} | ’+ r/ n |
| 57 | u_nique u:n_ums "x7y7z12w7q12" # without repeats, first-seen order | {\mathrm{\underline{u}nique}}\ {{}^{\mathrm{u}}\mathrm{\underline{n}ums}}\ {\text{"x7y7z12w7q12"}} | unique unums "x7y7z12w7q12" |
| 58 | s_ort n # in order | {\mathrm{\underline{s}ort}}\ {\mathrm{n}} | sort n |
| 59 | '+ r_/ d # the sum of the digits | {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{d}} | ’+ r/ d |
| 60 | w_here m > 0 c_at -1 d_rop m # where each number starts | {\mathrm{\underline{w}here}}\ {\mathrm{m}}\ {>}\ {0}\ {\mathrm{\underline{c}at}}\ {-1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{m}} | where m > 0 cat −1 drop m |
| 63 | u:s_econd := { s -> | {{}^{\mathrm{u}}\mathrm{\underline{s}econd}}\ {\leftarrow}\ {\{}\ {\mathrm{s}}\ {\to} | usecond ← { s → |
| 64 | m := 0 + s m_ember? "0123456789" | \ \ {\mathrm{m}}\ {\leftarrow}\ {0}\ {+}\ {\mathrm{s}}\ {\mathrm{\underline{m}ember}{?}}\ {\text{"0123456789"}} | m ← 0 + s member? "0123456789" |
| 65 | u := r_ev s_ort u_nique -1 + "0123456789" i_ndexOf m r_eplicate s | \ \ {\mathrm{u}}\ {\leftarrow}\ {\mathrm{\underline{r}ev}}\ {\mathrm{\underline{s}ort}}\ {\mathrm{\underline{u}nique}}\ {-1}\ {+}\ {\text{"0123456789"}}\ {\mathrm{\underline{i}ndexOf}}\ {\mathrm{m}}\ {\mathrm{\underline{r}eplicate}}\ {\mathrm{s}} | u ← rev sort unique −1 + "0123456789" indexOf m replicate s |
| 66 | 2 > t_ally u ? -1; 2 s_elect u | \ \ {2}\ {>}\ {\mathrm{\underline{t}ally}}\ {\mathrm{u}}\ {?}\ {-1}{\diamond}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{u}} | 2 > tally u ? −1⋄ 2 select u |
| 67 | } | {\}} | } |
| 68 | u:s_econd "dfa12321afd" # 3 | {{}^{\mathrm{u}}\mathrm{\underline{s}econd}}\ {\text{"dfa12321afd"}} | usecond "dfa12321afd" |
| 69 | u:s_econd "abc1111" # -1 | {{}^{\mathrm{u}}\mathrm{\underline{s}econd}}\ {\text{"abc1111"}} | usecond "abc1111" |
| 72 | u:a_scending := { s -> n := u:n_ums s; '& r_/ (1 d_rop n) > -1 d_rop n } | {{}^{\mathrm{u}}\mathrm{\underline{a}scending}}\ {\leftarrow}\ {\{}\ {\mathrm{s}}\ {\to}\ {\mathrm{n}}\ {\leftarrow}\ {{}^{\mathrm{u}}\mathrm{\underline{n}ums}}\ {\mathrm{s}}{\diamond}\ {\text{'}}{\wedge}\ {\mathrm{\underline{r}}{/}}\ {(}{1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{n}}{)}\ {>}\ {-1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{n}}\ {\}} | uascending ← { s → n ← unums s⋄ ’∧ r/ (1 drop n) > −1 drop n } |
| 73 | u:a_scending "1 box has 3 blue 4 red 6 green and 12 yellow marbles" | {{}^{\mathrm{u}}\mathrm{\underline{a}scending}}\ {\text{"1 box has 3 blue 4 red 6 green and 12 yellow marbles"}} | uascending "1 box has 3 blue 4 red 6 green and 12 yellow marbles" |
| 74 | u:a_scending "hello world 5 x 5" | {{}^{\mathrm{u}}\mathrm{\underline{a}scending}}\ {\text{"hello world 5 x 5"}} | uascending "hello world 5 x 5" |
| 6 | u:r_ps := { x y -> d := (x - y) m_od 3; y + (x - y) * d <= 1 } | {{}^{\mathrm{u}}\mathrm{\underline{r}ps}}\ {\leftarrow}\ {\{}\ {\mathrm{x}}\ {\mathrm{y}}\ {\to}\ {\mathrm{d}}\ {\leftarrow}\ {(}{\mathrm{x}}\ {-}\ {\mathrm{y}}{)}\ {\mathrm{\underline{m}od}}\ {3}{\diamond}\ {\mathrm{y}}\ {+}\ {(}{\mathrm{x}}\ {-}\ {\mathrm{y}}{)}\ {\times}\ {\mathrm{d}}\ {\leq}\ {1}\ {\}} | urps ← { x y → d ← (x − y) mod 3⋄ y + (x − y) × d ≤ 1 } |
| 7 | names := "rock" "paper" "scissors" | {\mathrm{names}}\ {\leftarrow}\ {\text{"rock"}}\ {\text{"paper"}}\ {\text{"scissors"}} | names ← "rock" "paper" "scissors" |
| 8 | t := (r_ange 3) 'u:r_ps t_able r_ange 3 | {\mathrm{t}}\ {\leftarrow}\ {(}{\mathrm{\underline{r}ange}}\ {3}{)}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{r}ps}}\ {\mathrm{\underline{t}able}}\ {\mathrm{\underline{r}ange}}\ {3} | t ← (range 3) ’urps table range 3 |
| 9 | t # the Cayley table: 1 rock, 2 paper, 3 scissors | {\mathrm{t}} | t |
| 10 | t s_elect names # the same, by name | {\mathrm{t}}\ {\mathrm{\underline{s}elect}}\ {\mathrm{names}} | t select names |
| 14 | u:c_ommutative := { f_ n -> ((r_ange n) 'f_ t_able r_ange n) m_atch (r_ange n) '{ _r f_ _l } t_able r_ange n } | {{}^{\mathrm{u}}\mathrm{\underline{c}ommutative}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{f}}}\ {\mathrm{n}}\ {\to}\ {(}{(}{\mathrm{\underline{r}ange}}\ {\mathrm{n}}{)}\ {\text{'}}{\mathrm{\underline{f}}}\ {\mathrm{\underline{t}able}}\ {\mathrm{\underline{r}ange}}\ {\mathrm{n}}{)}\ {\mathrm{\underline{m}atch}}\ {(}{\mathrm{\underline{r}ange}}\ {\mathrm{n}}{)}\ {\text{'}}{\{}\ {\_\mathrm{r}}\ {\mathrm{\underline{f}}}\ {\_\mathrm{l}}\ {\}}\ {\mathrm{\underline{t}able}}\ {\mathrm{\underline{r}ange}}\ {\mathrm{n}}\ {\}} | ucommutative ← { f n → ((range n) ’f table range n) match (range n) ’{ _r f _l } table range n } |
| 15 | u:i_dempotent := { f_ n -> (r_ange n) m_atch '{ _r f_ _r } e_ach r_ange n } | {{}^{\mathrm{u}}\mathrm{\underline{i}dempotent}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{f}}}\ {\mathrm{n}}\ {\to}\ {(}{\mathrm{\underline{r}ange}}\ {\mathrm{n}}{)}\ {\mathrm{\underline{m}atch}}\ {\text{'}}{\{}\ {\_\mathrm{r}}\ {\mathrm{\underline{f}}}\ {\_\mathrm{r}}\ {\}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{\underline{r}ange}}\ {\mathrm{n}}\ {\}} | uidempotent ← { f n → (range n) match ’{ _r f _r } each range n } |
| 16 | u:a_ssociative := { f_ n -> | {{}^{\mathrm{u}}\mathrm{\underline{a}ssociative}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{f}}}\ {\mathrm{n}}\ {\to} | uassociative ← { f n → |
| 17 | t := 1 + (3 r_eshape n) e_ncode o_ffsets n ^ 3 | \ \ {\mathrm{t}}\ {\leftarrow}\ {1}\ {+}\ {(}{3}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{n}}{)}\ {\mathrm{\underline{e}ncode}}\ {\mathrm{\underline{o}ffsets}}\ {\mathrm{n}}\ {\mathbin{\hat{}}}\ {3} | t ← 1 + (3 reshape n) encode offsets n ^ 3 |
| 18 | x := 1 s_elect t | \ \ {\mathrm{x}}\ {\leftarrow}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{t}} | x ← 1 select t |
| 19 | y := 2 s_elect t | \ \ {\mathrm{y}}\ {\leftarrow}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{t}} | y ← 2 select t |
| 20 | z := 3 s_elect t | \ \ {\mathrm{z}}\ {\leftarrow}\ {3}\ {\mathrm{\underline{s}elect}}\ {\mathrm{t}} | z ← 3 select t |
| 21 | '& r_/ ((x f_ y) f_ z) = x f_ y f_ z | \ \ {\text{'}}{\wedge}\ {\mathrm{\underline{r}}{/}}\ {(}{(}{\mathrm{x}}\ {\mathrm{\underline{f}}}\ {\mathrm{y}}{)}\ {\mathrm{\underline{f}}}\ {\mathrm{z}}{)}\ {=}\ {\mathrm{x}}\ {\mathrm{\underline{f}}}\ {\mathrm{y}}\ {\mathrm{\underline{f}}}\ {\mathrm{z}} | ’∧ r/ ((x f y) f z) = x f y f z |
| 22 | } | {\}} | } |
| 23 | u:i_dentity := { f_ n -> # the identity element, or 0 for none | {{}^{\mathrm{u}}\mathrm{\underline{i}dentity}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{f}}}\ {\mathrm{n}}\ {\to} | uidentity ← { f n → |
| 24 | r := r_ange n | \ \ {\mathrm{r}}\ {\leftarrow}\ {\mathrm{\underline{r}ange}}\ {\mathrm{n}} | r ← range n |
| 25 | e := w_here '{ (r m_atch _r f_ r) & r m_atch r f_ _r } e_ach r | \ \ {\mathrm{e}}\ {\leftarrow}\ {\mathrm{\underline{w}here}}\ {\text{'}}{\{}\ {(}{\mathrm{r}}\ {\mathrm{\underline{m}atch}}\ {\_\mathrm{r}}\ {\mathrm{\underline{f}}}\ {\mathrm{r}}{)}\ {\wedge}\ {\mathrm{r}}\ {\mathrm{\underline{m}atch}}\ {\mathrm{r}}\ {\mathrm{\underline{f}}}\ {\_\mathrm{r}}\ {\}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{r}} | e ← where ’{ (r match _r f r) ∧ r match r f _r } each r |
| 26 | 0 = t_ally e ? 0; f_irst e | \ \ {0}\ {=}\ {\mathrm{\underline{t}ally}}\ {\mathrm{e}}\ {?}\ {0}{\diamond}\ {\mathrm{\underline{f}irst}}\ {\mathrm{e}} | 0 = tally e ? 0⋄ first e |
| 27 | } | {\}} | } |
| 28 | 'u:r_ps u:c_ommutative 3 | {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{r}ps}}\ {{}^{\mathrm{u}}\mathrm{\underline{c}ommutative}}\ {3} | ’urps ucommutative 3 |
| 29 | 'u:r_ps u:i_dempotent 3 | {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{r}ps}}\ {{}^{\mathrm{u}}\mathrm{\underline{i}dempotent}}\ {3} | ’urps uidempotent 3 |
| 30 | 'u:r_ps u:a_ssociative 3 # not associative | {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{r}ps}}\ {{}^{\mathrm{u}}\mathrm{\underline{a}ssociative}}\ {3} | ’urps uassociative 3 |
| 31 | 'u:r_ps u:i_dentity 3 # no identity | {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{r}ps}}\ {{}^{\mathrm{u}}\mathrm{\underline{i}dentity}}\ {3} | ’urps uidentity 3 |
| 35 | 'u:r_ps r_/ 1 2 3 # rock vs (paper vs scissors): rock | {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{r}ps}}\ {\mathrm{\underline{r}}{/}}\ {1}\ {2}\ {3} | ’urps r/ 1 2 3 |
| 36 | (1 u:r_ps 2) u:r_ps 3 # (rock vs paper) vs scissors: scissors | {(}{1}\ {{}^{\mathrm{u}}\mathrm{\underline{r}ps}}\ {2}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{r}ps}}\ {3} | (1 urps 2) urps 3 |
| 40 | u:a_dd := { x y -> 1 + (x + y - 2) m_od 3 } | {{}^{\mathrm{u}}\mathrm{\underline{a}dd}}\ {\leftarrow}\ {\{}\ {\mathrm{x}}\ {\mathrm{y}}\ {\to}\ {1}\ {+}\ {(}{\mathrm{x}}\ {+}\ {\mathrm{y}}\ {-}\ {2}{)}\ {\mathrm{\underline{m}od}}\ {3}\ {\}} | uadd ← { x y → 1 + (x + y − 2) mod 3 } |
| 41 | u:s_ub := { x y -> 1 + (x - y) m_od 3 } | {{}^{\mathrm{u}}\mathrm{\underline{s}ub}}\ {\leftarrow}\ {\{}\ {\mathrm{x}}\ {\mathrm{y}}\ {\to}\ {1}\ {+}\ {(}{\mathrm{x}}\ {-}\ {\mathrm{y}}{)}\ {\mathrm{\underline{m}od}}\ {3}\ {\}} | usub ← { x y → 1 + (x − y) mod 3 } |
| 42 | 'u:a_dd u:c_ommutative 3 | {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}dd}}\ {{}^{\mathrm{u}}\mathrm{\underline{c}ommutative}}\ {3} | ’uadd ucommutative 3 |
| 43 | 'u:a_dd u:a_ssociative 3 | {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}dd}}\ {{}^{\mathrm{u}}\mathrm{\underline{a}ssociative}}\ {3} | ’uadd uassociative 3 |
| 44 | 'u:a_dd u:i_dentity 3 # 1 stands for 0 | {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}dd}}\ {{}^{\mathrm{u}}\mathrm{\underline{i}dentity}}\ {3} | ’uadd uidentity 3 |
| 45 | 'u:s_ub u:c_ommutative 3 | {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{s}ub}}\ {{}^{\mathrm{u}}\mathrm{\underline{c}ommutative}}\ {3} | ’usub ucommutative 3 |
| 46 | 'u:s_ub u:a_ssociative 3 | {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{s}ub}}\ {{}^{\mathrm{u}}\mathrm{\underline{a}ssociative}}\ {3} | ’usub uassociative 3 |
| 51 | u:r_psls := { x y -> d := (x - y) m_od 5; y + (x - y) * d <= 2 } | {{}^{\mathrm{u}}\mathrm{\underline{r}psls}}\ {\leftarrow}\ {\{}\ {\mathrm{x}}\ {\mathrm{y}}\ {\to}\ {\mathrm{d}}\ {\leftarrow}\ {(}{\mathrm{x}}\ {-}\ {\mathrm{y}}{)}\ {\mathrm{\underline{m}od}}\ {5}{\diamond}\ {\mathrm{y}}\ {+}\ {(}{\mathrm{x}}\ {-}\ {\mathrm{y}}{)}\ {\times}\ {\mathrm{d}}\ {\leq}\ {2}\ {\}} | urpsls ← { x y → d ← (x − y) mod 5⋄ y + (x − y) × d ≤ 2 } |
| 52 | moves := "rock" "Spock" "paper" "lizard" "scissors" | {\mathrm{moves}}\ {\leftarrow}\ {\text{"rock"}}\ {\text{"Spock"}}\ {\text{"paper"}}\ {\text{"lizard"}}\ {\text{"scissors"}} | moves ← "rock" "Spock" "paper" "lizard" "scissors" |
| 53 | w := (r_ange 5) 'u:r_psls t_able r_ange 5 | {\mathrm{w}}\ {\leftarrow}\ {(}{\mathrm{\underline{r}ange}}\ {5}{)}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{r}psls}}\ {\mathrm{\underline{t}able}}\ {\mathrm{\underline{r}ange}}\ {5} | w ← (range 5) ’urpsls table range 5 |
| 54 | w s_elect moves | {\mathrm{w}}\ {\mathrm{\underline{s}elect}}\ {\mathrm{moves}} | w select moves |
| 55 | beats := 0 + (r_ange 5) '{ (_l != _r) & _l = _l u:r_psls _r } t_able r_ange 5 | {\mathrm{beats}}\ {\leftarrow}\ {0}\ {+}\ {(}{\mathrm{\underline{r}ange}}\ {5}{)}\ {\text{'}}{\{}\ {(}{\_\mathrm{l}}\ {\neq}\ {\_\mathrm{r}}{)}\ {\wedge}\ {\_\mathrm{l}}\ {=}\ {\_\mathrm{l}}\ {{}^{\mathrm{u}}\mathrm{\underline{r}psls}}\ {\_\mathrm{r}}\ {\}}\ {\mathrm{\underline{t}able}}\ {\mathrm{\underline{r}ange}}\ {5} | beats ← 0 + (range 5) ’{ (_l = _r) ∧ _l = _l urpsls _r } table range 5 |
| 56 | beats # row x: the moves x beats | {\mathrm{beats}} | beats |
| 57 | '+ r_/_2 beats # each beats two | {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{2}}\ {\mathrm{beats}} | ’+ r/2 beats |
| 58 | '+ r_/ beats # and loses to two | {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{beats}} | ’+ r/ beats |
| 59 | 'u:r_psls u:c_ommutative 5 | {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{r}psls}}\ {{}^{\mathrm{u}}\mathrm{\underline{c}ommutative}}\ {5} | ’urpsls ucommutative 5 |
| 60 | 'u:r_psls u:i_dempotent 5 | {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{r}psls}}\ {{}^{\mathrm{u}}\mathrm{\underline{i}dempotent}}\ {5} | ’urpsls uidempotent 5 |
| 61 | 'u:r_psls u:a_ssociative 5 | {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{r}psls}}\ {{}^{\mathrm{u}}\mathrm{\underline{a}ssociative}}\ {5} | ’urpsls uassociative 5 |
| 62 | shown := []S_HOW []G_RID w # the winner table, colored by move | {\mathrm{shown}}\ {\leftarrow}\ {\square \mathrm{\underline{S}HOW}}\ {\square \mathrm{\underline{G}RID}}\ {\mathrm{w}} | shown ← □SHOW □GRID w |
| 34 | l:dwell := 5.0 | {{}^{\mathrm{l}}\mathrm{dwell}}\ {\leftarrow}\ {5.0} | ldwell ← 5.0 |
| 35 | l:idleBefore := 20.0 | {{}^{\mathrm{l}}\mathrm{idleBefore}}\ {\leftarrow}\ {20.0} | lidleBefore ← 20.0 |
| 47 | l:s_tart := { i l -> 5 5 r_eshape (f_loat i) c_at 0.0 0.0 1.0 0.0 c_at (f_loat l) c_at 0.0 0.0 1.0 0.0 c_at (f_loat l) c_at 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 c_at l:idleBefore c_at 0.0 0.0 0.0 0.0 } | {{}^{\mathrm{l}}\mathrm{\underline{s}tart}}\ {\leftarrow}\ {\{}\ {\mathrm{i}}\ {\mathrm{l}}\ {\to}\ {5}\ {5}\ {\mathrm{\underline{r}eshape}}\ {(}{\mathrm{\underline{f}loat}}\ {\mathrm{i}}{)}\ {\mathrm{\underline{c}at}}\ {0.0}\ {0.0}\ {1.0}\ {0.0}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{f}loat}}\ {\mathrm{l}}{)}\ {\mathrm{\underline{c}at}}\ {0.0}\ {0.0}\ {1.0}\ {0.0}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{f}loat}}\ {\mathrm{l}}{)}\ {\mathrm{\underline{c}at}}\ {0.0}\ {0.0}\ {1.0}\ {0.0}\ {0.0}\ {0.0}\ {0.0}\ {0.0}\ {0.0}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{idleBefore}}\ {\mathrm{\underline{c}at}}\ {0.0}\ {0.0}\ {0.0}\ {0.0}\ {\}} | lstart ← { i l → 5 5 reshape (float i) cat 0.0 0.0 1.0 0.0 cat (float l) cat 0.0 0.0 1.0 0.0 cat (float l) cat 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 cat lidleBefore cat 0.0 0.0 0.0 0.0 } |
| 50 | l:IDIOM := 1.0 | {{}^{\mathrm{l}}\mathrm{IDIOM}}\ {\leftarrow}\ {1.0} | lIDIOM ← 1.0 |
| 51 | l:TOP := 2.0 | {{}^{\mathrm{l}}\mathrm{TOP}}\ {\leftarrow}\ {2.0} | lTOP ← 2.0 |
| 52 | l:BOTTOM := 3.0 | {{}^{\mathrm{l}}\mathrm{BOTTOM}}\ {\leftarrow}\ {3.0} | lBOTTOM ← 3.0 |
| 53 | l:POINTER := 4.0 | {{}^{\mathrm{l}}\mathrm{POINTER}}\ {\leftarrow}\ {4.0} | lPOINTER ← 4.0 |
| 54 | l:ATTRACT := 5.0 | {{}^{\mathrm{l}}\mathrm{ATTRACT}}\ {\leftarrow}\ {5.0} | lATTRACT ← 5.0 |
| 55 | l:IDLE := 1.0 | {{}^{\mathrm{l}}\mathrm{IDLE}}\ {\leftarrow}\ {1.0} | lIDLE ← 1.0 |
| 56 | l:SINCE := 2.0 | {{}^{\mathrm{l}}\mathrm{SINCE}}\ {\leftarrow}\ {2.0} | lSINCE ← 2.0 |
| 57 | l:BOTTOMS := 3.0 | {{}^{\mathrm{l}}\mathrm{BOTTOMS}}\ {\leftarrow}\ {3.0} | lBOTTOMS ← 3.0 |
| 58 | l:IDIOMS := 4.0 | {{}^{\mathrm{l}}\mathrm{IDIOMS}}\ {\leftarrow}\ {4.0} | lIDIOMS ← 4.0 |
| 59 | l:COUNT := 1.0 | {{}^{\mathrm{l}}\mathrm{COUNT}}\ {\leftarrow}\ {1.0} | lCOUNT ← 1.0 |
| 60 | l:STEPS := 2.0 | {{}^{\mathrm{l}}\mathrm{STEPS}}\ {\leftarrow}\ {2.0} | lSTEPS ← 2.0 |
| 61 | l:ANGLE := 3.0 | {{}^{\mathrm{l}}\mathrm{ANGLE}}\ {\leftarrow}\ {3.0} | lANGLE ← 3.0 |
| 62 | l:PLAYING := 4.0 | {{}^{\mathrm{l}}\mathrm{PLAYING}}\ {\leftarrow}\ {4.0} | lPLAYING ← 4.0 |
| 63 | l:DRAGGING := 1.0 | {{}^{\mathrm{l}}\mathrm{DRAGGING}}\ {\leftarrow}\ {1.0} | lDRAGGING ← 1.0 |
| 64 | l:X := 2.0 | {{}^{\mathrm{l}}\mathrm{X}}\ {\leftarrow}\ {2.0} | lX ← 2.0 |
| 65 | l:Y := 3.0 | {{}^{\mathrm{l}}\mathrm{Y}}\ {\leftarrow}\ {3.0} | lY ← 3.0 |
| 66 | l:MOVED := 4.0 | {{}^{\mathrm{l}}\mathrm{MOVED}}\ {\leftarrow}\ {4.0} | lMOVED ← 4.0 |
| 67 | l:LAST := 5.0 | {{}^{\mathrm{l}}\mathrm{LAST}}\ {\leftarrow}\ {5.0} | lLAST ← 5.0 |
| 72 | l:middle := 210.0 | {{}^{\mathrm{l}}\mathrm{middle}}\ {\leftarrow}\ {210.0} | lmiddle ← 210.0 |
| 73 | l:perPixel := 90.0 / 210.0 | {{}^{\mathrm{l}}\mathrm{perPixel}}\ {\leftarrow}\ {90.0}\ {\div}\ {210.0} | lperPixel ← 90.0 ÷ 210.0 |
| 76 | l:a_t := { rc state -> (f_loor 2 s_elect rc) s_elect (f_loor 1 s_elect rc) s_elect state } | {{}^{\mathrm{l}}\mathrm{\underline{a}t}}\ {\leftarrow}\ {\{}\ {\mathrm{rc}}\ {\mathrm{state}}\ {\to}\ {(}{\mathrm{\underline{f}loor}}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{rc}}{)}\ {\mathrm{\underline{s}elect}}\ {(}{\mathrm{\underline{f}loor}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{rc}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{state}}\ {\}} | lat ← { rc state → (floor 2 select rc) select (floor 1 select rc) select state } |
| 80 | l:p_ut := { rcv state -> | {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {\leftarrow}\ {\{}\ {\mathrm{rcv}}\ {\mathrm{state}}\ {\to} | lput ← { rcv state → |
| 81 | mask := f_loat (rows = 1 s_elect rcv) * cols = 2 s_elect rcv | \ \ {\mathrm{mask}}\ {\leftarrow}\ {\mathrm{\underline{f}loat}}\ {(}{\mathrm{rows}}\ {=}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{rcv}}{)}\ {\times}\ {\mathrm{cols}}\ {=}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{rcv}} | mask ← float (rows = 1 select rcv) × cols = 2 select rcv |
| 82 | (state * 1.0 - mask) + mask * 3 s_elect rcv | \ \ {(}{\mathrm{state}}\ {\times}\ {1.0}\ {-}\ {\mathrm{mask}}{)}\ {+}\ {\mathrm{mask}}\ {\times}\ {3}\ {\mathrm{\underline{s}elect}}\ {\mathrm{rcv}} | (state × 1.0 − mask) + mask × 3 select rcv |
| 83 | } | {\}} | } |
| 84 | rows := 5 5 r_eshape 5 r_eplicate 1.0 2.0 3.0 4.0 5.0 | {\mathrm{rows}}\ {\leftarrow}\ {5}\ {5}\ {\mathrm{\underline{r}eshape}}\ {5}\ {\mathrm{\underline{r}eplicate}}\ {1.0}\ {2.0}\ {3.0}\ {4.0}\ {5.0} | rows ← 5 5 reshape 5 replicate 1.0 2.0 3.0 4.0 5.0 |
| 85 | cols := 5 5 r_eshape 1.0 2.0 3.0 4.0 5.0 | {\mathrm{cols}}\ {\leftarrow}\ {5}\ {5}\ {\mathrm{\underline{r}eshape}}\ {1.0}\ {2.0}\ {3.0}\ {4.0}\ {5.0} | cols ← 5 5 reshape 1.0 2.0 3.0 4.0 5.0 |
| 88 | 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 } |
| 94 | l:c_urrent := { axis state -> (f_loor 0.5 + (axis c_at l:COUNT) l:a_t state) l:w_rap f_loor 1.5 + (axis c_at l:STEPS) l:a_t state } | {{}^{\mathrm{l}}\mathrm{\underline{c}urrent}}\ {\leftarrow}\ {\{}\ {\mathrm{axis}}\ {\mathrm{state}}\ {\to}\ {(}{\mathrm{\underline{f}loor}}\ {0.5}\ {+}\ {(}{\mathrm{axis}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{COUNT}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{a}t}}\ {\mathrm{state}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{w}rap}}\ {\mathrm{\underline{f}loor}}\ {1.5}\ {+}\ {(}{\mathrm{axis}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{STEPS}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{a}t}}\ {\mathrm{state}}\ {\}} | lcurrent ← { axis state → (floor 0.5 + (axis cat lCOUNT) lat state) lwrap floor 1.5 + (axis cat lSTEPS) lat state } |
| 105 | l:s_tep := { ad state -> | {{}^{\mathrm{l}}\mathrm{\underline{s}tep}}\ {\leftarrow}\ {\{}\ {\mathrm{ad}}\ {\mathrm{state}}\ {\to} | lstep ← { ad state → |
| 106 | axis := 1 s_elect ad | \ \ {\mathrm{axis}}\ {\leftarrow}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{ad}} | axis ← 1 select ad |
| 107 | d := 2 s_elect ad | \ \ {\mathrm{d}}\ {\leftarrow}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{ad}} | d ← 2 select ad |
| 108 | moved := (axis c_at l:STEPS c_at d + (axis c_at l:STEPS) l:a_t state) l:p_ut state | \ \ {\mathrm{moved}}\ {\leftarrow}\ {(}{\mathrm{axis}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{STEPS}}\ {\mathrm{\underline{c}at}}\ {\mathrm{d}}\ {+}\ {(}{\mathrm{axis}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{STEPS}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{a}t}}\ {\mathrm{state}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {\mathrm{state}} | moved ← (axis cat lSTEPS cat d + (axis cat lSTEPS) lat state) lput state |
| 109 | axis = l:IDIOM ? moved | \ \ {\mathrm{axis}}\ {=}\ {{}^{\mathrm{l}}\mathrm{IDIOM}}\ {?}\ {\mathrm{moved}} | axis = lIDIOM ? moved |
| 110 | other := 5.0 - axis | \ \ {\mathrm{other}}\ {\leftarrow}\ {5.0}\ {-}\ {\mathrm{axis}} | other ← 5.0 − axis |
| 111 | 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 |
| 112 | "clash" i_f< "(axis c_at d) l:s_tep moved; moved" | \ \ {\text{"clash"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{"(axis c\_at d) l:s\_tep moved; moved"}} | "clash" if< "(axis c_at d) l:s_tep moved; moved" |
| 113 | } | {\}} | } |
| 124 | l:c_hoose := { ak state -> | {{}^{\mathrm{l}}\mathrm{\underline{c}hoose}}\ {\leftarrow}\ {\{}\ {\mathrm{ak}}\ {\mathrm{state}}\ {\to} | lchoose ← { ak state → |
| 125 | axis := 1 s_elect ak | \ \ {\mathrm{axis}}\ {\leftarrow}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{ak}} | axis ← 1 select ak |
| 126 | n := f_loor 0.5 + (axis c_at l:COUNT) l:a_t state | \ \ {\mathrm{n}}\ {\leftarrow}\ {\mathrm{\underline{f}loor}}\ {0.5}\ {+}\ {(}{\mathrm{axis}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{COUNT}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{a}t}}\ {\mathrm{state}} | n ← floor 0.5 + (axis cat lCOUNT) lat state |
| 127 | d := ((f_loor 2 s_elect ak) - axis l:c_urrent state) m_od n | \ \ {\mathrm{d}}\ {\leftarrow}\ {(}{(}{\mathrm{\underline{f}loor}}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{ak}}{)}\ {-}\ {\mathrm{axis}}\ {{}^{\mathrm{l}}\mathrm{\underline{c}urrent}}\ {\mathrm{state}}{)}\ {\mathrm{\underline{m}od}}\ {\mathrm{n}} | d ← ((floor 2 select ak) − axis lcurrent state) mod n |
| 128 | short := "(2 * d) > n" i_f< "d - n; d" | \ \ {\mathrm{short}}\ {\leftarrow}\ {\text{"(2 * d) > n"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{"d - n; d"}} | short ← "(2 * d) > n" if< "d - n; d" |
| 129 | chosen := (axis c_at l:PLAYING c_at 0.0) l:p_ut (axis c_at f_loat short) l:s_tep state | \ \ {\mathrm{chosen}}\ {\leftarrow}\ {(}{\mathrm{axis}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{PLAYING}}\ {\mathrm{\underline{c}at}}\ {0.0}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {(}{\mathrm{axis}}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{f}loat}}\ {\mathrm{short}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{s}tep}}\ {\mathrm{state}} | chosen ← (axis cat lPLAYING cat 0.0) lput (axis cat float short) lstep state |
| 130 | axis = l:IDIOM ? chosen | \ \ {\mathrm{axis}}\ {=}\ {{}^{\mathrm{l}}\mathrm{IDIOM}}\ {?}\ {\mathrm{chosen}} | axis = lIDIOM ? chosen |
| 131 | (f_loor 2 s_elect ak) = (5.0 - axis) l:c_urrent state ? state | \ \ {(}{\mathrm{\underline{f}loor}}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{ak}}{)}\ {=}\ {(}{5.0}\ {-}\ {\mathrm{axis}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{c}urrent}}\ {\mathrm{state}}\ {?}\ {\mathrm{state}} | (floor 2 select ak) = (5.0 − axis) lcurrent state ? state |
| 132 | chosen | \ \ {\mathrm{chosen}} | chosen |
| 133 | } | {\}} | } |
| 141 | l:e_ase := { adt state -> | {{}^{\mathrm{l}}\mathrm{\underline{e}ase}}\ {\leftarrow}\ {\{}\ {\mathrm{adt}}\ {\mathrm{state}}\ {\to} | lease ← { adt state → |
| 142 | axis := 1 s_elect adt | \ \ {\mathrm{axis}}\ {\leftarrow}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{adt}} | axis ← 1 select adt |
| 143 | angle := (axis c_at l:ANGLE) l:a_t state | \ \ {\mathrm{angle}}\ {\leftarrow}\ {(}{\mathrm{axis}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{ANGLE}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{a}t}}\ {\mathrm{state}} | angle ← (axis cat lANGLE) lat state |
| 144 | target := 90.0 * (axis c_at l:STEPS) l:a_t state | \ \ {\mathrm{target}}\ {\leftarrow}\ {90.0}\ {\times}\ {(}{\mathrm{axis}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{STEPS}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{a}t}}\ {\mathrm{state}} | target ← 90.0 × (axis cat lSTEPS) lat state |
| 145 | gap := target - angle | \ \ {\mathrm{gap}}\ {\leftarrow}\ {\mathrm{target}}\ {-}\ {\mathrm{angle}} | gap ← target − angle |
| 146 | moved := angle + gap * 1.0 m_in 2.0 * 2 s_elect adt | \ \ {\mathrm{moved}}\ {\leftarrow}\ {\mathrm{angle}}\ {+}\ {\mathrm{gap}}\ {\times}\ {1.0}\ {\mathrm{\underline{m}in}}\ {2.0}\ {\times}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{adt}} | moved ← angle + gap × 1.0 min 2.0 × 2 select adt |
| 147 | near := "0.5 > a_bs target - moved" i_f< "target; moved" | \ \ {\mathrm{near}}\ {\leftarrow}\ {\text{"0.5 > a\_bs target - moved"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{"target; moved"}} | near ← "0.5 > a_bs target - moved" if< "target; moved" |
| 148 | (axis c_at l:ANGLE c_at near) l:p_ut state | \ \ {(}{\mathrm{axis}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{ANGLE}}\ {\mathrm{\underline{c}at}}\ {\mathrm{near}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {\mathrm{state}} | (axis cat lANGLE cat near) lput state |
| 149 | } | {\}} | } |
| 160 | l:s_ettle := { state -> (l:BOTTOM c_at 9.0) l:e_ase (l:TOP c_at 9.0) l:e_ase (l:IDIOM c_at 9.0) l:e_ase state } | {{}^{\mathrm{l}}\mathrm{\underline{s}ettle}}\ {\leftarrow}\ {\{}\ {\mathrm{state}}\ {\to}\ {(}{{}^{\mathrm{l}}\mathrm{BOTTOM}}\ {\mathrm{\underline{c}at}}\ {9.0}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{e}ase}}\ {(}{{}^{\mathrm{l}}\mathrm{TOP}}\ {\mathrm{\underline{c}at}}\ {9.0}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{e}ase}}\ {(}{{}^{\mathrm{l}}\mathrm{IDIOM}}\ {\mathrm{\underline{c}at}}\ {9.0}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{e}ase}}\ {\mathrm{state}}\ {\}} | lsettle ← { state → (lBOTTOM cat 9.0) lease (lTOP cat 9.0) lease (lIDIOM cat 9.0) lease state } |
| 171 | l:t_ick := { dt state -> | {{}^{\mathrm{l}}\mathrm{\underline{t}ick}}\ {\leftarrow}\ {\{}\ {\mathrm{dt}}\ {\mathrm{state}}\ {\to} | ltick ← { dt state → |
| 172 | eased := (l:BOTTOM c_at dt) l:e_ase (l:TOP c_at dt) l:e_ase (l:IDIOM c_at dt) l:e_ase state | \ \ {\mathrm{eased}}\ {\leftarrow}\ {(}{{}^{\mathrm{l}}\mathrm{BOTTOM}}\ {\mathrm{\underline{c}at}}\ {\mathrm{dt}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{e}ase}}\ {(}{{}^{\mathrm{l}}\mathrm{TOP}}\ {\mathrm{\underline{c}at}}\ {\mathrm{dt}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{e}ase}}\ {(}{{}^{\mathrm{l}}\mathrm{IDIOM}}\ {\mathrm{\underline{c}at}}\ {\mathrm{dt}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{e}ase}}\ {\mathrm{state}} | eased ← (lBOTTOM cat dt) lease (lTOP cat dt) lease (lIDIOM cat dt) lease state |
| 173 | idle := dt + (l:ATTRACT c_at l:IDLE) l:a_t state | \ \ {\mathrm{idle}}\ {\leftarrow}\ {\mathrm{dt}}\ {+}\ {(}{{}^{\mathrm{l}}\mathrm{ATTRACT}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{IDLE}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{a}t}}\ {\mathrm{state}} | idle ← dt + (lATTRACT cat lIDLE) lat state |
| 174 | since := dt + (l:ATTRACT c_at l:SINCE) l:a_t state | \ \ {\mathrm{since}}\ {\leftarrow}\ {\mathrm{dt}}\ {+}\ {(}{{}^{\mathrm{l}}\mathrm{ATTRACT}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{SINCE}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{a}t}}\ {\mathrm{state}} | since ← dt + (lATTRACT cat lSINCE) lat state |
| 175 | timed := (l:ATTRACT c_at l:SINCE c_at since) l:p_ut (l:ATTRACT c_at l:IDLE c_at idle) l:p_ut eased | \ \ {\mathrm{timed}}\ {\leftarrow}\ {(}{{}^{\mathrm{l}}\mathrm{ATTRACT}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{SINCE}}\ {\mathrm{\underline{c}at}}\ {\mathrm{since}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {(}{{}^{\mathrm{l}}\mathrm{ATTRACT}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{IDLE}}\ {\mathrm{\underline{c}at}}\ {\mathrm{idle}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {\mathrm{eased}} | timed ← (lATTRACT cat lSINCE cat since) lput (lATTRACT cat lIDLE cat idle) lput eased |
| 176 | (idle < l:idleBefore) | since < l:dwell ? timed | \ \ {(}{\mathrm{idle}}\ {<}\ {{}^{\mathrm{l}}\mathrm{idleBefore}}{)}\ {\vee}\ {\mathrm{since}}\ {<}\ {{}^{\mathrm{l}}\mathrm{dwell}}\ {?}\ {\mathrm{timed}} | (idle < lidleBefore) ∨ since < ldwell ? timed |
| 177 | l:a_ttract (l:ATTRACT c_at l:SINCE c_at 0.0) l:p_ut timed | \ \ {{}^{\mathrm{l}}\mathrm{\underline{a}ttract}}\ {(}{{}^{\mathrm{l}}\mathrm{ATTRACT}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{SINCE}}\ {\mathrm{\underline{c}at}}\ {0.0}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {\mathrm{timed}} | lattract (lATTRACT cat lSINCE cat 0.0) lput timed |
| 178 | } | {\}} | } |
| 196 | l:a_ttract := { state -> | {{}^{\mathrm{l}}\mathrm{\underline{a}ttract}}\ {\leftarrow}\ {\{}\ {\mathrm{state}}\ {\to} | lattract ← { state → |
| 197 | n := (f_loor 0.5 + (l:TOP c_at l:COUNT) l:a_t state) - 1 | \ \ {\mathrm{n}}\ {\leftarrow}\ {(}{\mathrm{\underline{f}loor}}\ {0.5}\ {+}\ {(}{{}^{\mathrm{l}}\mathrm{TOP}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{COUNT}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{a}t}}\ {\mathrm{state}}{)}\ {-}\ {1} | n ← (floor 0.5 + (lTOP cat lCOUNT) lat state) − 1 |
| 198 | m := f_loor 0.5 + (l:IDIOM c_at l:COUNT) l:a_t state | \ \ {\mathrm{m}}\ {\leftarrow}\ {\mathrm{\underline{f}loor}}\ {0.5}\ {+}\ {(}{{}^{\mathrm{l}}\mathrm{IDIOM}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{COUNT}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{a}t}}\ {\mathrm{state}} | m ← floor 0.5 + (lIDIOM cat lCOUNT) lat state |
| 199 | bottoms := 1.0 + (l:ATTRACT c_at l:BOTTOMS) l:a_t state | \ \ {\mathrm{bottoms}}\ {\leftarrow}\ {1.0}\ {+}\ {(}{{}^{\mathrm{l}}\mathrm{ATTRACT}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{BOTTOMS}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{a}t}}\ {\mathrm{state}} | bottoms ← 1.0 + (lATTRACT cat lBOTTOMS) lat state |
| 200 | idioms := 1.0 + (l:ATTRACT c_at l:IDIOMS) l:a_t state | \ \ {\mathrm{idioms}}\ {\leftarrow}\ {1.0}\ {+}\ {(}{{}^{\mathrm{l}}\mathrm{ATTRACT}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{IDIOMS}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{a}t}}\ {\mathrm{state}} | idioms ← 1.0 + (lATTRACT cat lIDIOMS) lat state |
| 201 | moved := l:BOTTOM l:p_lay state | \ \ {\mathrm{moved}}\ {\leftarrow}\ {{}^{\mathrm{l}}\mathrm{BOTTOM}}\ {{}^{\mathrm{l}}\mathrm{\underline{p}lay}}\ {\mathrm{state}} | moved ← lBOTTOM lplay state |
| 202 | bottoms < f_loat n ? (l:ATTRACT c_at l:BOTTOMS c_at bottoms) l:p_ut moved | \ \ {\mathrm{bottoms}}\ {<}\ {\mathrm{\underline{f}loat}}\ {\mathrm{n}}\ {?}\ {(}{{}^{\mathrm{l}}\mathrm{ATTRACT}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{BOTTOMS}}\ {\mathrm{\underline{c}at}}\ {\mathrm{bottoms}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {\mathrm{moved}} | bottoms < float n ? (lATTRACT cat lBOTTOMS cat bottoms) lput moved |
| 203 | rolled := l:IDIOM l:p_lay (l:ATTRACT c_at l:BOTTOMS c_at 0.0) l:p_ut moved | \ \ {\mathrm{rolled}}\ {\leftarrow}\ {{}^{\mathrm{l}}\mathrm{IDIOM}}\ {{}^{\mathrm{l}}\mathrm{\underline{p}lay}}\ {(}{{}^{\mathrm{l}}\mathrm{ATTRACT}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{BOTTOMS}}\ {\mathrm{\underline{c}at}}\ {0.0}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {\mathrm{moved}} | rolled ← lIDIOM lplay (lATTRACT cat lBOTTOMS cat 0.0) lput moved |
| 204 | idioms < f_loat m ? (l:ATTRACT c_at l:IDIOMS c_at idioms) l:p_ut rolled | \ \ {\mathrm{idioms}}\ {<}\ {\mathrm{\underline{f}loat}}\ {\mathrm{m}}\ {?}\ {(}{{}^{\mathrm{l}}\mathrm{ATTRACT}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{IDIOMS}}\ {\mathrm{\underline{c}at}}\ {\mathrm{idioms}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {\mathrm{rolled}} | idioms < float m ? (lATTRACT cat lIDIOMS cat idioms) lput rolled |
| 205 | l:TOP l:p_lay (l:ATTRACT c_at l:IDIOMS c_at 0.0) l:p_ut rolled | \ \ {{}^{\mathrm{l}}\mathrm{TOP}}\ {{}^{\mathrm{l}}\mathrm{\underline{p}lay}}\ {(}{{}^{\mathrm{l}}\mathrm{ATTRACT}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{IDIOMS}}\ {\mathrm{\underline{c}at}}\ {0.0}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {\mathrm{rolled}} | lTOP lplay (lATTRACT cat lIDIOMS cat 0.0) lput rolled |
| 206 | } | {\}} | } |
| 209 | l:p_lay := { axis state -> "1.0 = (axis c_at l:PLAYING) l:a_t state" i_f< "(axis c_at 1.0) l:s_tep state; state" } | {{}^{\mathrm{l}}\mathrm{\underline{p}lay}}\ {\leftarrow}\ {\{}\ {\mathrm{axis}}\ {\mathrm{state}}\ {\to}\ {\text{"1.0 = (axis c\_at l:PLAYING) l:a\_t state"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{"(axis c\_at 1.0) l:s\_tep state; state"}}\ {\}} | lplay ← { axis state → "1.0 = (axis c_at l:PLAYING) l:a_t state" if< "(axis c_at 1.0) l:s_tep state; state" } |
| 212 | l:t_ouched := { state -> (l:ATTRACT c_at l:SINCE c_at 0.0) l:p_ut (l:ATTRACT c_at l:IDLE c_at 0.0) l:p_ut state } | {{}^{\mathrm{l}}\mathrm{\underline{t}ouched}}\ {\leftarrow}\ {\{}\ {\mathrm{state}}\ {\to}\ {(}{{}^{\mathrm{l}}\mathrm{ATTRACT}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{SINCE}}\ {\mathrm{\underline{c}at}}\ {0.0}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {(}{{}^{\mathrm{l}}\mathrm{ATTRACT}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{IDLE}}\ {\mathrm{\underline{c}at}}\ {0.0}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {\mathrm{state}}\ {\}} | ltouched ← { state → (lATTRACT cat lSINCE cat 0.0) lput (lATTRACT cat lIDLE cat 0.0) lput state } |
| 215 | l:r_esume := { state -> (l:BOTTOM c_at l:PLAYING c_at 1.0) l:p_ut (l:TOP c_at l:PLAYING c_at 1.0) l:p_ut (l:IDIOM c_at l:PLAYING c_at 1.0) l:p_ut state } | {{}^{\mathrm{l}}\mathrm{\underline{r}esume}}\ {\leftarrow}\ {\{}\ {\mathrm{state}}\ {\to}\ {(}{{}^{\mathrm{l}}\mathrm{BOTTOM}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{PLAYING}}\ {\mathrm{\underline{c}at}}\ {1.0}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {(}{{}^{\mathrm{l}}\mathrm{TOP}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{PLAYING}}\ {\mathrm{\underline{c}at}}\ {1.0}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {(}{{}^{\mathrm{l}}\mathrm{IDIOM}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{PLAYING}}\ {\mathrm{\underline{c}at}}\ {1.0}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {\mathrm{state}}\ {\}} | lresume ← { state → (lBOTTOM cat lPLAYING cat 1.0) lput (lTOP cat lPLAYING cat 1.0) lput (lIDIOM cat lPLAYING cat 1.0) lput state } |
| 226 | l:t_oggleTour := { state -> | {{}^{\mathrm{l}}\mathrm{\underline{t}oggleTour}}\ {\leftarrow}\ {\{}\ {\mathrm{state}}\ {\to} | ltoggleTour ← { state → |
| 227 | playing := ((l:IDIOM c_at l:PLAYING) l:a_t state) + ((l:TOP c_at l:PLAYING) l:a_t state) + (l:BOTTOM c_at l:PLAYING) l:a_t state | \ \ {\mathrm{playing}}\ {\leftarrow}\ {(}{(}{{}^{\mathrm{l}}\mathrm{IDIOM}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{PLAYING}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{a}t}}\ {\mathrm{state}}{)}\ {+}\ {(}{(}{{}^{\mathrm{l}}\mathrm{TOP}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{PLAYING}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{a}t}}\ {\mathrm{state}}{)}\ {+}\ {(}{{}^{\mathrm{l}}\mathrm{BOTTOM}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{PLAYING}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{a}t}}\ {\mathrm{state}} | playing ← ((lIDIOM cat lPLAYING) lat state) + ((lTOP cat lPLAYING) lat state) + (lBOTTOM cat lPLAYING) lat state |
| 228 | 0.0 < playing ? (l:BOTTOM c_at l:PLAYING c_at 0.0) l:p_ut (l:TOP c_at l:PLAYING c_at 0.0) l:p_ut (l:IDIOM c_at l:PLAYING c_at 0.0) l:p_ut state | \ \ {0.0}\ {<}\ {\mathrm{playing}}\ {?}\ {(}{{}^{\mathrm{l}}\mathrm{BOTTOM}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{PLAYING}}\ {\mathrm{\underline{c}at}}\ {0.0}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {(}{{}^{\mathrm{l}}\mathrm{TOP}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{PLAYING}}\ {\mathrm{\underline{c}at}}\ {0.0}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {(}{{}^{\mathrm{l}}\mathrm{IDIOM}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{PLAYING}}\ {\mathrm{\underline{c}at}}\ {0.0}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {\mathrm{state}} | 0.0 < playing ? (lBOTTOM cat lPLAYING cat 0.0) lput (lTOP cat lPLAYING cat 0.0) lput (lIDIOM cat lPLAYING cat 0.0) lput state |
| 229 | l:r_esume state | \ \ {{}^{\mathrm{l}}\mathrm{\underline{r}esume}}\ {\mathrm{state}} | lresume state |
| 230 | } | {\}} | } |
| 244 | l:m_ode := { state -> | {{}^{\mathrm{l}}\mathrm{\underline{m}ode}}\ {\leftarrow}\ {\{}\ {\mathrm{state}}\ {\to} | lmode ← { state → |
| 245 | p_aused := { axis -> 0.0 = (axis c_at l:PLAYING) l:a_t state } | \ \ {\mathrm{\underline{p}aused}}\ {\leftarrow}\ {\{}\ {\mathrm{axis}}\ {\to}\ {0.0}\ {=}\ {(}{\mathrm{axis}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{PLAYING}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{a}t}}\ {\mathrm{state}}\ {\}} | paused ← { axis → 0.0 = (axis cat lPLAYING) lat state } |
| 246 | paused := (p_aused l:IDIOM) c_at (p_aused l:TOP) c_at p_aused l:BOTTOM | \ \ {\mathrm{paused}}\ {\leftarrow}\ {(}{\mathrm{\underline{p}aused}}\ {{}^{\mathrm{l}}\mathrm{IDIOM}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{p}aused}}\ {{}^{\mathrm{l}}\mathrm{TOP}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{p}aused}}\ {{}^{\mathrm{l}}\mathrm{BOTTOM}} | paused ← (paused lIDIOM) cat (paused lTOP) cat paused lBOTTOM |
| 247 | 3 = '+ r_/ paused ? "paused" | \ \ {3}\ {=}\ {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{paused}}\ {?}\ {\text{"paused"}} | 3 = ’+ r/ paused ? "paused" |
| 248 | names := paused r_eplicate (e_nclose "roll") c_at (e_nclose "top") c_at e_nclose "bottom" | \ \ {\mathrm{names}}\ {\leftarrow}\ {\mathrm{paused}}\ {\mathrm{\underline{r}eplicate}}\ {(}{\mathrm{\underline{e}nclose}}\ {\text{"roll"}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{e}nclose}}\ {\text{"top"}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{e}nclose}}\ {\text{"bottom"}} | names ← paused replicate (enclose "roll") cat (enclose "top") cat enclose "bottom" |
| 249 | 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 |
| 250 | l:idleBefore > (l:ATTRACT c_at l:IDLE) l:a_t state ? "holding" | \ \ {{}^{\mathrm{l}}\mathrm{idleBefore}}\ {>}\ {(}{{}^{\mathrm{l}}\mathrm{ATTRACT}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{IDLE}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{a}t}}\ {\mathrm{state}}\ {?}\ {\text{"holding"}} | lidleBefore > (lATTRACT cat lIDLE) lat state ? "holding" |
| 251 | "touring" | \ \ {\text{"touring"}} | "touring" |
| 252 | } | {\}} | } |
| 255 | l:t_oggle := { axis state -> (axis c_at l:PLAYING c_at 1.0 - (axis c_at l:PLAYING) l:a_t state) l:p_ut state } | {{}^{\mathrm{l}}\mathrm{\underline{t}oggle}}\ {\leftarrow}\ {\{}\ {\mathrm{axis}}\ {\mathrm{state}}\ {\to}\ {(}{\mathrm{axis}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{PLAYING}}\ {\mathrm{\underline{c}at}}\ {1.0}\ {-}\ {(}{\mathrm{axis}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{PLAYING}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{a}t}}\ {\mathrm{state}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {\mathrm{state}}\ {\}} | ltoggle ← { axis state → (axis cat lPLAYING cat 1.0 − (axis cat lPLAYING) lat state) lput state } |
| 267 | l:u_pdate := { state e -> | {{}^{\mathrm{l}}\mathrm{\underline{u}pdate}}\ {\leftarrow}\ {\{}\ {\mathrm{state}}\ {\mathrm{e}}\ {\to} | lupdate ← { state e → |
| 268 | kind := []E_KIND e | \ \ {\mathrm{kind}}\ {\leftarrow}\ {\square \mathrm{\underline{E}KIND}}\ {\mathrm{e}} | kind ← □EKIND e |
| 269 | 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 |
| 270 | touched := l:t_ouched state | \ \ {\mathrm{touched}}\ {\leftarrow}\ {{}^{\mathrm{l}}\mathrm{\underline{t}ouched}}\ {\mathrm{state}} | touched ← ltouched state |
| 271 | 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 |
| 272 | kind m_atch "down" ? ([]E_AT e) l:d_own touched | \ \ {\mathrm{kind}}\ {\mathrm{\underline{m}atch}}\ {\text{"down"}}\ {?}\ {(}{\square \mathrm{\underline{E}AT}}\ {\mathrm{e}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{d}own}}\ {\mathrm{touched}} | kind match "down" ? (□EAT e) ldown touched |
| 273 | kind m_atch "move" ? ([]E_AT e) l:m_ove touched | \ \ {\mathrm{kind}}\ {\mathrm{\underline{m}atch}}\ {\text{"move"}}\ {?}\ {(}{\square \mathrm{\underline{E}AT}}\ {\mathrm{e}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{m}ove}}\ {\mathrm{touched}} | kind match "move" ? (□EAT e) lmove touched |
| 274 | kind m_atch "up" ? ([]E_AT e) l:u_p touched | \ \ {\mathrm{kind}}\ {\mathrm{\underline{m}atch}}\ {\text{"up"}}\ {?}\ {(}{\square \mathrm{\underline{E}AT}}\ {\mathrm{e}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{u}p}}\ {\mathrm{touched}} | kind match "up" ? (□EAT e) lup touched |
| 275 | kind m_atch "click" ? ([]E_AT e) l:c_lick touched | \ \ {\mathrm{kind}}\ {\mathrm{\underline{m}atch}}\ {\text{"click"}}\ {?}\ {(}{\square \mathrm{\underline{E}AT}}\ {\mathrm{e}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{c}lick}}\ {\mathrm{touched}} | kind match "click" ? (□EAT e) lclick touched |
| 276 | kind m_atch "choose" ? ([]E_AT e) l:c_hoose touched | \ \ {\mathrm{kind}}\ {\mathrm{\underline{m}atch}}\ {\text{"choose"}}\ {?}\ {(}{\square \mathrm{\underline{E}AT}}\ {\mathrm{e}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{c}hoose}}\ {\mathrm{touched}} | kind match "choose" ? (□EAT e) lchoose touched |
| 277 | state | \ \ {\mathrm{state}} | state |
| 278 | } | {\}} | } |
| 282 | l:h_alf := { xy -> "(2 s_elect xy) < l:middle" i_f< "l:TOP; l:BOTTOM" } | {{}^{\mathrm{l}}\mathrm{\underline{h}alf}}\ {\leftarrow}\ {\{}\ {\mathrm{xy}}\ {\to}\ {\text{"(2 s\_elect xy) < l:middle"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{"l:TOP; l:BOTTOM"}}\ {\}} | lhalf ← { xy → "(2 s_elect xy) < l:middle" if< "l:TOP; l:BOTTOM" } |
| 289 | l:d_own := { xy state -> (l:POINTER c_at l:LAST c_at 0.0) l:p_ut (l:POINTER c_at l:MOVED c_at 0.0) l:p_ut (l:POINTER c_at l:Y c_at 2 s_elect xy) l:p_ut (l:POINTER c_at l:X c_at 1 s_elect xy) l:p_ut (l:POINTER c_at l:DRAGGING c_at 0.5) l:p_ut state } | {{}^{\mathrm{l}}\mathrm{\underline{d}own}}\ {\leftarrow}\ {\{}\ {\mathrm{xy}}\ {\mathrm{state}}\ {\to}\ {(}{{}^{\mathrm{l}}\mathrm{POINTER}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{LAST}}\ {\mathrm{\underline{c}at}}\ {0.0}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {(}{{}^{\mathrm{l}}\mathrm{POINTER}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{MOVED}}\ {\mathrm{\underline{c}at}}\ {0.0}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {(}{{}^{\mathrm{l}}\mathrm{POINTER}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{Y}}\ {\mathrm{\underline{c}at}}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{xy}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {(}{{}^{\mathrm{l}}\mathrm{POINTER}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{X}}\ {\mathrm{\underline{c}at}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{xy}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {(}{{}^{\mathrm{l}}\mathrm{POINTER}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{DRAGGING}}\ {\mathrm{\underline{c}at}}\ {0.5}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {\mathrm{state}}\ {\}} | ldown ← { xy state → (lPOINTER cat lLAST cat 0.0) lput (lPOINTER cat lMOVED cat 0.0) lput (lPOINTER cat lY cat 2 select xy) lput (lPOINTER cat lX cat 1 select xy) lput (lPOINTER cat lDRAGGING cat 0.5) lput state } |
| 303 | l:m_ove := { xy state -> | {{}^{\mathrm{l}}\mathrm{\underline{m}ove}}\ {\leftarrow}\ {\{}\ {\mathrm{xy}}\ {\mathrm{state}}\ {\to} | lmove ← { xy state → |
| 304 | held := (l:POINTER c_at l:DRAGGING) l:a_t state | \ \ {\mathrm{held}}\ {\leftarrow}\ {(}{{}^{\mathrm{l}}\mathrm{POINTER}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{DRAGGING}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{a}t}}\ {\mathrm{state}} | held ← (lPOINTER cat lDRAGGING) lat state |
| 305 | held = 0.0 ? state | \ \ {\mathrm{held}}\ {=}\ {0.0}\ {?}\ {\mathrm{state}} | held = 0.0 ? state |
| 306 | dx := (1 s_elect xy) - (l:POINTER c_at l:X) l:a_t state | \ \ {\mathrm{dx}}\ {\leftarrow}\ {(}{1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{xy}}{)}\ {-}\ {(}{{}^{\mathrm{l}}\mathrm{POINTER}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{X}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{a}t}}\ {\mathrm{state}} | dx ← (1 select xy) − (lPOINTER cat lX) lat state |
| 307 | dy := (2 s_elect xy) - (l:POINTER c_at l:Y) l:a_t state | \ \ {\mathrm{dy}}\ {\leftarrow}\ {(}{2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{xy}}{)}\ {-}\ {(}{{}^{\mathrm{l}}\mathrm{POINTER}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{Y}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{a}t}}\ {\mathrm{state}} | dy ← (2 select xy) − (lPOINTER cat lY) lat state |
| 308 | moved := (a_bs dx) + (a_bs dy) + (l:POINTER c_at l:MOVED) l:a_t state | \ \ {\mathrm{moved}}\ {\leftarrow}\ {(}{\mathrm{\underline{a}bs}}\ {\mathrm{dx}}{)}\ {+}\ {(}{\mathrm{\underline{a}bs}}\ {\mathrm{dy}}{)}\ {+}\ {(}{{}^{\mathrm{l}}\mathrm{POINTER}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{MOVED}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{a}t}}\ {\mathrm{state}} | moved ← (abs dx) + (abs dy) + (lPOINTER cat lMOVED) lat state |
| 309 | placed := (l:POINTER c_at l:MOVED c_at moved) l:p_ut (l:POINTER c_at l:Y c_at 2 s_elect xy) l:p_ut (l:POINTER c_at l:X c_at 1 s_elect xy) l:p_ut state | \ \ {\mathrm{placed}}\ {\leftarrow}\ {(}{{}^{\mathrm{l}}\mathrm{POINTER}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{MOVED}}\ {\mathrm{\underline{c}at}}\ {\mathrm{moved}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {(}{{}^{\mathrm{l}}\mathrm{POINTER}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{Y}}\ {\mathrm{\underline{c}at}}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{xy}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {(}{{}^{\mathrm{l}}\mathrm{POINTER}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{X}}\ {\mathrm{\underline{c}at}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{xy}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {\mathrm{state}} | placed ← (lPOINTER cat lMOVED cat moved) lput (lPOINTER cat lY cat 2 select xy) lput (lPOINTER cat lX cat 1 select xy) lput state |
| 310 | (held = 0.5) & moved <= 4.0 ? placed | \ \ {(}{\mathrm{held}}\ {=}\ {0.5}{)}\ {\wedge}\ {\mathrm{moved}}\ {\leq}\ {4.0}\ {?}\ {\mathrm{placed}} | (held = 0.5) ∧ moved ≤ 4.0 ? placed |
| 311 | axis := "held = 0.5" i_f< "\"(a_bs dx) >= a_bs dy\" i_f< \"l:h_alf xy; l:IDIOM\"; held" | \ \ {\mathrm{axis}}\ {\leftarrow}\ {\text{"held = 0.5"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{"\textbackslash{}"(a\_bs dx) >= a\_bs dy\textbackslash{}" i\_f< \textbackslash{}"l:h\_alf xy; l:IDIOM\textbackslash{}"; held"}} | axis ← "held = 0.5" if< "\"(a_bs dx) >= a_bs dy\" i_f< \"l:h_alf xy; l:IDIOM\"; held" |
| 312 | along := "axis = l:IDIOM" i_f< "dy; dx" | \ \ {\mathrm{along}}\ {\leftarrow}\ {\text{"axis = l:IDIOM"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{"dy; dx"}} | along ← "axis = l:IDIOM" if< "dy; dx" |
| 313 | turn := n_eg along * l:perPixel | \ \ {\mathrm{turn}}\ {\leftarrow}\ {\mathrm{\underline{n}eg}}\ {\mathrm{along}}\ {\times}\ {{}^{\mathrm{l}}\mathrm{perPixel}} | turn ← neg along × lperPixel |
| 314 | angle := turn + (axis c_at l:ANGLE) l:a_t placed | \ \ {\mathrm{angle}}\ {\leftarrow}\ {\mathrm{turn}}\ {+}\ {(}{\mathrm{axis}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{ANGLE}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{a}t}}\ {\mathrm{placed}} | angle ← turn + (axis cat lANGLE) lat placed |
| 315 | (l:POINTER c_at l:LAST c_at turn) l:p_ut (l:POINTER c_at l:DRAGGING c_at axis) l:p_ut (axis c_at l:ANGLE c_at angle) l:p_ut placed | \ \ {(}{{}^{\mathrm{l}}\mathrm{POINTER}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{LAST}}\ {\mathrm{\underline{c}at}}\ {\mathrm{turn}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {(}{{}^{\mathrm{l}}\mathrm{POINTER}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{DRAGGING}}\ {\mathrm{\underline{c}at}}\ {\mathrm{axis}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {(}{\mathrm{axis}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{ANGLE}}\ {\mathrm{\underline{c}at}}\ {\mathrm{angle}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {\mathrm{placed}} | (lPOINTER cat lLAST cat turn) lput (lPOINTER cat lDRAGGING cat axis) lput (axis cat lANGLE cat angle) lput placed |
| 316 | } | {\}} | } |
| 327 | l:u_p := { xy state -> | {{}^{\mathrm{l}}\mathrm{\underline{u}p}}\ {\leftarrow}\ {\{}\ {\mathrm{xy}}\ {\mathrm{state}}\ {\to} | lup ← { xy state → |
| 328 | held := (l:POINTER c_at l:DRAGGING) l:a_t state | \ \ {\mathrm{held}}\ {\leftarrow}\ {(}{{}^{\mathrm{l}}\mathrm{POINTER}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{DRAGGING}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{a}t}}\ {\mathrm{state}} | held ← (lPOINTER cat lDRAGGING) lat state |
| 329 | held = 0.0 ? state | \ \ {\mathrm{held}}\ {=}\ {0.0}\ {?}\ {\mathrm{state}} | held = 0.0 ? state |
| 330 | released := (l:POINTER c_at l:DRAGGING c_at 0.0) l:p_ut state | \ \ {\mathrm{released}}\ {\leftarrow}\ {(}{{}^{\mathrm{l}}\mathrm{POINTER}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{DRAGGING}}\ {\mathrm{\underline{c}at}}\ {0.0}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {\mathrm{state}} | released ← (lPOINTER cat lDRAGGING cat 0.0) lput state |
| 331 | held = 0.5 ? xy l:c_lick released | \ \ {\mathrm{held}}\ {=}\ {0.5}\ {?}\ {\mathrm{xy}}\ {{}^{\mathrm{l}}\mathrm{\underline{c}lick}}\ {\mathrm{released}} | held = 0.5 ? xy lclick released |
| 332 | last := (l:POINTER c_at l:LAST) l:a_t state | \ \ {\mathrm{last}}\ {\leftarrow}\ {(}{{}^{\mathrm{l}}\mathrm{POINTER}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{LAST}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{a}t}}\ {\mathrm{state}} | last ← (lPOINTER cat lLAST) lat state |
| 333 | flick := "6.0 < a_bs last" i_f< "45.0 * last / a_bs last; 0.0" | \ \ {\mathrm{flick}}\ {\leftarrow}\ {\text{"6.0 < a\_bs last"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{"45.0 * last / a\_bs last; 0.0"}} | flick ← "6.0 < a_bs last" if< "45.0 * last / a_bs last; 0.0" |
| 334 | angle := (held c_at l:ANGLE) l:a_t state | \ \ {\mathrm{angle}}\ {\leftarrow}\ {(}{\mathrm{held}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{ANGLE}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{a}t}}\ {\mathrm{state}} | angle ← (held cat lANGLE) lat state |
| 335 | (held c_at l:STEPS c_at f_loat f_loor 0.5 + (angle + flick) / 90.0) l:p_ut released | \ \ {(}{\mathrm{held}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{STEPS}}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{f}loat}}\ {\mathrm{\underline{f}loor}}\ {0.5}\ {+}\ {(}{\mathrm{angle}}\ {+}\ {\mathrm{flick}}{)}\ {\div}\ {90.0}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {\mathrm{released}} | (held cat lSTEPS cat float floor 0.5 + (angle + flick) ÷ 90.0) lput released |
| 336 | } | {\}} | } |
| 342 | 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 } |
| 346 | l:k_ey := { k state -> | {{}^{\mathrm{l}}\mathrm{\underline{k}ey}}\ {\leftarrow}\ {\{}\ {\mathrm{k}}\ {\mathrm{state}}\ {\to} | lkey ← { k state → |
| 347 | k = []K_NAMED 1 ? (l:IDIOM c_at -1.0) l:s_tep state | \ \ {\mathrm{k}}\ {=}\ {\square \mathrm{\underline{K}NAMED}}\ {1}\ {?}\ {(}{{}^{\mathrm{l}}\mathrm{IDIOM}}\ {\mathrm{\underline{c}at}}\ {-1.0}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{s}tep}}\ {\mathrm{state}} | k = □KNAMED 1 ? (lIDIOM cat −1.0) lstep state |
| 348 | k = []K_NAMED 2 ? (l:IDIOM c_at 1.0) l:s_tep state | \ \ {\mathrm{k}}\ {=}\ {\square \mathrm{\underline{K}NAMED}}\ {2}\ {?}\ {(}{{}^{\mathrm{l}}\mathrm{IDIOM}}\ {\mathrm{\underline{c}at}}\ {1.0}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{s}tep}}\ {\mathrm{state}} | k = □KNAMED 2 ? (lIDIOM cat 1.0) lstep state |
| 349 | k = []K_NAMED 3 ? (l:TOP c_at -1.0) l:s_tep state | \ \ {\mathrm{k}}\ {=}\ {\square \mathrm{\underline{K}NAMED}}\ {3}\ {?}\ {(}{{}^{\mathrm{l}}\mathrm{TOP}}\ {\mathrm{\underline{c}at}}\ {-1.0}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{s}tep}}\ {\mathrm{state}} | k = □KNAMED 3 ? (lTOP cat −1.0) lstep state |
| 350 | k = []K_NAMED 4 ? (l:TOP c_at 1.0) l:s_tep state | \ \ {\mathrm{k}}\ {=}\ {\square \mathrm{\underline{K}NAMED}}\ {4}\ {?}\ {(}{{}^{\mathrm{l}}\mathrm{TOP}}\ {\mathrm{\underline{c}at}}\ {1.0}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{s}tep}}\ {\mathrm{state}} | k = □KNAMED 4 ? (lTOP cat 1.0) lstep state |
| 351 | c := []K_CHAR k | \ \ {\mathrm{c}}\ {\leftarrow}\ {\square \mathrm{\underline{K}CHAR}}\ {\mathrm{k}} | c ← □KCHAR k |
| 352 | c m_atch "a" ? (l:BOTTOM c_at -1.0) l:s_tep state | \ \ {\mathrm{c}}\ {\mathrm{\underline{m}atch}}\ {\text{"a"}}\ {?}\ {(}{{}^{\mathrm{l}}\mathrm{BOTTOM}}\ {\mathrm{\underline{c}at}}\ {-1.0}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{s}tep}}\ {\mathrm{state}} | c match "a" ? (lBOTTOM cat −1.0) lstep state |
| 353 | c m_atch "d" ? (l:BOTTOM c_at 1.0) l:s_tep state | \ \ {\mathrm{c}}\ {\mathrm{\underline{m}atch}}\ {\text{"d"}}\ {?}\ {(}{{}^{\mathrm{l}}\mathrm{BOTTOM}}\ {\mathrm{\underline{c}at}}\ {1.0}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{s}tep}}\ {\mathrm{state}} | c match "d" ? (lBOTTOM cat 1.0) lstep state |
| 354 | 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 |
| 355 | c m_atch "r" ? (l:ATTRACT c_at l:IDLE c_at l:idleBefore) l:p_ut l:r_esume state | \ \ {\mathrm{c}}\ {\mathrm{\underline{m}atch}}\ {\text{"r"}}\ {?}\ {(}{{}^{\mathrm{l}}\mathrm{ATTRACT}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{IDLE}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{l}}\mathrm{idleBefore}}{)}\ {{}^{\mathrm{l}}\mathrm{\underline{p}ut}}\ {{}^{\mathrm{l}}\mathrm{\underline{r}esume}}\ {\mathrm{state}} | c match "r" ? (lATTRACT cat lIDLE cat lidleBefore) lput lresume state |
| 356 | 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 |
| 357 | 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 |
| 358 | state | \ \ {\mathrm{state}} | state |
| 359 | } | {\}} | } |
| 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 := j_oin '{ k -> k l:l_ine d_isclose k s_elect lines } m_ap r_ange t_ally lines | \ \ {\mathrm{texts}}\ {\leftarrow}\ {\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 ← join ’{ 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 := "k = 1" i_f< "\"0.06\"; \"0.1\"" | \ \ {\mathrm{size}}\ {\leftarrow}\ {\text{"k = 1"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{"\textbackslash{}"0.06\textbackslash{}"; \textbackslash{}"0.1\textbackslash{}""}} | size ← "k = 1" if< "\"0.06\"; \"0.1\"" |
| 147 | y := "k = 1" i_f< "0.13; 0.14 + 0.16 * f_loat k" | \ \ {\mathrm{y}}\ {\leftarrow}\ {\text{"k = 1"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{"0.13; 0.14 + 0.16 * f\_loat k"}} | y ← "k = 1" if< "0.13; 0.14 + 0.16 * f_loat k" |
| 148 | color := "k = 1" i_f< "\"#4b5563\"; \"#000000\"" | \ \ {\mathrm{color}}\ {\leftarrow}\ {\text{"k = 1"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{"\textbackslash{}"\#4b5563\textbackslash{}"; \textbackslash{}"\#000000\textbackslash{}""}} | color ← "k = 1" if< "\"#4b5563\"; \"#000000\"" |
| 149 | weight := "k = 1" i_f< "\"500\"; \"700\"" | \ \ {\mathrm{weight}}\ {\leftarrow}\ {\text{"k = 1"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{"\textbackslash{}"500\textbackslash{}"; \textbackslash{}"700\textbackslash{}""}} | weight ← "k = 1" if< "\"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 | j_oin := { b -> | {\mathrm{\underline{j}oin}}\ {\leftarrow}\ {\{}\ {\mathrm{b}}\ {\to} | join ← { 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 | } | {\}} | } |
| 10 | "g:" u_se< "Geometry3D" | {\text{"g:"}}\ {\mathrm{\underline{u}se}{<}}\ {\text{"Geometry3D"}} | "g:" use< "Geometry3D" |
| 11 | "v:" u_se< "Svg" | {\text{"v:"}}\ {\mathrm{\underline{u}se}{<}}\ {\text{"Svg"}} | "v:" use< "Svg" |
| 13 | size := 300.0 # the picture is size by size | {\mathrm{size}}\ {\leftarrow}\ {300.0} | size ← 300.0 |
| 14 | eye := 6.0 # the viewer's distance along z | {\mathrm{eye}}\ {\leftarrow}\ {6.0} | eye ← 6.0 |
| 15 | zoom := 70.0 # pixels per unit | {\mathrm{zoom}}\ {\leftarrow}\ {70.0} | zoom ← 70.0 |
| 16 | light := 0.3 0.5 0.8 # from the viewer's side, upper right | {\mathrm{light}}\ {\leftarrow}\ {0.3}\ {0.5}\ {0.8} | light ← 0.3 0.5 0.8 |
| 18 | cube := g:c_ube 2 | {\mathrm{cube}}\ {\leftarrow}\ {{}^{\mathrm{g}}\mathrm{\underline{c}ube}}\ {2} | cube ← gcube 2 |
| 19 | faces := g:c_ubeFaces @ | {\mathrm{faces}}\ {\leftarrow}\ {{}^{\mathrm{g}}\mathrm{\underline{c}ubeFaces}}\ {@} | faces ← gcubeFaces @ |
| 22 | u:s_creen := { f -> | {{}^{\mathrm{u}}\mathrm{\underline{s}creen}}\ {\leftarrow}\ {\{}\ {\mathrm{f}}\ {\to} | uscreen ← { f → |
| 23 | p := eye g:p_roject f | \ \ {\mathrm{p}}\ {\leftarrow}\ {\mathrm{eye}}\ {{}^{\mathrm{g}}\mathrm{\underline{p}roject}}\ {\mathrm{f}} | p ← eye gproject f |
| 24 | xs := (size / 2) + zoom * 1 s_elect p | \ \ {\mathrm{xs}}\ {\leftarrow}\ {(}{\mathrm{size}}\ {\div}\ {2}{)}\ {+}\ {\mathrm{zoom}}\ {\times}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{p}} | xs ← (size ÷ 2) + zoom × 1 select p |
| 25 | ys := (size / 2) - zoom * 2 s_elect p | \ \ {\mathrm{ys}}\ {\leftarrow}\ {(}{\mathrm{size}}\ {\div}\ {2}{)}\ {-}\ {\mathrm{zoom}}\ {\times}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{p}} | ys ← (size ÷ 2) − zoom × 2 select p |
| 26 | (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 |
| 27 | } | {\}} | } |
| 30 | u:n_ormal := { f -> | {{}^{\mathrm{u}}\mathrm{\underline{n}ormal}}\ {\leftarrow}\ {\{}\ {\mathrm{f}}\ {\to} | unormal ← { f → |
| 31 | u := (2 s_elect_2 f) - 1 s_elect_2 f | \ \ {\mathrm{u}}\ {\leftarrow}\ {(}{2}\ {{\mathrm{\underline{s}elect}}_{2}}\ {\mathrm{f}}{)}\ {-}\ {1}\ {{\mathrm{\underline{s}elect}}_{2}}\ {\mathrm{f}} | u ← (2 select2 f) − 1 select2 f |
| 32 | w := (4 s_elect_2 f) - 1 s_elect_2 f | \ \ {\mathrm{w}}\ {\leftarrow}\ {(}{4}\ {{\mathrm{\underline{s}elect}}_{2}}\ {\mathrm{f}}{)}\ {-}\ {1}\ {{\mathrm{\underline{s}elect}}_{2}}\ {\mathrm{f}} | w ← (4 select2 f) − 1 select2 f |
| 33 | ((1 o_- u) * 2 o_- w) - (2 o_- u) * 1 o_- w | \ \ {(}{(}{1}\ {\mathrm{\underline{o}}{-}}\ {\mathrm{u}}{)}\ {\times}\ {2}\ {\mathrm{\underline{o}}{-}}\ {\mathrm{w}}{)}\ {-}\ {(}{2}\ {\mathrm{\underline{o}}{-}}\ {\mathrm{u}}{)}\ {\times}\ {1}\ {\mathrm{\underline{o}}{-}}\ {\mathrm{w}} | ((1 o− u) × 2 o− w) − (2 o− u) × 1 o− w |
| 34 | } | {\}} | } |
| 39 | u:l_it := { f -> | {{}^{\mathrm{u}}\mathrm{\underline{l}it}}\ {\leftarrow}\ {\{}\ {\mathrm{f}}\ {\to} | ulit ← { f → |
| 40 | n := u:n_ormal f | \ \ {\mathrm{n}}\ {\leftarrow}\ {{}^{\mathrm{u}}\mathrm{\underline{n}ormal}}\ {\mathrm{f}} | n ← unormal f |
| 41 | center := ('+ r_/ o_\ f) / 4.0 | \ \ {\mathrm{center}}\ {\leftarrow}\ {(}{\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{\underline{o}}{\backslash}}\ {\mathrm{f}}{)}\ {\div}\ {4.0} | center ← (’+ r/ o\ f) ÷ 4.0 |
| 42 | outward := n * (2.0 * f_loat 0 < '+ r_/ n * center) - 1.0 | \ \ {\mathrm{outward}}\ {\leftarrow}\ {\mathrm{n}}\ {\times}\ {(}{2.0}\ {\times}\ {\mathrm{\underline{f}loat}}\ {0}\ {<}\ {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{n}}\ {\times}\ {\mathrm{center}}{)}\ {-}\ {1.0} | outward ← n × (2.0 × float 0 < ’+ r/ n × center) − 1.0 |
| 43 | 0 m_ax ('+ r_/ outward * light) / ('+ r_/ n * n) ^ 0.5 | \ \ {0}\ {\mathrm{\underline{m}ax}}\ {(}{\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{outward}}\ {\times}\ {\mathrm{light}}{)}\ {\div}\ {(}{\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{n}}\ {\times}\ {\mathrm{n}}{)}\ {\mathbin{\hat{}}}\ {0.5} | 0 max (’+ r/ outward × light) ÷ (’+ r/ n × n) ^ 0.5 |
| 44 | } | {\}} | } |
| 47 | u:p_olygon := { shaded f -> | {{}^{\mathrm{u}}\mathrm{\underline{p}olygon}}\ {\leftarrow}\ {\{}\ {\mathrm{shaded}}\ {\mathrm{f}}\ {\to} | upolygon ← { shaded f → |
| 48 | fill := v:f_ill "shaded" i_f< "v:r_gb 3 r_eshape 40 + 200 * u:l_it f; \"none\"" | \ \ {\mathrm{fill}}\ {\leftarrow}\ {{}^{\mathrm{v}}\mathrm{\underline{f}ill}}\ {\text{"shaded"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{"v:r\_gb 3 r\_eshape 40 + 200 * u:l\_it f; \textbackslash{}"none\textbackslash{}""}} | fill ← vfill "shaded" if< "v:r_gb 3 r_eshape 40 + 200 * u:l_it f; \"none\"" |
| 49 | (fill c_at "#222" v:s_troke 1.5) v:p_olygon f_loor 0.5 + u:s_creen f | \ \ {(}{\mathrm{fill}}\ {\mathrm{\underline{c}at}}\ {\text{"\#222"}}\ {{}^{\mathrm{v}}\mathrm{\underline{s}troke}}\ {1.5}{)}\ {{}^{\mathrm{v}}\mathrm{\underline{p}olygon}}\ {\mathrm{\underline{f}loor}}\ {0.5}\ {+}\ {{}^{\mathrm{u}}\mathrm{\underline{s}creen}}\ {\mathrm{f}} | (fill cat "#222" vstroke 1.5) vpolygon floor 0.5 + uscreen f |
| 50 | } | {\}} | } |
| 54 | u:s_cene := { shaded a -> | {{}^{\mathrm{u}}\mathrm{\underline{s}cene}}\ {\leftarrow}\ {\{}\ {\mathrm{shaded}}\ {\mathrm{a}}\ {\to} | uscene ← { shaded a → |
| 55 | turned := ((g:r_otY 1.3 * a) g:t_urn g:r_otX a) g:t_urn cube | \ \ {\mathrm{turned}}\ {\leftarrow}\ {(}{(}{{}^{\mathrm{g}}\mathrm{\underline{r}otY}}\ {1.3}\ {\times}\ {\mathrm{a}}{)}\ {{}^{\mathrm{g}}\mathrm{\underline{t}urn}}\ {{}^{\mathrm{g}}\mathrm{\underline{r}otX}}\ {\mathrm{a}}{)}\ {{}^{\mathrm{g}}\mathrm{\underline{t}urn}}\ {\mathrm{cube}} | turned ← ((grotY 1.3 × a) gturn grotX a) gturn cube |
| 56 | solid := faces g:s_olid turned | \ \ {\mathrm{solid}}\ {\leftarrow}\ {\mathrm{faces}}\ {{}^{\mathrm{g}}\mathrm{\underline{s}olid}}\ {\mathrm{turned}} | solid ← faces gsolid turned |
| 57 | polygons := '{ i -> shaded u:p_olygon i s_elect solid } m_ap g:o_rder solid | \ \ {\mathrm{polygons}}\ {\leftarrow}\ {\text{'}}{\{}\ {\mathrm{i}}\ {\to}\ {\mathrm{shaded}}\ {{}^{\mathrm{u}}\mathrm{\underline{p}olygon}}\ {\mathrm{i}}\ {\mathrm{\underline{s}elect}}\ {\mathrm{solid}}\ {\}}\ {\mathrm{\underline{m}ap}}\ {{}^{\mathrm{g}}\mathrm{\underline{o}rder}}\ {\mathrm{solid}} | polygons ← ’{ i → shaded upolygon i select solid } map gorder solid |
| 58 | (size c_at size) v:p_icture d_isclose '{ x y -> e_nclose (d_isclose x) c_at d_isclose y } r_/ polygons | \ \ {(}{\mathrm{size}}\ {\mathrm{\underline{c}at}}\ {\mathrm{size}}{)}\ {{}^{\mathrm{v}}\mathrm{\underline{p}icture}}\ {\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{polygons}} | (size cat size) vpicture disclose ’{ x y → enclose (disclose x) cat disclose y } r/ polygons |
| 59 | } | {\}} | } |
| 61 | u:f_rame := { shaded a -> []S_HOW shaded u:s_cene a; []D_L 0.04; @ } | {{}^{\mathrm{u}}\mathrm{\underline{f}rame}}\ {\leftarrow}\ {\{}\ {\mathrm{shaded}}\ {\mathrm{a}}\ {\to}\ {\square \mathrm{\underline{S}HOW}}\ {\mathrm{shaded}}\ {{}^{\mathrm{u}}\mathrm{\underline{s}cene}}\ {\mathrm{a}}{\diamond}\ {\square \mathrm{\underline{D}L}}\ {0.04}{\diamond}\ {@}\ {\}} | uframe ← { shaded a → □SHOW shaded uscene a⋄ □DL 0.04⋄ @ } |
| 63 | angles := 30.0 * f_loat o_ffsets 12 | {\mathrm{angles}}\ {\leftarrow}\ {30.0}\ {\times}\ {\mathrm{\underline{f}loat}}\ {\mathrm{\underline{o}ffsets}}\ {12} | angles ← 30.0 × float offsets 12 |
| 64 | shown := '{ a -> 0 u:f_rame a } e_ach angles | {\mathrm{shown}}\ {\leftarrow}\ {\text{'}}{\{}\ {\mathrm{a}}\ {\to}\ {0}\ {{}^{\mathrm{u}}\mathrm{\underline{f}rame}}\ {\mathrm{a}}\ {\}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{angles}} | shown ← ’{ a → 0 uframe a } each angles |
| 65 | shown := '{ a -> 1 u:f_rame a } e_ach angles | {\mathrm{shown}}\ {\leftarrow}\ {\text{'}}{\{}\ {\mathrm{a}}\ {\to}\ {1}\ {{}^{\mathrm{u}}\mathrm{\underline{f}rame}}\ {\mathrm{a}}\ {\}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{angles}} | shown ← ’{ a → 1 uframe a } each angles |
| 66 | "24 frames shown" | {\text{"24 frames shown"}} | "24 frames shown" |
| 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 := "demos/rosetta/data.toml" | {\mathrm{data}}\ {\leftarrow}\ {\text{"demos/rosetta/data.toml"}} | data ← "demos/rosetta/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 := "0 = t_ally note" i_f< "\"(no concise idiom)\"; note" | \ \ {\mathrm{missing}}\ {\leftarrow}\ {\text{"0 = t\_ally note"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{"\textbackslash{}"(no concise idiom)\textbackslash{}"; note"}} | missing ← "0 = t_ally note" if< "\"(no concise idiom)\"; note" |
| 140 | result := "0 = t_ally out" i_f< "\"\"; \"-> \" c_at u:o_neLine out" | \ \ {\mathrm{result}}\ {\leftarrow}\ {\text{"0 = t\_ally out"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{"\textbackslash{}"\textbackslash{}"; \textbackslash{}"-> \textbackslash{}" c\_at u:o\_neLine out"}} | result ← "0 = t_ally out" if< "\"\"; \"-> \" c_at u:o_neLine 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 := { ao state -> | {{}^{\mathrm{u}}\mathrm{\underline{i}tem}}\ {\leftarrow}\ {\{}\ {\mathrm{ao}}\ {\mathrm{state}}\ {\to} | uitem ← { ao state → |
| 151 | axis := 1 s_elect ao | \ \ {\mathrm{axis}}\ {\leftarrow}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{ao}} | axis ← 1 select ao |
| 152 | n := f_loor 0.5 + (axis c_at cm:COUNT) cm:a_t state | \ \ {\mathrm{n}}\ {\leftarrow}\ {\mathrm{\underline{f}loor}}\ {0.5}\ {+}\ {(}{\mathrm{axis}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{cm}}\mathrm{COUNT}}{)}\ {{}^{\mathrm{cm}}\mathrm{\underline{a}t}}\ {\mathrm{state}} | n ← floor 0.5 + (axis cat cmCOUNT) cmat state |
| 153 | n cm:w_rap 1 + (f_loor 2 s_elect ao) + st:b_ase (axis c_at cm:ANGLE) cm:a_t state | \ \ {\mathrm{n}}\ {{}^{\mathrm{cm}}\mathrm{\underline{w}rap}}\ {1}\ {+}\ {(}{\mathrm{\underline{f}loor}}\ {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{ao}}{)}\ {+}\ {{}^{\mathrm{st}}\mathrm{\underline{b}ase}}\ {(}{\mathrm{axis}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{cm}}\mathrm{ANGLE}}{)}\ {{}^{\mathrm{cm}}\mathrm{\underline{a}t}}\ {\mathrm{state}} | n cmwrap 1 + (floor 2 select ao) + stbase (axis cat cmANGLE) cmat state |
| 154 | } | {\}} | } |
| 162 | u:s_tone := { state -> | {{}^{\mathrm{u}}\mathrm{\underline{s}tone}}\ {\leftarrow}\ {\{}\ {\mathrm{state}}\ {\to} | ustone ← { state → |
| 163 | i := (cm:IDIOM c_at 0.0) u:i_tem state | \ \ {\mathrm{i}}\ {\leftarrow}\ {(}{{}^{\mathrm{cm}}\mathrm{IDIOM}}\ {\mathrm{\underline{c}at}}\ {0.0}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{i}tem}}\ {\mathrm{state}} | i ← (cmIDIOM cat 0.0) uitem state |
| 164 | roll := (cm:IDIOM c_at cm:ANGLE) cm:a_t state | \ \ {\mathrm{roll}}\ {\leftarrow}\ {(}{{}^{\mathrm{cm}}\mathrm{IDIOM}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{cm}}\mathrm{ANGLE}}{)}\ {{}^{\mathrm{cm}}\mathrm{\underline{a}t}}\ {\mathrm{state}} | roll ← (cmIDIOM cat cmANGLE) cmat state |
| 165 | top := 1 st:r_ing ((cm:TOP c_at cm:ANGLE) cm:a_t state) c_at roll | \ \ {\mathrm{top}}\ {\leftarrow}\ {1}\ {{}^{\mathrm{st}}\mathrm{\underline{r}ing}}\ {(}{(}{{}^{\mathrm{cm}}\mathrm{TOP}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{cm}}\mathrm{ANGLE}}{)}\ {{}^{\mathrm{cm}}\mathrm{\underline{a}t}}\ {\mathrm{state}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{roll}} | top ← 1 string ((cmTOP cat cmANGLE) cmat state) cat roll |
| 166 | bottom := -1 st:r_ing ((cm:BOTTOM c_at cm:ANGLE) cm:a_t state) c_at roll | \ \ {\mathrm{bottom}}\ {\leftarrow}\ {-1}\ {{}^{\mathrm{st}}\mathrm{\underline{r}ing}}\ {(}{(}{{}^{\mathrm{cm}}\mathrm{BOTTOM}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{cm}}\mathrm{ANGLE}}{)}\ {{}^{\mathrm{cm}}\mathrm{\underline{a}t}}\ {\mathrm{state}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{roll}} | bottom ← −1 string ((cmBOTTOM cat cmANGLE) cmat state) cat roll |
| 167 | all := top c_at bottom | \ \ {\mathrm{all}}\ {\leftarrow}\ {\mathrm{top}}\ {\mathrm{\underline{c}at}}\ {\mathrm{bottom}} | all ← top cat bottom |
| 168 | c_apName := { k -> v:e_scape d_isclose ((cm:IDIOM c_at f_loat 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{\underline{c}at}}\ {\mathrm{\underline{f}loat}}\ {\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 cat float k select stcapOffsets) uitem state) select idiomNames } |
| 169 | c_apText := { k -> | \ \ {\mathrm{\underline{c}apText}}\ {\leftarrow}\ {\{}\ {\mathrm{k}}\ {\to} | capText ← { k → |
| 170 | k = 5 ? c_apName 1 | \ \ \ \ {\mathrm{k}}\ {=}\ {5}\ {?}\ {\mathrm{\underline{c}apName}}\ {1} | k = 5 ? capName 1 |
| 171 | k = 12 ? c_apName 2 | \ \ \ \ {\mathrm{k}}\ {=}\ {12}\ {?}\ {\mathrm{\underline{c}apName}}\ {2} | k = 12 ? capName 2 |
| 172 | "" | \ \ \ \ {\text{""}} | "" |
| 173 | } | \ \ {\}} | } |
| 174 | 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 } |
| 175 | t_opPanel := { k -> (e_nclose "#fdfcfa") c_at i u:f_ace (cm:TOP c_at f_loat 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{\underline{c}at}}\ {\mathrm{\underline{f}loat}}\ {\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 cat float k select stringOffsets) uitem state } |
| 176 | b_ottomPanel := { k -> (e_nclose "#f4f1ec") c_at i u:f_ace (cm:BOTTOM c_at f_loat 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{\underline{c}at}}\ {\mathrm{\underline{f}loat}}\ {\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 cat float k select stringOffsets) uitem state } |
| 177 | l_ines := { k -> | \ \ {\mathrm{\underline{l}ines}}\ {\leftarrow}\ {\{}\ {\mathrm{k}}\ {\to} | lines ← { k → |
| 178 | k <= 4 ? t_opPanel k | \ \ \ \ {\mathrm{k}}\ {\leq}\ {4}\ {?}\ {\mathrm{\underline{t}opPanel}}\ {\mathrm{k}} | k ≤ 4 ? topPanel k |
| 179 | k <= 6 ? c_ap k | \ \ \ \ {\mathrm{k}}\ {\leq}\ {6}\ {?}\ {\mathrm{\underline{c}ap}}\ {\mathrm{k}} | k ≤ 6 ? cap k |
| 180 | k <= 10 ? b_ottomPanel k - 6 | \ \ \ \ {\mathrm{k}}\ {\leq}\ {10}\ {?}\ {\mathrm{\underline{b}ottomPanel}}\ {\mathrm{k}}\ {-}\ {6} | k ≤ 10 ? bottomPanel k − 6 |
| 181 | c_ap k | \ \ \ \ {\mathrm{\underline{c}ap}}\ {\mathrm{k}} | cap k |
| 182 | } | \ \ {\}} | } |
| 183 | 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 } |
| 184 | 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 |
| 185 | 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 |
| 186 | (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 |
| 187 | } | {\}} | } |
| 189 | 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 } |
| 196 | u:w_here := { s -> | {{}^{\mathrm{u}}\mathrm{\underline{w}here}}\ {\leftarrow}\ {\{}\ {\mathrm{s}}\ {\to} | uwhere ← { s → |
| 197 | i := d_isclose ((cm:IDIOM c_at 0.0) u:i_tem s) s_elect idioms | \ \ {\mathrm{i}}\ {\leftarrow}\ {\mathrm{\underline{d}isclose}}\ {(}{(}{{}^{\mathrm{cm}}\mathrm{IDIOM}}\ {\mathrm{\underline{c}at}}\ {0.0}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{i}tem}}\ {\mathrm{s}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{idioms}} | i ← disclose ((cmIDIOM cat 0.0) uitem s) select idioms |
| 198 | t := d_isclose ((cm:TOP c_at 0.0) u:i_tem s) s_elect languages | \ \ {\mathrm{t}}\ {\leftarrow}\ {\mathrm{\underline{d}isclose}}\ {(}{(}{{}^{\mathrm{cm}}\mathrm{TOP}}\ {\mathrm{\underline{c}at}}\ {0.0}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{i}tem}}\ {\mathrm{s}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{languages}} | t ← disclose ((cmTOP cat 0.0) uitem s) select languages |
| 199 | b := d_isclose ((cm:BOTTOM c_at 0.0) u:i_tem s) s_elect languages | \ \ {\mathrm{b}}\ {\leftarrow}\ {\mathrm{\underline{d}isclose}}\ {(}{(}{{}^{\mathrm{cm}}\mathrm{BOTTOM}}\ {\mathrm{\underline{c}at}}\ {0.0}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{i}tem}}\ {\mathrm{s}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{languages}} | b ← disclose ((cmBOTTOM cat 0.0) uitem s) select languages |
| 200 | "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 |
| 201 | } | {\}} | } |
| 207 | u:l_oop := { state -> | {{}^{\mathrm{u}}\mathrm{\underline{l}oop}}\ {\leftarrow}\ {\{}\ {\mathrm{state}}\ {\to} | uloop ← { state → |
| 208 | e := []E_VENT @ | \ \ {\mathrm{e}}\ {\leftarrow}\ {\square \mathrm{\underline{E}VENT}}\ {@} | e ← □EVENT @ |
| 209 | kind := []E_KIND e | \ \ {\mathrm{kind}}\ {\leftarrow}\ {\square \mathrm{\underline{E}KIND}}\ {\mathrm{e}} | kind ← □EKIND e |
| 210 | kind m_atch "end" ? state | \ \ {\mathrm{kind}}\ {\mathrm{\underline{m}atch}}\ {\text{"end"}}\ {?}\ {\mathrm{state}} | kind match "end" ? state |
| 211 | next := state cm:u_pdate e | \ \ {\mathrm{next}}\ {\leftarrow}\ {\mathrm{state}}\ {{}^{\mathrm{cm}}\mathrm{\underline{u}pdate}}\ {\mathrm{e}} | next ← state cmupdate e |
| 212 | "(u:w_here state) m_atch u:w_here next" u_nless< "p_rint! u:w_here next" | \ \ {\text{"(u:w\_here state) m\_atch u:w\_here next"}}\ {\mathrm{\underline{u}nless}{<}}\ {\text{"p\_rint! u:w\_here next"}} | "(u:w_here state) m_atch u:w_here next" unless< "p_rint! u:w_here next" |
| 213 | "(cm:m_ode state) m_atch cm:m_ode next" u_nless< "p_rint! \"mode \" c_at cm:m_ode next" | \ \ {\text{"(cm:m\_ode state) m\_atch cm:m\_ode next"}}\ {\mathrm{\underline{u}nless}{<}}\ {\text{"p\_rint! \textbackslash{}"mode \textbackslash{}" c\_at cm:m\_ode next"}} | "(cm:m_ode state) m_atch cm:m_ode next" unless< "p_rint! \"mode \" c_at cm:m_ode next" |
| 214 | "n_ot kind m_atch \"tick\"" u_nless< "[]S_HOW u:s_tone next" | \ \ {\text{"n\_ot kind m\_atch \textbackslash{}"tick\textbackslash{}""}}\ {\mathrm{\underline{u}nless}{<}}\ {\text{"[]S\_HOW u:s\_tone next"}} | "n_ot kind m_atch \"tick\"" unless< "[]S_HOW u:s_tone next" |
| 215 | u:l_oop next | \ \ {{}^{\mathrm{u}}\mathrm{\underline{l}oop}}\ {\mathrm{next}} | uloop next |
| 216 | } | {\}} | } |
| 221 | start := cm:r_esume cm:s_ettle (cm:BOTTOM c_at 2.0) 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}}\ {\mathrm{\underline{c}at}}\ {2.0}{)}\ {{}^{\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 cat 2.0) cmchoose (tally idioms) cmstart tally languages |
| 222 | 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 |
| 223 | 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 |
| 224 | u:l_oop start | {{}^{\mathrm{u}}\mathrm{\underline{l}oop}}\ {\mathrm{start}} | uloop start |
| 12 | 42 # an Int | {42} | 42 |
| 13 | -3 2.5 # a negative literal; a strand has one type (Float) | {-3}\ {2.5} | −3 2.5 |
| 14 | x := 3 # `:=` binds; `=` is always equality | {\mathrm{x}}\ {\leftarrow}\ {3} | x ← 3 |
| 15 | x^2 # a literal exponent touches its value: superscript | {\mathrm{x}}^{2} | x2 |
| 16 | 4^-1 # a negative exponent gives a Float (a literal base) | {4}^{-1} | 4−1 |
| 17 | 2 ^ 10 # spaced `^` is the power function (computed exponents) | {2}\ {\mathbin{\hat{}}}\ {10} | 2 ^ 10 |
| 18 | 7 / 2 # `/` always gives a Float | {7}\ {\div}\ {2} | 7 ÷ 2 |
| 19 | 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 |
| 20 | (0.1 + 0.2) = 0.3 # `=` is exact: 0 (false) | {(}{0.1}\ {+}\ {0.2}{)}\ {=}\ {0.3} | (0.1 + 0.2) = 0.3 |
| 21 | (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 |
| 22 | (3 < 4) & 2 != 2 # Bool (`& | !=`); no precedence: parenthesize the left | {(}{3}\ {<}\ {4}{)}\ {\wedge}\ {2}\ {\neq}\ {2} | (3 < 4) ∧ 2 = 2 |
| 23 | f_loat 3 # Int to Float | {\mathrm{\underline{f}loat}}\ {3} | float 3 |
| 24 | 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 |
| 25 | a_tan 1 # and c_os | {\mathrm{\underline{a}tan}}\ {1} | atan 1 |
| 28 | count! := 0 # only names ending in ! (like `count!`) may be reassigned | {\mathrm{count}!}\ {\leftarrow}\ {0} | count! ← 0 |
| 29 | count! := count! + 1 | {\mathrm{count}!}\ {\leftarrow}\ {\mathrm{count}!}\ {+}\ {1} | count! ← count! + 1 |
| 30 | count! | {\mathrm{count}!} | count! |
| 33 | "hello" | {\text{"hello"}} | "hello" |
| 34 | "abc" = "abd" # item by item | {\text{"abc"}}\ {=}\ {\text{"abd"}} | "abc" = "abd" |
| 35 | 3 t_ake "hello" | {3}\ {\mathrm{\underline{t}ake}}\ {\text{"hello"}} | 3 take "hello" |
| 36 | "hello X̲ᵉTᵃL" # strings and comments may hold any Unicode (code may not) | {\text{"hello \underline{X}ᵉTᵃL"}} | "hello XᵉTᵃL" |
| 39 | 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 |
| 40 | m | {\mathrm{m}} | m |
| 41 | s_hape m; t_ally m | {\mathrm{\underline{s}hape}}\ {\mathrm{m}}{\diamond}\ {\mathrm{\underline{t}ally}}\ {\mathrm{m}} | shape m⋄ tally m |
| 42 | m * 10 # a scalar extends to every item | {\mathrm{m}}\ {\times}\ {10} | m × 10 |
| 43 | 2 s_elect m # the 2nd major cell (row) | {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{m}} | 2 select m |
| 44 | -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 |
| 45 | (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 |
| 46 | 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 |
| 47 | 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 |
| 48 | 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 |
| 49 | 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 |
| 50 | r_avel m | {\mathrm{\underline{r}avel}}\ {\mathrm{m}} | ravel m |
| 51 | 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 |
| 54 | 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 } |
| 55 | 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 |
| 56 | u:s_ub := { _l - _r } # `_l` is the left argument | {{}^{\mathrm{u}}\mathrm{\underline{s}ub}}\ {\leftarrow}\ {\{}\ {\_\mathrm{l}}\ {-}\ {\_\mathrm{r}}\ {\}} | usub ← { _l − _r } |
| 57 | 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 |
| 58 | 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 } |
| 59 | 3 u:h_yp 4 | {3}\ {{}^{\mathrm{u}}\mathrm{\underline{h}yp}}\ {4} | 3 uhyp 4 |
| 60 | 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 } |
| 61 | u:f_act := { n -> | {{}^{\mathrm{u}}\mathrm{\underline{f}act}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\to} | ufact ← { n → |
| 62 | n <= 1 ? 1 | \ \ {\mathrm{n}}\ {\leq}\ {1}\ {?}\ {1} | n ≤ 1 ? 1 |
| 63 | n * u:f_act n - 1 | \ \ {\mathrm{n}}\ {\times}\ {{}^{\mathrm{u}}\mathrm{\underline{f}act}}\ {\mathrm{n}}\ {-}\ {1} | n × ufact n − 1 |
| 64 | } | {\}} | } |
| 65 | u:f_act 10 # recursion | {{}^{\mathrm{u}}\mathrm{\underline{f}act}}\ {10} | ufact 10 |
| 66 | u:t_wo := { @ -> 2 } # a niladic function takes `@` | {{}^{\mathrm{u}}\mathrm{\underline{t}wo}}\ {\leftarrow}\ {\{}\ {@}\ {\to}\ {2}\ {\}} | utwo ← { @ → 2 } |
| 67 | u:t_wo @ | {{}^{\mathrm{u}}\mathrm{\underline{t}wo}}\ {@} | utwo @ |
| 68 | u:k_eep := { a ~b -> a } # `~b` is a lazy parameter: evaluated | {{}^{\mathrm{u}}\mathrm{\underline{k}eep}}\ {\leftarrow}\ {\{}\ {\mathrm{a}}\ {\sim}{\mathrm{b}}\ {\to}\ {\mathrm{a}}\ {\}} | ukeep ← { a ∼b → a } |
| 69 | 7 u:k_eep 1 / 0 # only if used, so no division by zero | {7}\ {{}^{\mathrm{u}}\mathrm{\underline{k}eep}}\ {1}\ {\div}\ {0} | 7 ukeep 1 ÷ 0 |
| 70 | (u:s_ub 100)_ 1 # `(expr)_` applies a function value | {(}{{}^{\mathrm{u}}\mathrm{\underline{s}ub}}\ {100}{)}{\_}\ {1} | (usub 100)_ 1 |
| 71 | 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 } |
| 72 | '{ _r + 10 } u:t_wice 3 # 3 + 10 + 10 | {\text{'}}{\{}\ {\_\mathrm{r}}\ {+}\ {10}\ {\}}\ {{}^{\mathrm{u}}\mathrm{\underline{t}wice}}\ {3} | ’{ _r + 10 } utwice 3 |
| 73 | '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 |
| 76 | '+ 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 |
| 77 | '- r_/ 1 2 3 # reduce folds from the right: 1 - (2 - 3) | {\text{'}}{-}\ {\mathrm{\underline{r}}{/}}\ {1}\ {2}\ {3} | ’− r/ 1 2 3 |
| 78 | '+ s_\ 1 2 3 4 # scan: the prefix reductions | {\text{'}}{+}\ {\mathrm{\underline{s}}{\backslash}}\ {1}\ {2}\ {3}\ {4} | ’+ s\ 1 2 3 4 |
| 79 | '+ r_/ m # the leading axis: column sums | {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{m}} | ’+ r/ m |
| 80 | '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 |
| 81 | 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 |
| 82 | 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 |
| 83 | 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 |
| 84 | '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 |
| 85 | 2 '/ s_wap 1 # swap the arguments: 1 / 2 | {2}\ {\text{'}}{\div}\ {\mathrm{\underline{s}wap}}\ {1} | 2 ’÷ swap 1 |
| 86 | '{ _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 |
| 89 | 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] |
| 90 | u:a_vg 1 2 3 4 | {{}^{\mathrm{u}}\mathrm{\underline{a}vg}}\ {1}\ {2}\ {3}\ {4} | uavg 1 2 3 4 |
| 91 | { 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 |
| 92 | [n_eg a_bs] -5 # atop: `n_eg a_bs x` | {[}{\mathrm{\underline{n}eg}}\ {\mathrm{\underline{a}bs}}{]}\ {-5} | [neg abs] −5 |
| 93 | 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 |
| 94 | [i_d - n_eg] 5 # hook: `x - n_eg x` | {[}{\mathrm{\underline{i}d}}\ {-}\ {\mathrm{\underline{n}eg}}{]}\ {5} | [id − neg] 5 |
| 95 | 1 2 [+ * -] 3 4 # dyadic fork: `(x + y) * (x - y)` | {1}\ {2}\ {[}{+}\ {\times}\ {-}{]}\ {3}\ {4} | 1 2 [+ × −] 3 4 |
| 96 | [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 |
| 97 | '[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" |
| 100 | 1 o_- 1 2 3 4 # rotate toward the front | {1}\ {\mathrm{\underline{o}}{-}}\ {1}\ {2}\ {3}\ {4} | 1 o− 1 2 3 4 |
| 101 | r_ev "stressed" | {\mathrm{\underline{r}ev}}\ {\text{"stressed"}} | rev "stressed" |
| 105 | '+ r_/ m # implicit: axis 1, so column sums | {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{m}} | ’+ r/ m |
| 106 | '+ r_/_1 m # the same, explicit | {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{1}}\ {\mathrm{m}} | ’+ r/1 m |
| 107 | '+ r_/_2 m # axis 2: row sums | {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{2}}\ {\mathrm{m}} | ’+ r/2 m |
| 108 | '+ s_\_2 m # running sums along each row | {\text{'}}{+}\ {{\mathrm{\underline{s}}{\backslash}}_{2}}\ {\mathrm{m}} | ’+ s\2 m |
| 109 | 1 o_- m # rotate the rows (axis 1) | {1}\ {\mathrm{\underline{o}}{-}}\ {\mathrm{m}} | 1 o− m |
| 110 | 1 o_-_1 m # the same, explicit | {1}\ {{\mathrm{\underline{o}}{-}}_{1}}\ {\mathrm{m}} | 1 o−1 m |
| 111 | 1 o_-_2 m # rotate within each row (axis 2) | {1}\ {{\mathrm{\underline{o}}{-}}_{2}}\ {\mathrm{m}} | 1 o−2 m |
| 112 | r_ev_2 m # reverse each row | {{\mathrm{\underline{r}ev}}_{2}}\ {\mathrm{m}} | rev2 m |
| 113 | '+ r_/_12 m # two axes in turn: the total | {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{12}}\ {\mathrm{m}} | ’+ r/12 m |
| 114 | -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 |
| 115 | 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 |
| 116 | o_\ m # transpose: rows become columns | {\mathrm{\underline{o}}{\backslash}}\ {\mathrm{m}} | o\ m |
| 117 | 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 |
| 118 | s_hape o_\ a # every axis reversed: 4 3 2 | {\mathrm{\underline{s}hape}}\ {\mathrm{\underline{o}}{\backslash}}\ {\mathrm{a}} | shape o\ a |
| 119 | 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 |
| 120 | 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 |
| 123 | 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 |
| 124 | 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 |
| 125 | u_nique v | {\mathrm{\underline{u}nique}}\ {\mathrm{v}} | unique v |
| 126 | v i_ndexOf 5 7 # 7 is absent: tally + 1 | {\mathrm{v}}\ {\mathrm{\underline{i}ndexOf}}\ {5}\ {7} | v indexOf 5 7 |
| 127 | 2 7 m_ember? v | {2}\ {7}\ {\mathrm{\underline{m}ember}{?}}\ {\mathrm{v}} | 2 7 member? v |
| 128 | w_here v > 4 # indices of the 1s | {\mathrm{\underline{w}here}}\ {\mathrm{v}}\ {>}\ {4} | where v > 4 |
| 131 | n := "ab" "cde" # a strand of strings: a vector of 2 boxes | {\mathrm{n}}\ {\leftarrow}\ {\text{"ab"}}\ {\text{"cde"}} | n ← "ab" "cde" |
| 132 | n # nested values print framed (APL2's DISPLAY) | {\mathrm{n}} | n |
| 133 | t_ally n | {\mathrm{\underline{t}ally}}\ {\mathrm{n}} | tally n |
| 134 | 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 |
| 135 | s := "to be or not" | {\mathrm{s}}\ {\leftarrow}\ {\text{"to be or not"}} | s ← "to be or not" |
| 136 | (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 |
| 137 | '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 |
| 138 | d_isplay m # any value framed, as a character matrix (xetal --box prints all so) | {\mathrm{\underline{d}isplay}}\ {\mathrm{m}} | display m |
| 141 | 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 |
| 142 | r_oll! 6 6 6 # (and each line rolls again) | {\mathrm{\underline{r}oll}{!}}\ {6}\ {6}\ {6} | roll! 6 6 6 |
| 143 | r_oll! 6 6 6 | {\mathrm{\underline{r}oll}{!}}\ {6}\ {6}\ {6} | roll! 6 6 6 |
| 144 | p_rint! "printed, then returned" # `p_rint!` prints and returns its argument | {\mathrm{\underline{p}rint}{!}}\ {\text{"printed, then returned"}} | print! "printed, then returned" |
| 151 | 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 |
| 154 | "s:" u_se< "Stats" # import a library under an alias of your choosing | {\text{"s:"}}\ {\mathrm{\underline{u}se}{<}}\ {\text{"Stats"}} | "s:" use< "Stats" |
| 155 | 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 |
| 156 | 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 |
| 157 | s:r_ange 3 1 4 1 5 # largest minus smallest | {{}^{\mathrm{s}}\mathrm{\underline{r}ange}}\ {3}\ {1}\ {4}\ {1}\ {5} | srange 3 1 4 1 5 |
| 158 | "h:" u_se< "Hello" # a library of your own, found in userlibs/ | {\text{"h:"}}\ {\mathrm{\underline{u}se}{<}}\ {\text{"Hello"}} | "h:" use< "Hello" |
| 159 | h:h_ello @ # niladic: called with Unit | {{}^{\mathrm{h}}\mathrm{\underline{h}ello}}\ {@} | hhello @ |
| 162 | "c:" u_se< "Combinators" # Smullyan's birds, a standard library | {\text{"c:"}}\ {\mathrm{\underline{u}se}{<}}\ {\text{"Combinators"}} | "c:" use< "Combinators" |
| 163 | 1 c:K_ 2 # K keeps its first argument | {1}\ {{}^{\mathrm{c}}\mathrm{\underline{K}}}\ {2} | 1 cK 2 |
| 164 | 10 '- c:C_ 3 # C swaps the arguments: 3 - 10 | {10}\ {\text{'}}{-}\ {{}^{\mathrm{c}}\mathrm{\underline{C}}}\ {3} | 10 ’− cC 3 |
| 165 | '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 |
| 166 | '* c:W_ 4 # W uses its argument twice: 4 * 4 | {\text{'}}{\times}\ {{}^{\mathrm{c}}\mathrm{\underline{W}}}\ {4} | ’× cW 4 |
| 167 | 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 } |
| 168 | '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 |
| 169 | n_eg^3 5 # a superscript repeats a function: n_eg three times | {\mathrm{\underline{n}eg}}^{3}\ {5} | neg3 5 |
| 172 | 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 } |
| 173 | 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 |
| 11 | l:I_ := { x -> x } # Idiot Bird (identity) | {{}^{\mathrm{l}}\mathrm{\underline{I}}}\ {\leftarrow}\ {\{}\ {\mathrm{x}}\ {\to}\ {\mathrm{x}}\ {\}} | lI ← { x → x } |
| 12 | l:K_ := { x y -> x } # Kestrel | {{}^{\mathrm{l}}\mathrm{\underline{K}}}\ {\leftarrow}\ {\{}\ {\mathrm{x}}\ {\mathrm{y}}\ {\to}\ {\mathrm{x}}\ {\}} | lK ← { x y → x } |
| 13 | 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 } |
| 14 | 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 } |
| 15 | 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 } |
| 17 | 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 } |
| 18 | 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 } |
| 19 | 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}}}\ {(}{\mathrm{z}}\ {\mathrm{\underline{y}}}\ {\mathrm{w}}{)}{\_}\ {\mathrm{v}}\ {\}} | lB2 ← { x y z w v → x (z y w)_ v } |
| 20 | 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 } |
| 21 | 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 } |
| 22 | 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 } |
| 23 | 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}\ {(}{\mathrm{y}}\ {\mathrm{\underline{x}}}\ {\mathrm{z}}{)}{\_}\ {\mathrm{\underline{w}}}\ {\mathrm{v}}\ {\}} | lD1 ← { x y z w v → (y x z)_ w v } |
| 24 | 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 } |
| 25 | 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 } |
| 26 | 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 } |
| 27 | 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 } |
| 28 | 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 } |
| 29 | l:H_ := { x_ y z -> (y x_ z)_ y } # Hummingbird | {{}^{\mathrm{l}}\mathrm{\underline{H}}}\ {\leftarrow}\ {\{}\ {\mathrm{\underline{x}}}\ {\mathrm{y}}\ {\mathrm{z}}\ {\to}\ {(}{\mathrm{y}}\ {\mathrm{\underline{x}}}\ {\mathrm{z}}{)}{\_}\ {\mathrm{y}}\ {\}} | lH ← { x y z → (y x z)_ y } |
| 30 | 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 } |
| 31 | 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 } |
| 32 | 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 } |
| 33 | 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 } |
| 34 | 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 } |
| 35 | 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 } |
| 36 | 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 } |
| 37 | 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 } |
| 38 | 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 } |
| 39 | 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 } |
| 42 | 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}\ {(}{\mathrm{y}}\ {\mathrm{\underline{x}}}\ {\mathrm{w}}{)}{\_}\ {\mathrm{z}}\ {\}} | lCs ← { x y z w → (y x w)_ z } |
| 43 | 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}\ {(}{\mathrm{z}}\ {\mathrm{\underline{x}}}\ {\mathrm{w}}{)}{\_}\ {\mathrm{y}}\ {\}} | lRs ← { x y z w → (z x w)_ y } |
| 44 | 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}\ {(}{\mathrm{w}}\ {\mathrm{\underline{x}}}\ {\mathrm{z}}{)}{\_}\ {\mathrm{y}}\ {\}} | lFs ← { x y z w → (w x z)_ y } |
| 45 | 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}\ {(}{\mathrm{w}}\ {\mathrm{\underline{x}}}\ {\mathrm{y}}{)}{\_}\ {\mathrm{z}}\ {\}} | lVs ← { x y z w → (w x y)_ z } |
| 46 | 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}\ {(}{\mathrm{y}}\ {\mathrm{\underline{x}}}\ {\mathrm{z}}{)}{\_}\ {\mathrm{z}}\ {\}} | lWs ← { x y z → (y x z)_ z } |
| 49 | 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}\ {(}{(}{\mathrm{y}}\ {\mathrm{\underline{x}}}\ {\mathrm{z}}{)}{\_}\ {\mathrm{v}}{)}{\_}\ {\mathrm{w}}\ {\}} | lCss ← { x y z w v → ((y x z)_ v)_ w } |
| 50 | 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}\ {(}{(}{\mathrm{y}}\ {\mathrm{\underline{x}}}\ {\mathrm{w}}{)}{\_}\ {\mathrm{v}}{)}{\_}\ {\mathrm{z}}\ {\}} | lRss ← { x y z w v → ((y x w)_ v)_ z } |
| 51 | 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}\ {(}{(}{\mathrm{y}}\ {\mathrm{\underline{x}}}\ {\mathrm{v}}{)}{\_}\ {\mathrm{w}}{)}{\_}\ {\mathrm{z}}\ {\}} | lFss ← { x y z w v → ((y x v)_ w)_ z } |
| 52 | 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}\ {(}{(}{\mathrm{y}}\ {\mathrm{\underline{x}}}\ {\mathrm{v}}{)}{\_}\ {\mathrm{z}}{)}{\_}\ {\mathrm{w}}\ {\}} | lVss ← { x y z w v → ((y x v)_ z)_ w } |
| 53 | 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}\ {(}{(}{\mathrm{y}}\ {\mathrm{\underline{x}}}\ {\mathrm{z}}{)}{\_}\ {\mathrm{w}}{)}{\_}\ {\mathrm{w}}\ {\}} | lWss ← { x y z w → ((y x z)_ w)_ w } |
| 57 | 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 } |
| 16 | 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 "\"" } |
| 29 | l:e_scape := { t -> | {{}^{\mathrm{l}}\mathrm{\underline{e}scape}}\ {\leftarrow}\ {\{}\ {\mathrm{t}}\ {\to} | lescape ← { t → |
| 30 | 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 |
| 31 | j_oin 'e_sc m_ap t | \ \ {\mathrm{\underline{j}oin}}\ {\text{'}}{\mathrm{\underline{e}sc}}\ {\mathrm{\underline{m}ap}}\ {\mathrm{t}} | join ’esc map t |
| 32 | } | {\}} | } |
| 38 | 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 } |
| 45 | l:r_gb := { c -> | {{}^{\mathrm{l}}\mathrm{\underline{r}gb}}\ {\leftarrow}\ {\{}\ {\mathrm{c}}\ {\to} | lrgb ← { c → |
| 46 | 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 |
| 47 | "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 ")" |
| 48 | } | {\}} | } |
| 54 | 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\"" } |
| 61 | l:p_olygon := { attrs points -> "<polygon points=\"" c_at (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{\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 (pairs points) cat "\"" cat attrs cat "/>" } |
| 67 | l:p_olyline := { attrs points -> "<polyline points=\"" c_at (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{\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 (pairs points) cat "\"" cat attrs cat "/>" } |
| 73 | 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 } |
| 80 | 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>" } |
| 87 | 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>" } |
| 94 | 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>" } |
| 101 | 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>" } |
| 108 | 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>" } |
| 114 | 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 ")" } |
| 121 | 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 ")" } |
| 131 | l:m_atrix := { c -> | {{}^{\mathrm{l}}\mathrm{\underline{m}atrix}}\ {\leftarrow}\ {\{}\ {\mathrm{c}}\ {\to} | lmatrix ← { c → |
| 132 | tl := 1 s_elect_2 c | \ \ {\mathrm{tl}}\ {\leftarrow}\ {1}\ {{\mathrm{\underline{s}elect}}_{2}}\ {\mathrm{c}} | tl ← 1 select2 c |
| 133 | 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 |
| 134 | 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 |
| 135 | "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 ")" |
| 136 | } | {\}} | } |
| 142 | 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 ")" } |
| 150 | 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>" } |
| 156 | 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 } |
| 163 | l:g_radient := { id colors -> | {{}^{\mathrm{l}}\mathrm{\underline{g}radient}}\ {\leftarrow}\ {\{}\ {\mathrm{id}}\ {\mathrm{colors}}\ {\to} | lgradient ← { id colors → |
| 164 | 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 |
| 165 | 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 |
| 166 | "<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>" |
| 167 | } | {\}} | } |
| 175 | l:p_icture := { wh elements -> | {{}^{\mathrm{l}}\mathrm{\underline{p}icture}}\ {\leftarrow}\ {\{}\ {\mathrm{wh}}\ {\mathrm{elements}}\ {\to} | lpicture ← { wh elements → |
| 176 | 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 |
| 177 | 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 |
| 178 | "<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>" |
| 179 | } | {\}} | } |
| 187 | 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 } |
| 192 | e_sc := { c -> c = f_irst "&" ? "&"; c = f_irst "<" ? "<"; c = f_irst ">" ? ">"; c = f_irst "\"" ? """; c } | {\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}}\ {\}} | esc ← { c → c = first "&" ? "&"⋄ c = first "<" ? "<"⋄ c = first ">" ? ">"⋄ c = first "\"" ? """⋄ c } |
| 195 | j_oin := { b -> | {\mathrm{\underline{j}oin}}\ {\leftarrow}\ {\{}\ {\mathrm{b}}\ {\to} | join ← { b → |
| 196 | 0 = t_ally b ? "" | \ \ {0}\ {=}\ {\mathrm{\underline{t}ally}}\ {\mathrm{b}}\ {?}\ {\text{""}} | 0 = tally b ? "" |
| 197 | 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 |
| 198 | } | {\}} | } |
| 201 | p_airs := { points -> | {\mathrm{\underline{p}airs}}\ {\leftarrow}\ {\{}\ {\mathrm{points}}\ {\to} | pairs ← { points → |
| 202 | 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 |
| 203 | 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 |
| 204 | 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 |
| 205 | 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 |
| 206 | } | {\}} | } |
| 13 | 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" } |
| 17 | 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 |
| 21 | l:o_utcome := { s -> | {{}^{\mathrm{l}}\mathrm{\underline{o}utcome}}\ {\leftarrow}\ {\{}\ {\mathrm{s}}\ {\to} | loutcome ← { s → |
| 22 | 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 |
| 23 | 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 |
| 24 | } | {\}} | } |
| 29 | 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 |
| 30 | 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 } |
| 33 | 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 |
| 39 | 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 } |
| 40 | 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 } |
| 43 | 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 } |
| 46 | l:c_hoose := { m s -> | {{}^{\mathrm{l}}\mathrm{\underline{c}hoose}}\ {\leftarrow}\ {\{}\ {\mathrm{m}}\ {\mathrm{s}}\ {\to} | lchoose ← { m s → |
| 47 | p := w_here s = 0 | \ \ {\mathrm{p}}\ {\leftarrow}\ {\mathrm{\underline{w}here}}\ {\mathrm{s}}\ {=}\ {0} | p ← where s = 0 |
| 48 | 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 |
| 49 | (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 |
| 50 | } | {\}} | } |
| 55 | p_ick! := { m s -> | {\mathrm{\underline{p}ick}{!}}\ {\leftarrow}\ {\{}\ {\mathrm{m}}\ {\mathrm{s}}\ {\to} | pick! ← { m s → |
| 56 | p := w_here s = 0 | \ \ {\mathrm{p}}\ {\leftarrow}\ {\mathrm{\underline{w}here}}\ {\mathrm{s}}\ {=}\ {0} | p ← where s = 0 |
| 57 | (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 |
| 58 | } | {\}} | } |
| 59 | p_lay! := { m g -> | {\mathrm{\underline{p}lay}{!}}\ {\leftarrow}\ {\{}\ {\mathrm{m}}\ {\mathrm{g}}\ {\to} | play! ← { m g → |
| 60 | 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 |
| 61 | g := g c_at 1 9 r_eshape s l:a_fter m p_ick! s | \ \ {\mathrm{g}}\ {\leftarrow}\ {\mathrm{g}}\ {\mathrm{\underline{c}at}}\ {1}\ {9}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{s}}\ {{}^{\mathrm{l}}\mathrm{\underline{a}fter}}\ {\mathrm{m}}\ {\mathrm{\underline{p}ick}{!}}\ {\mathrm{s}} | g ← g cat 1 9 reshape s lafter m pick! s |
| 62 | 0 = l:o_utcome (t_ally g) s_elect g ? m p_lay! g; g | \ \ {0}\ {=}\ {{}^{\mathrm{l}}\mathrm{\underline{o}utcome}}\ {(}{\mathrm{\underline{t}ally}}\ {\mathrm{g}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{g}}\ {?}\ {\mathrm{m}}\ {\mathrm{\underline{p}lay}{!}}\ {\mathrm{g}}{\diamond}\ {\mathrm{g}} | 0 = loutcome (tally g) select g ? m play! g⋄ g |
| 63 | } | {\}} | } |
| 64 | l:g_ame! := { m -> m p_lay! 1 9 r_eshape 0 } | {{}^{\mathrm{l}}\mathrm{\underline{g}ame}{!}}\ {\leftarrow}\ {\{}\ {\mathrm{m}}\ {\to}\ {\mathrm{m}}\ {\mathrm{\underline{p}lay}{!}}\ {1}\ {9}\ {\mathrm{\underline{r}eshape}}\ {0}\ {\}} | lgame! ← { m → m play! 1 9 reshape 0 } |
| 71 | r_esult := { g j -> | {\mathrm{\underline{r}esult}}\ {\leftarrow}\ {\{}\ {\mathrm{g}}\ {\mathrm{j}}\ {\to} | result ← { g j → |
| 72 | 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 |
| 73 | 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 |
| 74 | (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 |
| 75 | } | {\}} | } |
| 76 | t_arget := { g m j -> | {\mathrm{\underline{t}arget}}\ {\leftarrow}\ {\{}\ {\mathrm{g}}\ {\mathrm{m}}\ {\mathrm{j}}\ {\to} | target ← { g m j → |
| 77 | j >= (t_ally g) - 2 ? g 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{\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 result j⋄ 0.9 × m lvalue (j + 3) select g |
| 78 | } | {\}} | } |
| 79 | b_ack := { g m j -> | {\mathrm{\underline{b}ack}}\ {\leftarrow}\ {\{}\ {\mathrm{g}}\ {\mathrm{m}}\ {\mathrm{j}}\ {\to} | back ← { g m j → |
| 80 | 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 |
| 81 | d := 0.2 * ((g t_arget m)_ j) - m l:v_alue (j + 1) s_elect g | \ \ {\mathrm{d}}\ {\leftarrow}\ {0.2}\ {\times}\ {(}{(}{\mathrm{g}}\ {\mathrm{\underline{t}arget}}\ {\mathrm{m}}{)}{\_}\ {\mathrm{j}}{)}\ {-}\ {\mathrm{m}}\ {{}^{\mathrm{l}}\mathrm{\underline{v}alue}}\ {(}{\mathrm{j}}\ {+}\ {1}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{g}} | d ← 0.2 × ((g target m)_ j) − m lvalue (j + 1) select g |
| 82 | m := m + (0.0 c_at d) '* t_able f_loat (r_ange t_ally 1 s_elect m) = k | \ \ {\mathrm{m}}\ {\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}} | m ← m + (0.0 cat d) ’× table float (range tally 1 select m) = k |
| 83 | j = 1 ? m; (g b_ack m)_ j - 1 | \ \ {\mathrm{j}}\ {=}\ {1}\ {?}\ {\mathrm{m}}{\diamond}\ {(}{\mathrm{g}}\ {\mathrm{\underline{b}ack}}\ {\mathrm{m}}{)}{\_}\ {\mathrm{j}}\ {-}\ {1} | j = 1 ? m⋄ (g back m)_ j − 1 |
| 84 | } | {\}} | } |
| 86 | m_eet := { m g -> | {\mathrm{\underline{m}eet}}\ {\leftarrow}\ {\{}\ {\mathrm{m}}\ {\mathrm{g}}\ {\to} | meet ← { m g → |
| 87 | 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 |
| 88 | 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 |
| 89 | 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 |
| 90 | (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 |
| 91 | } | {\}} | } |
| 92 | l:l_earn := { m g -> (g b_ack m m_eet g)_ (t_ally g) - 1 } | {{}^{\mathrm{l}}\mathrm{\underline{l}earn}}\ {\leftarrow}\ {\{}\ {\mathrm{m}}\ {\mathrm{g}}\ {\to}\ {(}{\mathrm{g}}\ {\mathrm{\underline{b}ack}}\ {\mathrm{m}}\ {\mathrm{\underline{m}eet}}\ {\mathrm{g}}{)}{\_}\ {(}{\mathrm{\underline{t}ally}}\ {\mathrm{g}}{)}\ {-}\ {1}\ {\}} | llearn ← { m g → (g back m meet g)_ (tally g) − 1 } |
| 100 | r_ound! := { m -> m l:l_earn l:g_ame! m } | {\mathrm{\underline{r}ound}{!}}\ {\leftarrow}\ {\{}\ {\mathrm{m}}\ {\to}\ {\mathrm{m}}\ {{}^{\mathrm{l}}\mathrm{\underline{l}earn}}\ {{}^{\mathrm{l}}\mathrm{\underline{g}ame}{!}}\ {\mathrm{m}}\ {\}} | round! ← { m → m llearn lgame! m } |
| 101 | l_oop! := { n m -> | {\mathrm{\underline{l}oop}{!}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\mathrm{m}}\ {\to} | loop! ← { n m → |
| 102 | k := 250 m_in n | \ \ {\mathrm{k}}\ {\leftarrow}\ {250}\ {\mathrm{\underline{m}in}}\ {\mathrm{n}} | k ← 250 min n |
| 103 | m := k 'r_ound! p_ower m | \ \ {\mathrm{m}}\ {\leftarrow}\ {\mathrm{k}}\ {\text{'}}{\mathrm{\underline{r}ound}{!}}\ {\mathrm{\underline{p}ower}}\ {\mathrm{m}} | m ← k ’round! power m |
| 104 | shown := p_rint! (n - k) c_at t_ally 1 s_elect m | \ \ {\mathrm{shown}}\ {\leftarrow}\ {\mathrm{\underline{p}rint}{!}}\ {(}{\mathrm{n}}\ {-}\ {\mathrm{k}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{t}ally}}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{m}} | shown ← print! (n − k) cat tally 1 select m |
| 105 | n = k ? m; (n - k) l_oop! m | \ \ {\mathrm{n}}\ {=}\ {\mathrm{k}}\ {?}\ {\mathrm{m}}{\diamond}\ {(}{\mathrm{n}}\ {-}\ {\mathrm{k}}{)}\ {\mathrm{\underline{l}oop}{!}}\ {\mathrm{m}} | n = k ? m⋄ (n − k) loop! m |
| 106 | } | {\}} | } |
| 107 | l:t_rain! := { n m -> | {{}^{\mathrm{l}}\mathrm{\underline{t}rain}{!}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\mathrm{m}}\ {\to} | ltrain! ← { n m → |
| 108 | shown := p_rint! "games to go, positions known:" | \ \ {\mathrm{shown}}\ {\leftarrow}\ {\mathrm{\underline{p}rint}{!}}\ {\text{"games to go, positions known:"}} | shown ← print! "games to go, positions known:" |
| 109 | n l_oop! m | \ \ {\mathrm{n}}\ {\mathrm{\underline{l}oop}{!}}\ {\mathrm{m}} | n loop! m |
| 110 | } | {\}} | } |
| 115 | t_urn! := { m side s -> | {\mathrm{\underline{t}urn}{!}}\ {\leftarrow}\ {\{}\ {\mathrm{m}}\ {\mathrm{side}}\ {\mathrm{s}}\ {\to} | turn! ← { m side s → |
| 116 | p := w_here s = 0 | \ \ {\mathrm{p}}\ {\leftarrow}\ {\mathrm{\underline{w}here}}\ {\mathrm{s}}\ {=}\ {0} | p ← where s = 0 |
| 117 | (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 |
| 118 | } | {\}} | } |
| 119 | v_ersus! := { m side s -> | {\mathrm{\underline{v}ersus}{!}}\ {\leftarrow}\ {\{}\ {\mathrm{m}}\ {\mathrm{side}}\ {\mathrm{s}}\ {\to} | versus! ← { m side s → |
| 120 | s := s l:a_fter ((m t_urn! side)_ s) | \ \ {\mathrm{s}}\ {\leftarrow}\ {\mathrm{s}}\ {{}^{\mathrm{l}}\mathrm{\underline{a}fter}}\ {(}{(}{\mathrm{m}}\ {\mathrm{\underline{t}urn}{!}}\ {\mathrm{side}}{)}{\_}\ {\mathrm{s}}{)} | s ← s lafter ((m turn! side)_ s) |
| 121 | w := l:o_utcome s | \ \ {\mathrm{w}}\ {\leftarrow}\ {{}^{\mathrm{l}}\mathrm{\underline{o}utcome}}\ {\mathrm{s}} | w ← loutcome s |
| 122 | w = 0 ? ((m v_ersus! side)_ s); w | \ \ {\mathrm{w}}\ {=}\ {0}\ {?}\ {(}{(}{\mathrm{m}}\ {\mathrm{\underline{v}ersus}{!}}\ {\mathrm{side}}{)}{\_}\ {\mathrm{s}}{)}{\diamond}\ {\mathrm{w}} | w = 0 ? ((m versus! side)_ s)⋄ w |
| 123 | } | {\}} | } |
| 124 | c_ount! := { m side n -> | {\mathrm{\underline{c}ount}{!}}\ {\leftarrow}\ {\{}\ {\mathrm{m}}\ {\mathrm{side}}\ {\mathrm{n}}\ {\to} | count! ← { m side n → |
| 125 | w := '{ i -> ((m v_ersus! side)_ 9 r_eshape 0) } e_ach r_ange n | \ \ {\mathrm{w}}\ {\leftarrow}\ {\text{'}}{\{}\ {\mathrm{i}}\ {\to}\ {(}{(}{\mathrm{m}}\ {\mathrm{\underline{v}ersus}{!}}\ {\mathrm{side}}{)}{\_}\ {9}\ {\mathrm{\underline{r}eshape}}\ {0}{)}\ {\}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{\underline{r}ange}}\ {\mathrm{n}} | w ← ’{ i → ((m versus! side)_ 9 reshape 0) } each range n |
| 126 | '+ 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 |
| 127 | } | {\}} | } |
| 130 | l:t_rial! := { n m -> 2 3 r_eshape ((m c_ount! 1)_ n) c_at (m c_ount! -1)_ n } | {{}^{\mathrm{l}}\mathrm{\underline{t}rial}{!}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\mathrm{m}}\ {\to}\ {2}\ {3}\ {\mathrm{\underline{r}eshape}}\ {(}{(}{\mathrm{m}}\ {\mathrm{\underline{c}ount}{!}}\ {1}{)}{\_}\ {\mathrm{n}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{m}}\ {\mathrm{\underline{c}ount}{!}}\ {-1}{)}{\_}\ {\mathrm{n}}\ {\}} | ltrial! ← { n m → 2 3 reshape ((m count! 1)_ n) cat (m count! −1)_ n } |
| 134 | g_reedy := { m g -> | {\mathrm{\underline{g}reedy}}\ {\leftarrow}\ {\{}\ {\mathrm{m}}\ {\mathrm{g}}\ {\to} | greedy ← { m g → |
| 135 | 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 |
| 136 | g := g c_at 1 9 r_eshape s l:a_fter m l:c_hoose s | \ \ {\mathrm{g}}\ {\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}} | g ← g cat 1 9 reshape s lafter m lchoose s |
| 137 | 0 = l:o_utcome (t_ally g) s_elect g ? m g_reedy g; g | \ \ {0}\ {=}\ {{}^{\mathrm{l}}\mathrm{\underline{o}utcome}}\ {(}{\mathrm{\underline{t}ally}}\ {\mathrm{g}}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{g}}\ {?}\ {\mathrm{m}}\ {\mathrm{\underline{g}reedy}}\ {\mathrm{g}}{\diamond}\ {\mathrm{g}} | 0 = loutcome (tally g) select g ? m greedy g⋄ g |
| 138 | } | {\}} | } |
| 139 | l:b_est := { m -> m g_reedy 1 9 r_eshape 0 } | {{}^{\mathrm{l}}\mathrm{\underline{b}est}}\ {\leftarrow}\ {\{}\ {\mathrm{m}}\ {\to}\ {\mathrm{m}}\ {\mathrm{\underline{g}reedy}}\ {1}\ {9}\ {\mathrm{\underline{r}eshape}}\ {0}\ {\}} | lbest ← { m → m greedy 1 9 reshape 0 } |
| 142 | l:b_oards := { g -> | {{}^{\mathrm{l}}\mathrm{\underline{b}oards}}\ {\leftarrow}\ {\{}\ {\mathrm{g}}\ {\to} | lboards ← { g → |
| 143 | k := t_ally g | \ \ {\mathrm{k}}\ {\leftarrow}\ {\mathrm{\underline{t}ally}}\ {\mathrm{g}} | k ← tally g |
| 144 | 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 |
| 145 | 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 |
| 146 | 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 |
| 147 | (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 " |
| 148 | } | {\}} | } |
| 154 | o_pening! := { @ -> 2 9 r_eshape (9 r_eshape 0) c_at 1 * (r_ange 9) = r_oll! 9 } | {\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}\ {\}} | opening! ← { @ → 2 9 reshape (9 reshape 0) cat 1 × (range 9) = roll! 9 } |
| 155 | f_inal := { g -> l:o_utcome (t_ally g) s_elect g } | {\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}}\ {\}} | final ← { g → loutcome (tally g) select g } |
| 156 | l:s_elfTrial! := { n m -> | {{}^{\mathrm{l}}\mathrm{\underline{s}elfTrial}{!}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\mathrm{m}}\ {\to} | lselfTrial! ← { n m → |
| 157 | w := '{ i -> f_inal m g_reedy o_pening! @ } e_ach r_ange n | \ \ {\mathrm{w}}\ {\leftarrow}\ {\text{'}}{\{}\ {\mathrm{i}}\ {\to}\ {\mathrm{\underline{f}inal}}\ {\mathrm{m}}\ {\mathrm{\underline{g}reedy}}\ {\mathrm{\underline{o}pening}{!}}\ {@}\ {\}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{\underline{r}ange}}\ {\mathrm{n}} | w ← ’{ i → final m greedy opening! @ } each range n |
| 158 | '+ 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 |
| 159 | } | {\}} | } |
| 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 | watched := []S_HOW []G_RID (4 r_eshape 1) u:p_lay 4 u:h_anoi 1 3 2 | {\mathrm{watched}}\ {\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} | watched ← □SHOW □GRID (4 reshape 1) uplay 4 uhanoi 1 3 2 |
| 348 | a := 4 4 r_eshape 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 | {\mathrm{a}}\ {\leftarrow}\ {4}\ {4}\ {\mathrm{\underline{r}eshape}}\ {0}\ {1}\ {0}\ {0}\ \ {0}\ {0}\ {1}\ {0}\ \ {0}\ {0}\ {0}\ {1}\ \ {0}\ {0}\ {0}\ {0} | a ← 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 a | {{}^{\mathrm{u}}\mathrm{\underline{c}losure}}\ {\mathrm{a}} | uclosure a |
| 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 | watched := []S_HOW []G_RID g u:w_arshallSteps 1 | {\mathrm{watched}}\ {\leftarrow}\ {\square \mathrm{\underline{S}HOW}}\ {\square \mathrm{\underline{G}RID}}\ {\mathrm{g}}\ {{}^{\mathrm{u}}\mathrm{\underline{w}arshallSteps}}\ {1} | watched ← □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 | shown := []S_HOW []G_RID tall | {\mathrm{shown}}\ {\leftarrow}\ {\square \mathrm{\underline{S}HOW}}\ {\square \mathrm{\underline{G}RID}}\ {\mathrm{tall}} | shown ← □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 | n := 1 s_elect 1 d_rop s_hape arrowhead | {\mathrm{n}}\ {\leftarrow}\ {1}\ {\mathrm{\underline{s}elect}}\ {1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{\underline{s}hape}}\ {\mathrm{arrowhead}} | n ← 1 select 1 drop shape arrowhead |
| 759 | u:u_pTo := { k -> ((f_loor k * n / 24) m_in r_ange n) s_elect_2 arrowhead } | {{}^{\mathrm{u}}\mathrm{\underline{u}pTo}}\ {\leftarrow}\ {\{}\ {\mathrm{k}}\ {\to}\ {(}{(}{\mathrm{\underline{f}loor}}\ {\mathrm{k}}\ {\times}\ {\mathrm{n}}\ {\div}\ {24}{)}\ {\mathrm{\underline{m}in}}\ {\mathrm{\underline{r}ange}}\ {\mathrm{n}}{)}\ {{\mathrm{\underline{s}elect}}_{2}}\ {\mathrm{arrowhead}}\ {\}} | uupTo ← { k → ((floor k × n ÷ 24) min range n) 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 | n | {\mathrm{n}} | n |
| 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 |
| 38 | u:h_anoi := { n pegs -> | {{}^{\mathrm{u}}\mathrm{\underline{h}anoi}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\mathrm{pegs}}\ {\to} | uhanoi ← { n pegs → |
| 39 | n = 0 ? 0 2 r_eshape 0 | \ \ {\mathrm{n}}\ {=}\ {0}\ {?}\ {0}\ {2}\ {\mathrm{\underline{r}eshape}}\ {0} | n = 0 ? 0 2 reshape 0 |
| 40 | 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 |
| 41 | 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 |
| 42 | 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 |
| 43 | } | {\}} | } |
| 44 | 3 u:h_anoi 1 3 2 | {3}\ {{}^{\mathrm{u}}\mathrm{\underline{h}anoi}}\ {1}\ {3}\ {2} | 3 uhanoi 1 3 2 |
| 79 | '{ t_ally _r u:h_anoi 1 3 2 } e_ach r_ange 10 | {\text{'}}{\{}\ {\mathrm{\underline{t}ally}}\ {\_\mathrm{r}}\ {{}^{\mathrm{u}}\mathrm{\underline{h}anoi}}\ {1}\ {3}\ {2}\ {\}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{\underline{r}ange}}\ {10} | ’{ tally _r uhanoi 1 3 2 } each range 10 |
| 105 | u:m_v := { from to -> 1 2 r_eshape from c_at to } | {{}^{\mathrm{u}}\mathrm{\underline{m}v}}\ {\leftarrow}\ {\{}\ {\mathrm{from}}\ {\mathrm{to}}\ {\to}\ {1}\ {2}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{from}}\ {\mathrm{\underline{c}at}}\ {\mathrm{to}}\ {\}} | umv ← { from to → 1 2 reshape from cat to } |
| 106 | u:h_ := { n from to via -> | {{}^{\mathrm{u}}\mathrm{\underline{h}}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\mathrm{from}}\ {\mathrm{to}}\ {\mathrm{via}}\ {\to} | uh ← { n from to via → |
| 107 | n = 0 ? 0 2 r_eshape 0 | \ \ {\mathrm{n}}\ {=}\ {0}\ {?}\ {0}\ {2}\ {\mathrm{\underline{r}eshape}}\ {0} | n = 0 ? 0 2 reshape 0 |
| 108 | a := (((n - 1) u:h_ from)_ via)_ to | \ \ {\mathrm{a}}\ {\leftarrow}\ {(}{(}{(}{\mathrm{n}}\ {-}\ {1}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{h}}}\ {\mathrm{from}}{)}{\_}\ {\mathrm{via}}{)}{\_}\ {\mathrm{to}} | a ← (((n − 1) uh from)_ via)_ to |
| 109 | b := (((n - 1) u:h_ via)_ to)_ from | \ \ {\mathrm{b}}\ {\leftarrow}\ {(}{(}{(}{\mathrm{n}}\ {-}\ {1}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{h}}}\ {\mathrm{via}}{)}{\_}\ {\mathrm{to}}{)}{\_}\ {\mathrm{from}} | b ← (((n − 1) uh via)_ to)_ from |
| 110 | a c_at (from u:m_v to) c_at b | \ \ {\mathrm{a}}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{from}}\ {{}^{\mathrm{u}}\mathrm{\underline{m}v}}\ {\mathrm{to}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{b}} | a cat (from umv to) cat b |
| 111 | } | {\}} | } |
| 112 | ((3 u:h_ 1)_ 3)_ 2 | {(}{(}{3}\ {{}^{\mathrm{u}}\mathrm{\underline{h}}}\ {1}{)}{\_}\ {3}{)}{\_}\ {2} | ((3 uh 1)_ 3)_ 2 |
| 141 | "c:" u_se< "Combinators" | {\text{"c:"}}\ {\mathrm{\underline{u}se}{<}}\ {\text{"Combinators"}} | "c:" use< "Combinators" |
| 142 | u:h_c := { n from to via -> | {{}^{\mathrm{u}}\mathrm{\underline{h}c}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\mathrm{from}}\ {\mathrm{to}}\ {\mathrm{via}}\ {\to} | uhc ← { n from to via → |
| 143 | n = 0 ? 0 2 r_eshape 0 | \ \ {\mathrm{n}}\ {=}\ {0}\ {?}\ {0}\ {2}\ {\mathrm{\underline{r}eshape}}\ {0} | n = 0 ? 0 2 reshape 0 |
| 144 | m_ove := (n - 1) u:h_c from | \ \ {\mathrm{\underline{m}ove}}\ {\leftarrow}\ {(}{\mathrm{n}}\ {-}\ {1}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{h}c}}\ {\mathrm{from}} | move ← (n − 1) uhc from |
| 145 | b_ack := (n - 1) u:h_c via | \ \ {\mathrm{\underline{b}ack}}\ {\leftarrow}\ {(}{\mathrm{n}}\ {-}\ {1}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{h}c}}\ {\mathrm{via}} | back ← (n − 1) uhc via |
| 146 | (to 'm_ove c:C_ via) c_at (from u:m_v to) c_at to b_ack from | \ \ {(}{\mathrm{to}}\ {\text{'}}{\mathrm{\underline{m}ove}}\ {{}^{\mathrm{c}}\mathrm{\underline{C}}}\ {\mathrm{via}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{from}}\ {{}^{\mathrm{u}}\mathrm{\underline{m}v}}\ {\mathrm{to}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{to}}\ {\mathrm{\underline{b}ack}}\ {\mathrm{from}} | (to ’move cC via) cat (from umv to) cat to back from |
| 147 | } | {\}} | } |
| 148 | (((6 u:h_c 1)_ 3)_ 2) m_atch 6 u:h_anoi 1 3 2 | {(}{(}{(}{6}\ {{}^{\mathrm{u}}\mathrm{\underline{h}c}}\ {1}{)}{\_}\ {3}{)}{\_}\ {2}{)}\ {\mathrm{\underline{m}atch}}\ {6}\ {{}^{\mathrm{u}}\mathrm{\underline{h}anoi}}\ {1}\ {3}\ {2} | (((6 uhc 1)_ 3)_ 2) match 6 uhanoi 1 3 2 |
| 182 | k := r_ange 7 | {\mathrm{k}}\ {\leftarrow}\ {\mathrm{\underline{r}ange}}\ {7} | k ← range 7 |
| 183 | 0 = k 'm_od t_able 2 ^ r_ange 3 | {0}\ {=}\ {\mathrm{k}}\ {\text{'}}{\mathrm{\underline{m}od}}\ {\mathrm{\underline{t}able}}\ {2}\ {\mathbin{\hat{}}}\ {\mathrm{\underline{r}ange}}\ {3} | 0 = k ’mod table 2 ^ range 3 |
| 184 | '+ r_/_2 0 = k 'm_od t_able 2 ^ r_ange 3 | {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{2}}\ {0}\ {=}\ {\mathrm{k}}\ {\text{'}}{\mathrm{\underline{m}od}}\ {\mathrm{\underline{t}able}}\ {2}\ {\mathbin{\hat{}}}\ {\mathrm{\underline{r}ange}}\ {3} | ’+ r/2 0 = k ’mod table 2 ^ range 3 |
| 222 | u:m_oves := { n -> | {{}^{\mathrm{u}}\mathrm{\underline{m}oves}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\to} | umoves ← { n → |
| 223 | k := r_ange (2 ^ n) - 1 | \ \ {\mathrm{k}}\ {\leftarrow}\ {\mathrm{\underline{r}ange}}\ {(}{2}\ {\mathbin{\hat{}}}\ {\mathrm{n}}{)}\ {-}\ {1} | k ← range (2 ^ n) − 1 |
| 224 | d := 1 + '+ r_/_2 0 = k 'm_od t_able 2 ^ r_ange n | \ \ {\mathrm{d}}\ {\leftarrow}\ {1}\ {+}\ {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{2}}\ {0}\ {=}\ {\mathrm{k}}\ {\text{'}}{\mathrm{\underline{m}od}}\ {\mathrm{\underline{t}able}}\ {2}\ {\mathbin{\hat{}}}\ {\mathrm{\underline{r}ange}}\ {\mathrm{n}} | d ← 1 + ’+ r/2 0 = k ’mod table 2 ^ range n |
| 225 | m := k d_iv 2 ^ d | \ \ {\mathrm{m}}\ {\leftarrow}\ {\mathrm{k}}\ {\mathrm{\underline{d}iv}}\ {2}\ {\mathbin{\hat{}}}\ {\mathrm{d}} | m ← k div 2 ^ d |
| 226 | s := 1 + 0 = (n - d) m_od 2 | \ \ {\mathrm{s}}\ {\leftarrow}\ {1}\ {+}\ {0}\ {=}\ {(}{\mathrm{n}}\ {-}\ {\mathrm{d}}{)}\ {\mathrm{\underline{m}od}}\ {2} | s ← 1 + 0 = (n − d) mod 2 |
| 227 | from := 1 + (s * m) m_od 3 | \ \ {\mathrm{from}}\ {\leftarrow}\ {1}\ {+}\ {(}{\mathrm{s}}\ {\times}\ {\mathrm{m}}{)}\ {\mathrm{\underline{m}od}}\ {3} | from ← 1 + (s × m) mod 3 |
| 228 | to := 1 + (s * m + 1) m_od 3 | \ \ {\mathrm{to}}\ {\leftarrow}\ {1}\ {+}\ {(}{\mathrm{s}}\ {\times}\ {\mathrm{m}}\ {+}\ {1}{)}\ {\mathrm{\underline{m}od}}\ {3} | to ← 1 + (s × m + 1) mod 3 |
| 229 | o_\ (2 c_at t_ally from) r_eshape from c_at to | \ \ {\mathrm{\underline{o}}{\backslash}}\ {(}{2}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{t}ally}}\ {\mathrm{from}}{)}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{from}}\ {\mathrm{\underline{c}at}}\ {\mathrm{to}} | o\ (2 cat tally from) reshape from cat to |
| 230 | } | {\}} | } |
| 231 | u:m_oves 3 | {{}^{\mathrm{u}}\mathrm{\underline{m}oves}}\ {3} | umoves 3 |
| 251 | '{ (u:m_oves _r) m_atch _r u:h_anoi 1 3 2 } e_ach r_ange 10 | {\text{'}}{\{}\ {(}{{}^{\mathrm{u}}\mathrm{\underline{m}oves}}\ {\_\mathrm{r}}{)}\ {\mathrm{\underline{m}atch}}\ {\_\mathrm{r}}\ {{}^{\mathrm{u}}\mathrm{\underline{h}anoi}}\ {1}\ {3}\ {2}\ {\}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{\underline{r}ange}}\ {10} | ’{ (umoves _r) match _r uhanoi 1 3 2 } each range 10 |
| 291 | u:m_ove := { p m -> | {{}^{\mathrm{u}}\mathrm{\underline{m}ove}}\ {\leftarrow}\ {\{}\ {\mathrm{p}}\ {\mathrm{m}}\ {\to} | umove ← { p m → |
| 292 | from := 1 s_elect m | \ \ {\mathrm{from}}\ {\leftarrow}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{m}} | from ← 1 select m |
| 293 | disk := p i_ndexOf from | \ \ {\mathrm{disk}}\ {\leftarrow}\ {\mathrm{p}}\ {\mathrm{\underline{i}ndexOf}}\ {\mathrm{from}} | disk ← p indexOf from |
| 294 | 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 |
| 295 | } | {\}} | } |
| 296 | u:s_lots := { p -> | {{}^{\mathrm{u}}\mathrm{\underline{s}lots}}\ {\leftarrow}\ {\{}\ {\mathrm{p}}\ {\to} | uslots ← { p → |
| 297 | n := t_ally p | \ \ {\mathrm{n}}\ {\leftarrow}\ {\mathrm{\underline{t}ally}}\ {\mathrm{p}} | n ← tally p |
| 298 | (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 |
| 299 | } | {\}} | } |
| 300 | u:p_icture := { p -> | {{}^{\mathrm{u}}\mathrm{\underline{p}icture}}\ {\leftarrow}\ {\{}\ {\mathrm{p}}\ {\to} | upicture ← { p → |
| 301 | n := t_ally p | \ \ {\mathrm{n}}\ {\leftarrow}\ {\mathrm{\underline{t}ally}}\ {\mathrm{p}} | n ← tally p |
| 302 | w := 1 + 2 * n | \ \ {\mathrm{w}}\ {\leftarrow}\ {1}\ {+}\ {2}\ {\times}\ {\mathrm{n}} | w ← 1 + 2 × n |
| 303 | 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 |
| 304 | (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 |
| 305 | } | {\}} | } |
| 306 | 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 } |
| 307 | u:p_lay := { p moves -> | {{}^{\mathrm{u}}\mathrm{\underline{p}lay}}\ {\leftarrow}\ {\{}\ {\mathrm{p}}\ {\mathrm{moves}}\ {\to} | uplay ← { p moves → |
| 308 | 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 |
| 309 | 0 = t_ally moves ? frame | \ \ {0}\ {=}\ {\mathrm{\underline{t}ally}}\ {\mathrm{moves}}\ {?}\ {\mathrm{frame}} | 0 = tally moves ? frame |
| 310 | 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 |
| 311 | } | {\}} | } |
| 321 | watched := []S_HOW []G_RID (4 r_eshape 1) u:p_lay u:m_oves 4 | {\mathrm{watched}}\ {\leftarrow}\ {\square \mathrm{\underline{S}HOW}}\ {\square \mathrm{\underline{G}RID}}\ {(}{4}\ {\mathrm{\underline{r}eshape}}\ {1}{)}\ {{}^{\mathrm{u}}\mathrm{\underline{p}lay}}\ {{}^{\mathrm{u}}\mathrm{\underline{m}oves}}\ {4} | watched ← □SHOW □GRID (4 reshape 1) uplay umoves 4 |
| 42 | "st:" u_se< "Stone" | {\text{"st:"}}\ {\mathrm{\underline{u}se}{<}}\ {\text{"Stone"}} | "st:" use< "Stone" |
| 43 | "v:" u_se< "Svg" | {\text{"v:"}}\ {\mathrm{\underline{u}se}{<}}\ {\text{"Svg"}} | "v:" use< "Svg" |
| 44 | "g:" u_se< "Geometry3D" | {\text{"g:"}}\ {\mathrm{\underline{u}se}{<}}\ {\text{"Geometry3D"}} | "g:" use< "Geometry3D" |
| 45 | s_hape 1 st:r_ing 0.0 0.0 | {\mathrm{\underline{s}hape}}\ {1}\ {{}^{\mathrm{st}}\mathrm{\underline{r}ing}}\ {0.0}\ {0.0} | shape 1 string 0.0 0.0 |
| 46 | s_hape (1 st:r_ing 0.0 0.0) c_at -1 st:r_ing 0.0 0.0 | {\mathrm{\underline{s}hape}}\ {(}{1}\ {{}^{\mathrm{st}}\mathrm{\underline{r}ing}}\ {0.0}\ {0.0}{)}\ {\mathrm{\underline{c}at}}\ {-1}\ {{}^{\mathrm{st}}\mathrm{\underline{r}ing}}\ {0.0}\ {0.0} | shape (1 string 0.0 0.0) cat −1 string 0.0 0.0 |
| 63 | f_loor 0.5 + st:s_creen 1 s_elect 1 st:r_ing 0.0 0.0 | {\mathrm{\underline{f}loor}}\ {0.5}\ {+}\ {{}^{\mathrm{st}}\mathrm{\underline{s}creen}}\ {1}\ {\mathrm{\underline{s}elect}}\ {1}\ {{}^{\mathrm{st}}\mathrm{\underline{r}ing}}\ {0.0}\ {0.0} | floor 0.5 + stscreen 1 select 1 string 0.0 0.0 |
| 97 | u:f_ace := { title code -> (e_nclose "#fdfcfa") c_at (e_nclose v:e_scape title) c_at e_nclose "#1d4ed8" v:s_pan code } | {{}^{\mathrm{u}}\mathrm{\underline{f}ace}}\ {\leftarrow}\ {\{}\ {\mathrm{title}}\ {\mathrm{code}}\ {\to}\ {(}{\mathrm{\underline{e}nclose}}\ {\text{"\#fdfcfa"}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{e}nclose}}\ {{}^{\mathrm{v}}\mathrm{\underline{e}scape}}\ {\mathrm{title}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{e}nclose}}\ {\text{"\#1d4ed8"}}\ {{}^{\mathrm{v}}\mathrm{\underline{s}pan}}\ {\mathrm{code}}\ {\}} | uface ← { title code → (enclose "#fdfcfa") cat (enclose vescape title) cat enclose "#1d4ed8" vspan code } |
| 98 | names := (e_nclose "front") c_at (e_nclose "right") c_at (e_nclose "back") c_at (e_nclose "left") c_at (e_nclose "lid") c_at e_nclose "floor" | {\mathrm{names}}\ {\leftarrow}\ {(}{\mathrm{\underline{e}nclose}}\ {\text{"front"}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{e}nclose}}\ {\text{"right"}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{e}nclose}}\ {\text{"back"}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{e}nclose}}\ {\text{"left"}}{)}\ {\mathrm{\underline{c}at}}\ {(}{\mathrm{\underline{e}nclose}}\ {\text{"lid"}}{)}\ {\mathrm{\underline{c}at}}\ {\mathrm{\underline{e}nclose}}\ {\text{"floor"}} | names ← (enclose "front") cat (enclose "right") cat (enclose "back") cat (enclose "left") cat (enclose "lid") cat enclose "floor" |
| 99 | u:o_ne := { k halves -> | {{}^{\mathrm{u}}\mathrm{\underline{o}ne}}\ {\leftarrow}\ {\{}\ {\mathrm{k}}\ {\mathrm{halves}}\ {\to} | uone ← { k halves → |
| 100 | half := "k <= 6" i_f< "\"top\"; \"bottom\"" | \ \ {\mathrm{half}}\ {\leftarrow}\ {\text{"k <= 6"}}\ {\mathrm{\underline{i}f}{<}}\ {\text{"\textbackslash{}"top\textbackslash{}"; \textbackslash{}"bottom\textbackslash{}""}} | half ← "k <= 6" if< "\"top\"; \"bottom\"" |
| 101 | side := d_isclose (1 + (k - 1) m_od 6) s_elect names | \ \ {\mathrm{side}}\ {\leftarrow}\ {\mathrm{\underline{d}isclose}}\ {(}{1}\ {+}\ {(}{\mathrm{k}}\ {-}\ {1}{)}\ {\mathrm{\underline{m}od}}\ {6}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{names}} | side ← disclose (1 + (k − 1) mod 6) select names |
| 102 | (half u:f_ace side) st:p_anel k s_elect halves | \ \ {(}{\mathrm{half}}\ {{}^{\mathrm{u}}\mathrm{\underline{f}ace}}\ {\mathrm{side}}{)}\ {{}^{\mathrm{st}}\mathrm{\underline{p}anel}}\ {\mathrm{k}}\ {\mathrm{\underline{s}elect}}\ {\mathrm{halves}} | (half uface side) stpanel k select halves |
| 103 | } | {\}} | } |
| 104 | u:p_anels := { halves -> d_isclose '{ x y -> e_nclose (d_isclose x) c_at d_isclose y } r_/ '{ k -> k u:o_ne halves } m_ap st:p_ainting halves } | {{}^{\mathrm{u}}\mathrm{\underline{p}anels}}\ {\leftarrow}\ {\{}\ {\mathrm{halves}}\ {\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}}{/}}\ {\text{'}}{\{}\ {\mathrm{k}}\ {\to}\ {\mathrm{k}}\ {{}^{\mathrm{u}}\mathrm{\underline{o}ne}}\ {\mathrm{halves}}\ {\}}\ {\mathrm{\underline{m}ap}}\ {{}^{\mathrm{st}}\mathrm{\underline{p}ainting}}\ {\mathrm{halves}}\ {\}} | upanels ← { halves → disclose ’{ x y → enclose (disclose x) cat disclose y } r/ ’{ k → k uone halves } map stpainting halves } |
| 105 | u:p_icture := { halves -> (st:size c_at st:size) v:p_icture u:p_anels halves } | {{}^{\mathrm{u}}\mathrm{\underline{p}icture}}\ {\leftarrow}\ {\{}\ {\mathrm{halves}}\ {\to}\ {(}{{}^{\mathrm{st}}\mathrm{size}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{st}}\mathrm{size}}{)}\ {{}^{\mathrm{v}}\mathrm{\underline{p}icture}}\ {{}^{\mathrm{u}}\mathrm{\underline{p}anels}}\ {\mathrm{halves}}\ {\}} | upicture ← { halves → (stsize cat stsize) vpicture upanels halves } |
| 106 | rest := (1 st:r_ing 0.0 0.0) c_at -1 st:r_ing 0.0 0.0 | {\mathrm{rest}}\ {\leftarrow}\ {(}{1}\ {{}^{\mathrm{st}}\mathrm{\underline{r}ing}}\ {0.0}\ {0.0}{)}\ {\mathrm{\underline{c}at}}\ {-1}\ {{}^{\mathrm{st}}\mathrm{\underline{r}ing}}\ {0.0}\ {0.0} | rest ← (1 string 0.0 0.0) cat −1 string 0.0 0.0 |
| 107 | t_ally u:p_icture rest | {\mathrm{\underline{t}ally}}\ {{}^{\mathrm{u}}\mathrm{\underline{p}icture}}\ {\mathrm{rest}} | tally upicture rest |
| 118 | shown := []S_HOW u:p_icture rest | {\mathrm{shown}}\ {\leftarrow}\ {\square \mathrm{\underline{S}HOW}}\ {{}^{\mathrm{u}}\mathrm{\underline{p}icture}}\ {\mathrm{rest}} | shown ← □SHOW upicture rest |
| 143 | turned := (1 st:r_ing 45.0 0.0) c_at -1 st:r_ing 0.0 0.0 | {\mathrm{turned}}\ {\leftarrow}\ {(}{1}\ {{}^{\mathrm{st}}\mathrm{\underline{r}ing}}\ {45.0}\ {0.0}{)}\ {\mathrm{\underline{c}at}}\ {-1}\ {{}^{\mathrm{st}}\mathrm{\underline{r}ing}}\ {0.0}\ {0.0} | turned ← (1 string 45.0 0.0) cat −1 string 0.0 0.0 |
| 144 | shown := []S_HOW u:p_icture turned | {\mathrm{shown}}\ {\leftarrow}\ {\square \mathrm{\underline{S}HOW}}\ {{}^{\mathrm{u}}\mathrm{\underline{p}icture}}\ {\mathrm{turned}} | shown ← □SHOW upicture turned |
| 160 | rolled := (1 st:r_ing 0.0 45.0) c_at -1 st:r_ing 0.0 45.0 | {\mathrm{rolled}}\ {\leftarrow}\ {(}{1}\ {{}^{\mathrm{st}}\mathrm{\underline{r}ing}}\ {0.0}\ {45.0}{)}\ {\mathrm{\underline{c}at}}\ {-1}\ {{}^{\mathrm{st}}\mathrm{\underline{r}ing}}\ {0.0}\ {45.0} | rolled ← (1 string 0.0 45.0) cat −1 string 0.0 45.0 |
| 161 | shown := []S_HOW u:p_icture rolled | {\mathrm{shown}}\ {\leftarrow}\ {\square \mathrm{\underline{S}HOW}}\ {{}^{\mathrm{u}}\mathrm{\underline{p}icture}}\ {\mathrm{rolled}} | shown ← □SHOW upicture rolled |
| 185 | angles := 0.0 30.0 89.0 90.0 135.0 180.0 -45.0 | {\mathrm{angles}}\ {\leftarrow}\ {0.0}\ {30.0}\ {89.0}\ {90.0}\ {135.0}\ {180.0}\ {-45.0} | angles ← 0.0 30.0 89.0 90.0 135.0 180.0 −45.0 |
| 186 | 'st:p_art e_ach angles | {\text{'}}{{}^{\mathrm{st}}\mathrm{\underline{p}art}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{angles}} | ’stpart each angles |
| 187 | 'st:b_ase e_ach angles | {\text{'}}{{}^{\mathrm{st}}\mathrm{\underline{b}ase}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{angles}} | ’stbase each angles |
| 212 | "cm:" u_se< "Comparison" | {\text{"cm:"}}\ {\mathrm{\underline{u}se}{<}}\ {\text{"Comparison"}} | "cm:" use< "Comparison" |
| 213 | s0 := 31 cm:s_tart 7 | {\mathrm{s0}}\ {\leftarrow}\ {31}\ {{}^{\mathrm{cm}}\mathrm{\underline{s}tart}}\ {7} | s0 ← 31 cmstart 7 |
| 214 | s0 | {\mathrm{s0}} | s0 |
| 240 | chosen := (cm:TOP c_at 7.0) cm:c_hoose s0 | {\mathrm{chosen}}\ {\leftarrow}\ {(}{{}^{\mathrm{cm}}\mathrm{TOP}}\ {\mathrm{\underline{c}at}}\ {7.0}{)}\ {{}^{\mathrm{cm}}\mathrm{\underline{c}hoose}}\ {\mathrm{s0}} | chosen ← (cmTOP cat 7.0) cmchoose s0 |
| 241 | cm:TOP cm:c_urrent chosen | {{}^{\mathrm{cm}}\mathrm{TOP}}\ {{}^{\mathrm{cm}}\mathrm{\underline{c}urrent}}\ {\mathrm{chosen}} | cmTOP cmcurrent chosen |
| 242 | (cm:TOP c_at cm:STEPS) cm:a_t chosen | {(}{{}^{\mathrm{cm}}\mathrm{TOP}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{cm}}\mathrm{STEPS}}{)}\ {{}^{\mathrm{cm}}\mathrm{\underline{a}t}}\ {\mathrm{chosen}} | (cmTOP cat cmSTEPS) cmat chosen |
| 243 | (cm:TOP c_at cm:ANGLE) cm:a_t chosen | {(}{{}^{\mathrm{cm}}\mathrm{TOP}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{cm}}\mathrm{ANGLE}}{)}\ {{}^{\mathrm{cm}}\mathrm{\underline{a}t}}\ {\mathrm{chosen}} | (cmTOP cat cmANGLE) cmat chosen |
| 244 | (cm:TOP c_at cm:ANGLE) cm:a_t 0.1 cm:t_ick chosen | {(}{{}^{\mathrm{cm}}\mathrm{TOP}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{cm}}\mathrm{ANGLE}}{)}\ {{}^{\mathrm{cm}}\mathrm{\underline{a}t}}\ {0.1}\ {{}^{\mathrm{cm}}\mathrm{\underline{t}ick}}\ {\mathrm{chosen}} | (cmTOP cat cmANGLE) cmat 0.1 cmtick chosen |
| 245 | (cm:TOP c_at cm:ANGLE) cm:a_t 0.1 cm:t_ick 0.1 cm:t_ick chosen | {(}{{}^{\mathrm{cm}}\mathrm{TOP}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{cm}}\mathrm{ANGLE}}{)}\ {{}^{\mathrm{cm}}\mathrm{\underline{a}t}}\ {0.1}\ {{}^{\mathrm{cm}}\mathrm{\underline{t}ick}}\ {0.1}\ {{}^{\mathrm{cm}}\mathrm{\underline{t}ick}}\ {\mathrm{chosen}} | (cmTOP cat cmANGLE) cmat 0.1 cmtick 0.1 cmtick chosen |
| 246 | (cm:TOP c_at cm:ANGLE) cm:a_t cm:s_ettle chosen | {(}{{}^{\mathrm{cm}}\mathrm{TOP}}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{cm}}\mathrm{ANGLE}}{)}\ {{}^{\mathrm{cm}}\mathrm{\underline{a}t}}\ {{}^{\mathrm{cm}}\mathrm{\underline{s}ettle}}\ {\mathrm{chosen}} | (cmTOP cat cmANGLE) cmat cmsettle chosen |
| 274 | stepped := (cm:BOTTOM c_at 1.0) cm:s_tep (cm:TOP c_at 2.0) cm:c_hoose s0 | {\mathrm{stepped}}\ {\leftarrow}\ {(}{{}^{\mathrm{cm}}\mathrm{BOTTOM}}\ {\mathrm{\underline{c}at}}\ {1.0}{)}\ {{}^{\mathrm{cm}}\mathrm{\underline{s}tep}}\ {(}{{}^{\mathrm{cm}}\mathrm{TOP}}\ {\mathrm{\underline{c}at}}\ {2.0}{)}\ {{}^{\mathrm{cm}}\mathrm{\underline{c}hoose}}\ {\mathrm{s0}} | stepped ← (cmBOTTOM cat 1.0) cmstep (cmTOP cat 2.0) cmchoose s0 |
| 275 | cm:BOTTOM cm:c_urrent stepped | {{}^{\mathrm{cm}}\mathrm{BOTTOM}}\ {{}^{\mathrm{cm}}\mathrm{\underline{c}urrent}}\ {\mathrm{stepped}} | cmBOTTOM cmcurrent stepped |
| 276 | cm:BOTTOM cm:c_urrent (cm:BOTTOM c_at 2.0) cm:c_hoose stepped | {{}^{\mathrm{cm}}\mathrm{BOTTOM}}\ {{}^{\mathrm{cm}}\mathrm{\underline{c}urrent}}\ {(}{{}^{\mathrm{cm}}\mathrm{BOTTOM}}\ {\mathrm{\underline{c}at}}\ {2.0}{)}\ {{}^{\mathrm{cm}}\mathrm{\underline{c}hoose}}\ {\mathrm{stepped}} | cmBOTTOM cmcurrent (cmBOTTOM cat 2.0) cmchoose stepped |
| 304 | u:f_acing := { s -> (cm:IDIOM cm:c_urrent s) c_at (cm:TOP cm:c_urrent s) c_at cm:BOTTOM cm:c_urrent s } | {{}^{\mathrm{u}}\mathrm{\underline{f}acing}}\ {\leftarrow}\ {\{}\ {\mathrm{s}}\ {\to}\ {(}{{}^{\mathrm{cm}}\mathrm{IDIOM}}\ {{}^{\mathrm{cm}}\mathrm{\underline{c}urrent}}\ {\mathrm{s}}{)}\ {\mathrm{\underline{c}at}}\ {(}{{}^{\mathrm{cm}}\mathrm{TOP}}\ {{}^{\mathrm{cm}}\mathrm{\underline{c}urrent}}\ {\mathrm{s}}{)}\ {\mathrm{\underline{c}at}}\ {{}^{\mathrm{cm}}\mathrm{BOTTOM}}\ {{}^{\mathrm{cm}}\mathrm{\underline{c}urrent}}\ {\mathrm{s}}\ {\}} | ufacing ← { s → (cmIDIOM cmcurrent s) cat (cmTOP cmcurrent s) cat cmBOTTOM cmcurrent s } |
| 305 | u:d_well := { s -> cm:dwell cm:t_ick s } | {{}^{\mathrm{u}}\mathrm{\underline{d}well}}\ {\leftarrow}\ {\{}\ {\mathrm{s}}\ {\to}\ {{}^{\mathrm{cm}}\mathrm{dwell}}\ {{}^{\mathrm{cm}}\mathrm{\underline{t}ick}}\ {\mathrm{s}}\ {\}} | udwell ← { s → cmdwell cmtick s } |
| 306 | u:t_our := { n -> u:f_acing cm:s_ettle n 'u:d_well p_ower cm:r_esume s0 } | {{}^{\mathrm{u}}\mathrm{\underline{t}our}}\ {\leftarrow}\ {\{}\ {\mathrm{n}}\ {\to}\ {{}^{\mathrm{u}}\mathrm{\underline{f}acing}}\ {{}^{\mathrm{cm}}\mathrm{\underline{s}ettle}}\ {\mathrm{n}}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{d}well}}\ {\mathrm{\underline{p}ower}}\ {{}^{\mathrm{cm}}\mathrm{\underline{r}esume}}\ {\mathrm{s0}}\ {\}} | utour ← { n → ufacing cmsettle n ’udwell power cmresume s0 } |
| 307 | 8 3 r_eshape d_isclose '{ x y -> e_nclose (d_isclose x) c_at d_isclose y } r_/ 'u:t_our m_ap r_ange 8 | {8}\ {3}\ {\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{u}}\mathrm{\underline{t}our}}\ {\mathrm{\underline{m}ap}}\ {\mathrm{\underline{r}ange}}\ {8} | 8 3 reshape disclose ’{ x y → enclose (disclose x) cat disclose y } r/ ’utour map range 8 |
| 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 ~b -> a } # `~b` is a lazy parameter: evaluated | {{}^{\mathrm{u}}\mathrm{\underline{k}eep}}\ {\leftarrow}\ {\{}\ {\mathrm{a}}\ {\sim}{\mathrm{b}}\ {\to}\ {\mathrm{a}}\ {\}} | ukeep ← { a ∼b → a } |
| 498 | 7 u:k_eep 1 / 0 # only if used, so 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 | {(}{{}^{\mathrm{u}}\mathrm{\underline{s}ub}}\ {100}{)}{\_}\ {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:r_ange 3 1 4 1 5 # largest minus smallest | {{}^{\mathrm{s}}\mathrm{\underline{r}ange}}\ {3}\ {1}\ {4}\ {1}\ {5} | srange 3 1 4 1 5 |
| 1259 | "h:" u_se< "Hello" # a library of your own, found in userlibs/ | {\text{"h:"}}\ {\mathrm{\underline{u}se}{<}}\ {\text{"Hello"}} | "h:" use< "Hello" |
| 1260 | h:h_ello @ # niladic: called with Unit | {{}^{\mathrm{h}}\mathrm{\underline{h}ello}}\ {@} | hhello @ |
| 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 |
| 1364 | 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 } |
| 1365 | 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 |
| 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 |
| 233 | f_loat 3 | {\mathrm{\underline{f}loat}}\ {3} | float 3 |
| 249 | s_in 0 1 | {\mathrm{\underline{s}in}}\ {0}\ {1} | sin 0 1 |
| 260 | c_os p_i @ | {\mathrm{\underline{c}os}}\ {\mathrm{\underline{p}i}}\ {@} | cos pi @ |
| 271 | 4 * a_tan 1 | {4}\ {\times}\ {\mathrm{\underline{a}tan}}\ {1} | 4 × atan 1 |
| 282 | p_i @ | {\mathrm{\underline{p}i}}\ {@} | pi @ |
| 284 | 2 * p_i @ | {2}\ {\times}\ {\mathrm{\underline{p}i}}\ {@} | 2 × pi @ |
| 301 | 3 = 3 | {3}\ {=}\ {3} | 3 = 3 |
| 303 | v = 1 | {\mathrm{v}}\ {=}\ {1} | v = 1 |
| 314 | v != 1 | {\mathrm{v}}\ {\neq}\ {1} | v = 1 |
| 325 | v < 2 | {\mathrm{v}}\ {<}\ {2} | v < 2 |
| 336 | v > 2 | {\mathrm{v}}\ {>}\ {2} | v > 2 |
| 347 | v <= 2 | {\mathrm{v}}\ {\leq}\ {2} | v ≤ 2 |
| 358 | v >= 2 | {\mathrm{v}}\ {\geq}\ {2} | v ≥ 2 |
| 369 | (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 |
| 380 | 1 1 0 & 1 0 0 | {1}\ {1}\ {0}\ {\wedge}\ {1}\ {0}\ {0} | 1 1 0 ∧ 1 0 0 |
| 391 | 1 1 0 | 1 0 0 | {1}\ {1}\ {0}\ {\vee}\ {1}\ {0}\ {0} | 1 1 0 ∨ 1 0 0 |
| 402 | n_ot 1 0 | {\mathrm{\underline{n}ot}}\ {1}\ {0} | not 1 0 |
| 421 | s_hape v | {\mathrm{\underline{s}hape}}\ {\mathrm{v}} | shape v |
| 423 | s_hape M | {\mathrm{\underline{s}hape}}\ {\mathrm{M}} | shape M |
| 436 | t_ally v | {\mathrm{\underline{t}ally}}\ {\mathrm{v}} | tally v |
| 438 | t_ally M | {\mathrm{\underline{t}ally}}\ {\mathrm{M}} | tally M |
| 440 | t_ally_1 M | {{\mathrm{\underline{t}ally}}_{1}}\ {\mathrm{M}} | tally1 M |
| 442 | t_ally_2 M | {{\mathrm{\underline{t}ally}}_{2}}\ {\mathrm{M}} | tally2 M |
| 453 | r_ange 5 | {\mathrm{\underline{r}ange}}\ {5} | range 5 |
| 464 | o_ffsets 5 | {\mathrm{\underline{o}ffsets}}\ {5} | offsets 5 |
| 476 | 2 3 r_eshape r_ange 6 | {2}\ {3}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{\underline{r}ange}}\ {6} | 2 3 reshape range 6 |
| 479 | 2 2 r_eshape 7 | {2}\ {2}\ {\mathrm{\underline{r}eshape}}\ {7} | 2 2 reshape 7 |
| 492 | r_avel M | {\mathrm{\underline{r}avel}}\ {\mathrm{M}} | ravel M |
| 494 | r_avel_2 M | {{\mathrm{\underline{r}avel}}_{2}}\ {\mathrm{M}} | ravel2 M |
| 506 | f_irst v | {\mathrm{\underline{f}irst}}\ {\mathrm{v}} | first v |
| 508 | f_irst M | {\mathrm{\underline{f}irst}}\ {\mathrm{M}} | first M |
| 510 | f_irst_1 M | {{\mathrm{\underline{f}irst}}_{1}}\ {\mathrm{M}} | first1 M |
| 512 | f_irst_2 M | {{\mathrm{\underline{f}irst}}_{2}}\ {\mathrm{M}} | first2 M |
| 524 | 2 t_ake v | {2}\ {\mathrm{\underline{t}ake}}\ {\mathrm{v}} | 2 take v |
| 526 | -2 t_ake v | {-2}\ {\mathrm{\underline{t}ake}}\ {\mathrm{v}} | −2 take v |
| 528 | 1 t_ake M | {1}\ {\mathrm{\underline{t}ake}}\ {\mathrm{M}} | 1 take M |
| 530 | 1 t_ake_1 M | {1}\ {{\mathrm{\underline{t}ake}}_{1}}\ {\mathrm{M}} | 1 take1 M |
| 532 | 1 t_ake_2 M | {1}\ {{\mathrm{\underline{t}ake}}_{2}}\ {\mathrm{M}} | 1 take2 M |
| 545 | 1 d_rop v | {1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{v}} | 1 drop v |
| 547 | 1 d_rop M | {1}\ {\mathrm{\underline{d}rop}}\ {\mathrm{M}} | 1 drop M |
| 549 | 1 d_rop_1 M | {1}\ {{\mathrm{\underline{d}rop}}_{1}}\ {\mathrm{M}} | 1 drop1 M |
| 551 | 1 d_rop_2 M | {1}\ {{\mathrm{\underline{d}rop}}_{2}}\ {\mathrm{M}} | 1 drop2 M |
| 564 | 3 1 s_elect v | {3}\ {1}\ {\mathrm{\underline{s}elect}}\ {\mathrm{v}} | 3 1 select v |
| 566 | 2 s_elect M | {2}\ {\mathrm{\underline{s}elect}}\ {\mathrm{M}} | 2 select M |
| 568 | 2 s_elect_1 M | {2}\ {{\mathrm{\underline{s}elect}}_{1}}\ {\mathrm{M}} | 2 select1 M |
| 570 | 2 s_elect_2 M | {2}\ {{\mathrm{\underline{s}elect}}_{2}}\ {\mathrm{M}} | 2 select2 M |
| 584 | 1 0 2 r_eplicate "abc" | {1}\ {0}\ {2}\ {\mathrm{\underline{r}eplicate}}\ {\text{"abc"}} | 1 0 2 replicate "abc" |
| 586 | (v > 1) r_eplicate v | {(}{\mathrm{v}}\ {>}\ {1}{)}\ {\mathrm{\underline{r}eplicate}}\ {\mathrm{v}} | (v > 1) replicate v |
| 588 | 2 r_eplicate v | {2}\ {\mathrm{\underline{r}eplicate}}\ {\mathrm{v}} | 2 replicate v |
| 590 | 0 2 r_eplicate M | {0}\ {2}\ {\mathrm{\underline{r}eplicate}}\ {\mathrm{M}} | 0 2 replicate M |
| 593 | 1 0 2 r_eplicate_2 M | {1}\ {0}\ {2}\ {{\mathrm{\underline{r}eplicate}}_{2}}\ {\mathrm{M}} | 1 0 2 replicate2 M |
| 596 | 1 -1 2 r_eplicate v | {1}\ {-1}\ {2}\ {\mathrm{\underline{r}eplicate}}\ {\mathrm{v}} | 1 −1 2 replicate v |
| 611 | 2 2 2 2 e_ncode 11 | {2}\ {2}\ {2}\ {2}\ {\mathrm{\underline{e}ncode}}\ {11} | 2 2 2 2 encode 11 |
| 613 | 24 60 60 e_ncode 3725 | {24}\ {60}\ {60}\ {\mathrm{\underline{e}ncode}}\ {3725} | 24 60 60 encode 3725 |
| 615 | 0 10 e_ncode 123 | {0}\ {10}\ {\mathrm{\underline{e}ncode}}\ {123} | 0 10 encode 123 |
| 617 | 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 |
| 621 | 2 2 e_ncode M | {2}\ {2}\ {\mathrm{\underline{e}ncode}}\ {\mathrm{M}} | 2 2 encode M |
| 636 | 2 d_ecode 1 0 1 1 | {2}\ {\mathrm{\underline{d}ecode}}\ {1}\ {0}\ {1}\ {1} | 2 decode 1 0 1 1 |
| 638 | 10 d_ecode 1 2 3 | {10}\ {\mathrm{\underline{d}ecode}}\ {1}\ {2}\ {3} | 10 decode 1 2 3 |
| 640 | 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 |
| 642 | 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 |
| 644 | 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 |
| 646 | 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 |
| 648 | 2 2 d_ecode 1 0 1 | {2}\ {2}\ {\mathrm{\underline{d}ecode}}\ {1}\ {0}\ {1} | 2 2 decode 1 0 1 |
| 664 | e_nclose "abc" | {\mathrm{\underline{e}nclose}}\ {\text{"abc"}} | enclose "abc" |
| 670 | "ab" "cde" | {\text{"ab"}}\ {\text{"cde"}} | "ab" "cde" |
| 676 | (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 |
| 682 | t_ally "ab" "cde" | {\mathrm{\underline{t}ally}}\ {\text{"ab"}}\ {\text{"cde"}} | tally "ab" "cde" |
| 693 | d_isclose e_nclose "abc" | {\mathrm{\underline{d}isclose}}\ {\mathrm{\underline{e}nclose}}\ {\text{"abc"}} | disclose enclose "abc" |
| 695 | 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" |
| 697 | d_isclose "ab" "cde" | {\mathrm{\underline{d}isclose}}\ {\text{"ab"}}\ {\text{"cde"}} | disclose "ab" "cde" |
| 713 | d_isplay M | {\mathrm{\underline{d}isplay}}\ {\mathrm{M}} | display M |
| 718 | d_isplay "abc" | {\mathrm{\underline{d}isplay}}\ {\text{"abc"}} | display "abc" |
| 722 | d_isplay "ab" "cde" | {\mathrm{\underline{d}isplay}}\ {\text{"ab"}}\ {\text{"cde"}} | display "ab" "cde" |
| 728 | s_hape d_isplay v | {\mathrm{\underline{s}hape}}\ {\mathrm{\underline{d}isplay}}\ {\mathrm{v}} | shape display v |
| 730 | d_isplay 5 | {\mathrm{\underline{d}isplay}}\ {5} | display 5 |
| 744 | 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" |
| 746 | 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" |
| 748 | '[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" |
| 750 | 1 1 p_artition 1 2 3 | {1}\ {1}\ {\mathrm{\underline{p}artition}}\ {1}\ {2}\ {3} | 1 1 partition 1 2 3 |
| 764 | 1 2 c_at 3 4 | {1}\ {2}\ {\mathrm{\underline{c}at}}\ {3}\ {4} | 1 2 cat 3 4 |
| 766 | M c_at M | {\mathrm{M}}\ {\mathrm{\underline{c}at}}\ {\mathrm{M}} | M cat M |
| 771 | M c_at_2 M | {\mathrm{M}}\ {{\mathrm{\underline{c}at}}_{2}}\ {\mathrm{M}} | M cat2 M |
| 774 | M c_at_2 0 9 | {\mathrm{M}}\ {{\mathrm{\underline{c}at}}_{2}}\ {0}\ {9} | M cat2 0 9 |
| 777 | M c_at_2 1 2 3 | {\mathrm{M}}\ {{\mathrm{\underline{c}at}}_{2}}\ {1}\ {2}\ {3} | M cat2 1 2 3 |
| 795 | '+ r_/ v | {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{v}} | ’+ r/ v |
| 797 | '- r_/ 1 2 3 | {\text{'}}{-}\ {\mathrm{\underline{r}}{/}}\ {1}\ {2}\ {3} | ’− r/ 1 2 3 |
| 799 | '+ r_/ M | {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{M}} | ’+ r/ M |
| 801 | '+ r_/_1 M | {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{1}}\ {\mathrm{M}} | ’+ r/1 M |
| 803 | '+ r_/_2 M | {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{2}}\ {\mathrm{M}} | ’+ r/2 M |
| 805 | '+ r_/_12 M | {\text{'}}{+}\ {{\mathrm{\underline{r}}{/}}_{12}}\ {\mathrm{M}} | ’+ r/12 M |
| 807 | 'm_ax r_/_2 M | {\text{'}}{\mathrm{\underline{m}ax}}\ {{\mathrm{\underline{r}}{/}}_{2}}\ {\mathrm{M}} | ’max r/2 M |
| 819 | '+ s_\ v | {\text{'}}{+}\ {\mathrm{\underline{s}}{\backslash}}\ {\mathrm{v}} | ’+ s\ v |
| 821 | '+ s_\ M | {\text{'}}{+}\ {\mathrm{\underline{s}}{\backslash}}\ {\mathrm{M}} | ’+ s\ M |
| 824 | '+ s_\_1 M | {\text{'}}{+}\ {{\mathrm{\underline{s}}{\backslash}}_{1}}\ {\mathrm{M}} | ’+ s\1 M |
| 827 | '+ s_\_2 M | {\text{'}}{+}\ {{\mathrm{\underline{s}}{\backslash}}_{2}}\ {\mathrm{M}} | ’+ s\2 M |
| 840 | 'n_eg e_ach v | {\text{'}}{\mathrm{\underline{n}eg}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{v}} | ’neg each v |
| 842 | '{ _r * 10 } e_ach v | {\text{'}}{\{}\ {\_\mathrm{r}}\ {\times}\ {10}\ {\}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{v}} | ’{ _r × 10 } each v |
| 844 | 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 |
| 856 | 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 |
| 858 | 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 |
| 860 | '[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 |
| 872 | 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 |
| 886 | (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 |
| 899 | '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 |
| 901 | [n_eg a_bs] -5 | {[}{\mathrm{\underline{n}eg}}\ {\mathrm{\underline{a}bs}}{]}\ {-5} | [neg abs] −5 |
| 912 | 10 '- s_wap 3 | {10}\ {\text{'}}{-}\ {\mathrm{\underline{s}wap}}\ {3} | 10 ’− swap 3 |
| 924 | 3 'n_eg p_ower 5 | {3}\ {\text{'}}{\mathrm{\underline{n}eg}}\ {\mathrm{\underline{p}ower}}\ {5} | 3 ’neg power 5 |
| 926 | n_eg^3 5 | {\mathrm{\underline{n}eg}}^{3}\ {5} | neg3 5 |
| 942 | 5 6 7 i_ndexOf 7 9 | {5}\ {6}\ {7}\ {\mathrm{\underline{i}ndexOf}}\ {7}\ {9} | 5 6 7 indexOf 7 9 |
| 944 | M i_ndexOf 4 5 6 | {\mathrm{M}}\ {\mathrm{\underline{i}ndexOf}}\ {4}\ {5}\ {6} | M indexOf 4 5 6 |
| 955 | 2 9 m_ember? 1 2 3 | {2}\ {9}\ {\mathrm{\underline{m}ember}{?}}\ {1}\ {2}\ {3} | 2 9 member? 1 2 3 |
| 968 | 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 |
| 970 | 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 |
| 972 | M m_atch M | {\mathrm{M}}\ {\mathrm{\underline{m}atch}}\ {\mathrm{M}} | M match M |
| 974 | 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 |
| 976 | 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 |
| 987 | u_nique 3 1 3 2 1 | {\mathrm{\underline{u}nique}}\ {3}\ {1}\ {3}\ {2}\ {1} | unique 3 1 3 2 1 |
| 999 | s_ort 3 1 2 | {\mathrm{\underline{s}ort}}\ {3}\ {1}\ {2} | sort 3 1 2 |
| 1001 | s_ort N | {\mathrm{\underline{s}ort}}\ {\mathrm{N}} | sort N |
| 1004 | s_ort_2 N | {{\mathrm{\underline{s}ort}}_{2}}\ {\mathrm{N}} | sort2 N |
| 1017 | g_rade 3 1 2 | {\mathrm{\underline{g}rade}}\ {3}\ {1}\ {2} | grade 3 1 2 |
| 1019 | g_rade_2 N | {{\mathrm{\underline{g}rade}}_{2}}\ {\mathrm{N}} | grade2 N |
| 1030 | w_here 0 1 1 0 | {\mathrm{\underline{w}here}}\ {0}\ {1}\ {1}\ {0} | where 0 1 1 0 |
| 1032 | w_here_2 M | {{\mathrm{\underline{w}here}}_{2}}\ {\mathrm{M}} | where2 M |
| 1048 | 1 o_- v | {1}\ {\mathrm{\underline{o}}{-}}\ {\mathrm{v}} | 1 o− v |
| 1050 | -1 o_- v | {-1}\ {\mathrm{\underline{o}}{-}}\ {\mathrm{v}} | −1 o− v |
| 1052 | 1 o_- M | {1}\ {\mathrm{\underline{o}}{-}}\ {\mathrm{M}} | 1 o− M |
| 1055 | 1 o_-_1 M | {1}\ {{\mathrm{\underline{o}}{-}}_{1}}\ {\mathrm{M}} | 1 o−1 M |
| 1058 | 1 o_-_2 M | {1}\ {{\mathrm{\underline{o}}{-}}_{2}}\ {\mathrm{M}} | 1 o−2 M |
| 1061 | -1 0 1 o_- v | {-1}\ {0}\ {1}\ {\mathrm{\underline{o}}{-}}\ {\mathrm{v}} | −1 0 1 o− v |
| 1075 | r_ev v | {\mathrm{\underline{r}ev}}\ {\mathrm{v}} | rev v |
| 1077 | r_ev M | {\mathrm{\underline{r}ev}}\ {\mathrm{M}} | rev M |
| 1080 | r_ev_1 M | {{\mathrm{\underline{r}ev}}_{1}}\ {\mathrm{M}} | rev1 M |
| 1083 | r_ev_2 M | {{\mathrm{\underline{r}ev}}_{2}}\ {\mathrm{M}} | rev2 M |
| 1097 | o_\ M | {\mathrm{\underline{o}}{\backslash}}\ {\mathrm{M}} | o\ M |
| 1101 | 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 |
| 1103 | 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 |
| 1105 | o_\_2 M | {{\mathrm{\underline{o}}{\backslash}}_{2}}\ {\mathrm{M}} | o\2 M |
| 1119 | 2 1 t_ranspose M | {2}\ {1}\ {\mathrm{\underline{t}ranspose}}\ {\mathrm{M}} | 2 1 transpose M |
| 1123 | 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 |
| 1125 | 1 1 t_ranspose M | {1}\ {1}\ {\mathrm{\underline{t}ranspose}}\ {\mathrm{M}} | 1 1 transpose M |
| 1139 | []A | {\square \mathrm{A}} | □A |
| 1141 | 3 t_ake []A | {3}\ {\mathrm{\underline{t}ake}}\ {\square \mathrm{A}} | 3 take □A |
| 1152 | []D | {\square \mathrm{D}} | □D |
| 1164 | t_ally []AV | {\mathrm{\underline{t}ally}}\ {\square \mathrm{AV}} | tally □AV |
| 1166 | 66 s_elect []AV | {66}\ {\mathrm{\underline{s}elect}}\ {\square \mathrm{AV}} | 66 select □AV |
| 1177 | []IO | {\square \mathrm{IO}} | □IO |
| 1189 | []U_CS "Hi" | {\square \mathrm{\underline{U}CS}}\ {\text{"Hi"}} | □UCS "Hi" |
| 1191 | ([]U_CS "a") - []U_CS "A" | {(}{\square \mathrm{\underline{U}CS}}\ {\text{"a"}}{)}\ {-}\ {\square \mathrm{\underline{U}CS}}\ {\text{"A"}} | (□UCS "a") − □UCS "A" |
| 1202 | []U_CHAR 72 105 | {\square \mathrm{\underline{U}CHAR}}\ {72}\ {105} | □UCHAR 72 105 |
| 1204 | []U_CHAR 1 + []U_CS "HAL" | {\square \mathrm{\underline{U}CHAR}}\ {1}\ {+}\ {\square \mathrm{\underline{U}CS}}\ {\text{"HAL"}} | □UCHAR 1 + □UCS "HAL" |
| 1206 | []U_CHAR 200 | {\square \mathrm{\underline{U}CHAR}}\ {200} | □UCHAR 200 |
| 1219 | s_hape []TS | {\mathrm{\underline{s}hape}}\ {\square \mathrm{TS}} | shape □TS |
| 1221 | 2026 <= 1 s_elect []TS | {2026}\ {\leq}\ {1}\ {\mathrm{\underline{s}elect}}\ {\square \mathrm{TS}} | 2026 ≤ 1 select □TS |
| 1234 | ([]D_L 0.01) >= 0.01 | {(}{\square \mathrm{\underline{D}L}}\ {0.01}{)}\ {\geq}\ {0.01} | (□DL 0.01) ≥ 0.01 |
| 1236 | []D_L -1 | {\square \mathrm{\underline{D}L}}\ {-1} | □DL −1 |
| 1249 | p_rint! v | {\mathrm{\underline{p}rint}{!}}\ {\mathrm{v}} | print! v |
| 1262 | r_oll! 6 6 6 | {\mathrm{\underline{r}oll}{!}}\ {6}\ {6}\ {6} | roll! 6 6 6 |
| 1275 | i_d v | {\mathrm{\underline{i}d}}\ {\mathrm{v}} | id v |
| 1277 | [i_d - n_eg] 5 | {[}{\mathrm{\underline{i}d}}\ {-}\ {\mathrm{\underline{n}eg}}{]}\ {5} | [id − neg] 5 |
| 1289 | 1 l_eft 2 | {1}\ {\mathrm{\underline{l}eft}}\ {2} | 1 left 2 |
| 1291 | 3 [l_eft - r_ight] 4 | {3}\ {[}{\mathrm{\underline{l}eft}}\ {-}\ {\mathrm{\underline{r}ight}}{]}\ {4} | 3 [left − right] 4 |
| 1302 | 1 r_ight 2 | {1}\ {\mathrm{\underline{r}ight}}\ {2} | 1 right 2 |
| 1304 | 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 |
| 1315 | f_ormat 3.5 | {\mathrm{\underline{f}ormat}}\ {3.5} | format 3.5 |
| 1317 | t_ally f_ormat 1 2 3 | {\mathrm{\underline{t}ally}}\ {\mathrm{\underline{f}ormat}}\ {1}\ {2}\ {3} | tally format 1 2 3 |
| 1328 | n_umbers "1 2.5 -3" | {\mathrm{\underline{n}umbers}}\ {\text{"1 2.5 -3"}} | numbers "1 2.5 -3" |
| 1340 | "hello" []N_PUT "work/reference.txt" | {\text{"hello"}}\ {\square \mathrm{\underline{N}PUT}}\ {\text{"work/reference.txt"}} | "hello" □NPUT "work/reference.txt" |
| 1351 | []N_GET "work/reference.txt" | {\square \mathrm{\underline{N}GET}}\ {\text{"work/reference.txt"}} | □NGET "work/reference.txt" |
| 1362 | []R_EAD @ | {\square \mathrm{\underline{R}EAD}}\ {@} | □READ @ |
| 1376 | []K_EY @ | {\square \mathrm{\underline{K}EY}}\ {@} | □KEY @ |
| 1387 | []K_CHAR []K_EY @ | {\square \mathrm{\underline{K}CHAR}}\ {\square \mathrm{\underline{K}EY}}\ {@} | □KCHAR □KEY @ |
| 1399 | []K_NAMED 1 | {\square \mathrm{\underline{K}NAMED}}\ {1} | □KNAMED 1 |
| 1416 | []V_IEW "1 + r_ange n" | {\square \mathrm{\underline{V}IEW}}\ {\text{"1 + r\_ange n"}} | □VIEW "1 + r_ange n" |
| 1452 | "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" |
| 1458 | "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" |
| 1473 | 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") |
| 1475 | 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") |
| 1496 | []E_VENT @ | {\square \mathrm{\underline{E}VENT}}\ {@} | □EVENT @ |
| 1509 | []E_KIND []E_VENT @ | {\square \mathrm{\underline{E}KIND}}\ {\square \mathrm{\underline{E}VENT}}\ {@} | □EKIND □EVENT @ |
| 1522 | []E_AT []E_VENT @ | {\square \mathrm{\underline{E}AT}}\ {\square \mathrm{\underline{E}VENT}}\ {@} | □EAT □EVENT @ |
| 1534 | 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 @ |
| 1536 | []E_KEY []E_VENT @ | {\square \mathrm{\underline{E}KEY}}\ {\square \mathrm{\underline{E}VENT}}\ {@} | □EKEY □EVENT @ |
| 1548 | []C_OLOR 2 | {\square \mathrm{\underline{C}OLOR}}\ {2} | □COLOR 2 |
| 1561 | 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" |
| 1572 | 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" |
| 1583 | t_ally []B_OLD "hi" | {\mathrm{\underline{t}ally}}\ {\square \mathrm{\underline{B}OLD}}\ {\text{"hi"}} | tally □BOLD "hi" |
| 1595 | 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" |
| 1606 | t_ally []C_LS @ | {\mathrm{\underline{t}ally}}\ {\square \mathrm{\underline{C}LS}}\ {@} | tally □CLS @ |
| 1618 | []T_E @ | {\square \mathrm{\underline{T}E}}\ {@} | □TE @ |
| 1630 | t_ally []E_RR "careful" | {\mathrm{\underline{t}ally}}\ {\square \mathrm{\underline{E}RR}}\ {\text{"careful"}} | tally □ERR "careful" |
| 1643 | 1 + []P_ANIC "stop here" | {1}\ {+}\ {\square \mathrm{\underline{P}ANIC}}\ {\text{"stop here"}} | 1 + □PANIC "stop here" |
| 1657 | "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" |
| 1659 | "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" |
| 1683 | '{ @ -> []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 "" } |
| 1685 | '{ @ -> "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 } |
| 1687 | '{ @ -> 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 } |
| 1698 | '{ @ -> 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 } |
| 1710 | '{ @ -> "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 } |
| 1722 | 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 } |
| 1724 | '{ @ -> "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 } |
| 1735 | '{ @ -> "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 } |
| 1746 | '{ @ -> "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 } |
| 1758 | '{ @ -> "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 } |
| 1774 | '{ @ -> 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 } |
| 1776 | '{ @ -> 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 } |
| 1778 | 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") |
| 1793 | '{ @ -> '{ @ -> 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 } |
| 1795 | '{ @ -> "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 } |
| 1808 | '{ @ -> 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" } |
| 1812 | '{ @ -> "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" } |
| 1830 | "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" |
| 1841 | []S_TATEMENT @ | {\square \mathrm{\underline{S}TATEMENT}}\ {@} | □STATEMENT @ |
| 1852 | []F_ILE @ | {\square \mathrm{\underline{F}ILE}}\ {@} | □FILE @ |
| 1863 | []L_INE @ | {\square \mathrm{\underline{L}INE}}\ {@} | □LINE @ |
| 1875 | []I_NCLUDE "data.txt" | {\square \mathrm{\underline{I}NCLUDE}}\ {\text{"data.txt"}} | □INCLUDE "data.txt" |
| 1887 | []C_FG "cli" | {\square \mathrm{\underline{C}FG}}\ {\text{"cli"}} | □CFG "cli" |
| 1908 | []G_RID 1 0 | {\square \mathrm{\underline{G}RID}}\ {1}\ {0} | □GRID 1 0 |
| 1925 | []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 |
| 1941 | 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 |
| 6 | "c:" u_se< "Combinators" | {\text{"c:"}}\ {\mathrm{\underline{u}se}{<}}\ {\text{"Combinators"}} | "c:" use< "Combinators" |
| 7 | u:a_b := { a b -> (10 * a) + b } | {{}^{\mathrm{u}}\mathrm{\underline{a}b}}\ {\leftarrow}\ {\{}\ {\mathrm{a}}\ {\mathrm{b}}\ {\to}\ {(}{10}\ {\times}\ {\mathrm{a}}{)}\ {+}\ {\mathrm{b}}\ {\}} | uab ← { a b → (10 × a) + b } |
| 8 | u:a_bc := { a b c -> (100 * a) + (10 * b) + c } | {{}^{\mathrm{u}}\mathrm{\underline{a}bc}}\ {\leftarrow}\ {\{}\ {\mathrm{a}}\ {\mathrm{b}}\ {\mathrm{c}}\ {\to}\ {(}{100}\ {\times}\ {\mathrm{a}}{)}\ {+}\ {(}{10}\ {\times}\ {\mathrm{b}}{)}\ {+}\ {\mathrm{c}}\ {\}} | uabc ← { a b c → (100 × a) + (10 × b) + c } |
| 9 | u:a_bcd := { a b c d -> (1000 * a) + (100 * b) + (10 * c) + d } | {{}^{\mathrm{u}}\mathrm{\underline{a}bcd}}\ {\leftarrow}\ {\{}\ {\mathrm{a}}\ {\mathrm{b}}\ {\mathrm{c}}\ {\mathrm{d}}\ {\to}\ {(}{1000}\ {\times}\ {\mathrm{a}}{)}\ {+}\ {(}{100}\ {\times}\ {\mathrm{b}}{)}\ {+}\ {(}{10}\ {\times}\ {\mathrm{c}}{)}\ {+}\ {\mathrm{d}}\ {\}} | uabcd ← { a b c d → (1000 × a) + (100 × b) + (10 × c) + d } |
| 10 | u:i_nc := { _r + 1 } | {{}^{\mathrm{u}}\mathrm{\underline{i}nc}}\ {\leftarrow}\ {\{}\ {\_\mathrm{r}}\ {+}\ {1}\ {\}} | uinc ← { _r + 1 } |
| 11 | u:d_bl := { _r * 2 } | {{}^{\mathrm{u}}\mathrm{\underline{d}bl}}\ {\leftarrow}\ {\{}\ {\_\mathrm{r}}\ {\times}\ {2}\ {\}} | udbl ← { _r × 2 } |
| 12 | c:I_ 7 | {{}^{\mathrm{c}}\mathrm{\underline{I}}}\ {7} | cI 7 |
| 13 | 1 c:K_ 2 | {1}\ {{}^{\mathrm{c}}\mathrm{\underline{K}}}\ {2} | 1 cK 2 |
| 14 | 3 c:T_ 'u:d_bl | {3}\ {{}^{\mathrm{c}}\mathrm{\underline{T}}}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{d}bl}} | 3 cT ’udbl |
| 15 | 'u:a_b c:W_ 3 | {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}b}}\ {{}^{\mathrm{c}}\mathrm{\underline{W}}}\ {3} | ’uab cW 3 |
| 16 | 3 c:W_1 'u:a_b | {3}\ {{}^{\mathrm{c}}\mathrm{\underline{W}1}}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}b}} | 3 cW1 ’uab |
| 17 | 'u:d_bl 'u:i_nc c:B_ 5 | {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{d}bl}}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{i}nc}}\ {{}^{\mathrm{c}}\mathrm{\underline{B}}}\ {5} | ’udbl ’uinc cB 5 |
| 18 | 1 'u:a_b 'u:i_nc c:B_1 2 | {1}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}b}}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{i}nc}}\ {{}^{\mathrm{c}}\mathrm{\underline{B}1}}\ {2} | 1 ’uab ’uinc cB1 2 |
| 19 | (1 'u:a_bc 'u:i_nc c:B_2 2)_ 3 | {(}{1}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}bc}}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{i}nc}}\ {{}^{\mathrm{c}}\mathrm{\underline{B}2}}\ {2}{)}{\_}\ {3} | (1 ’uabc ’uinc cB2 2)_ 3 |
| 20 | 'u:i_nc 'u:d_bl 'n_eg c:B_3 5 | {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{i}nc}}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{d}bl}}\ {\text{'}}{\mathrm{\underline{n}eg}}\ {{}^{\mathrm{c}}\mathrm{\underline{B}3}}\ {5} | ’uinc ’udbl ’neg cB3 5 |
| 21 | 1 'u:a_b c:C_ 2 | {1}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}b}}\ {{}^{\mathrm{c}}\mathrm{\underline{C}}}\ {2} | 1 ’uab cC 2 |
| 22 | (1 'u:a_b c:D_ 'u:d_bl)_ 2 | {(}{1}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}b}}\ {{}^{\mathrm{c}}\mathrm{\underline{D}}}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{d}bl}}{)}{\_}\ {2} | (1 ’uab cD ’udbl)_ 2 |
| 23 | ((1 'u:a_bc c:D_1 2)_ 'u:d_bl)_ 3 | {(}{(}{1}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}bc}}\ {{}^{\mathrm{c}}\mathrm{\underline{D}1}}\ {2}{)}{\_}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{d}bl}}{)}{\_}\ {3} | ((1 ’uabc cD1 2)_ ’udbl)_ 3 |
| 24 | (1 'u:d_bl 'u:a_b c:D_2 'u:i_nc)_ 2 | {(}{1}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{d}bl}}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}b}}\ {{}^{\mathrm{c}}\mathrm{\underline{D}2}}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{i}nc}}{)}{\_}\ {2} | (1 ’udbl ’uab cD2 ’uinc)_ 2 |
| 25 | ((1 'u:a_b c:E_ 'u:a_b)_ 2)_ 3 | {(}{(}{1}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}b}}\ {{}^{\mathrm{c}}\mathrm{\underline{E}}}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}b}}{)}{\_}\ {2}{)}{\_}\ {3} | ((1 ’uab cE ’uab)_ 2)_ 3 |
| 26 | (((1 'u:a_b 'u:a_b c:E_h 2)_ 'u:a_b)_ 3)_ 4 | {(}{(}{(}{1}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}b}}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}b}}\ {{}^{\mathrm{c}}\mathrm{\underline{E}h}}\ {2}{)}{\_}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}b}}{)}{\_}\ {3}{)}{\_}\ {4} | (((1 ’uab ’uab cEh 2)_ ’uab)_ 3)_ 4 |
| 27 | (1 c:F_ 2)_ 'u:a_b | {(}{1}\ {{}^{\mathrm{c}}\mathrm{\underline{F}}}\ {2}{)}{\_}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}b}} | (1 cF 2)_ ’uab |
| 28 | 1 'u:d_bl 'u:a_b c:G_ 2 | {1}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{d}bl}}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}b}}\ {{}^{\mathrm{c}}\mathrm{\underline{G}}}\ {2} | 1 ’udbl ’uab cG 2 |
| 29 | 1 'u:a_bc c:H_ 2 | {1}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}bc}}\ {{}^{\mathrm{c}}\mathrm{\underline{H}}}\ {2} | 1 ’uabc cH 2 |
| 30 | (1 'u:a_b c:J_ 2)_ 3 | {(}{1}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}b}}\ {{}^{\mathrm{c}}\mathrm{\underline{J}}}\ {2}{)}{\_}\ {3} | (1 ’uab cJ 2)_ 3 |
| 31 | '{ f_ -> f_ 3 } c:O_ 'u:d_bl | {\text{'}}{\{}\ {\mathrm{\underline{f}}}\ {\to}\ {\mathrm{\underline{f}}}\ {3}\ {\}}\ {{}^{\mathrm{c}}\mathrm{\underline{O}}}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{d}bl}} | ’{ f → f 3 } cO ’udbl |
| 32 | 'u:d_bl 'u:i_nc c:Q_ 5 | {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{d}bl}}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{i}nc}}\ {{}^{\mathrm{c}}\mathrm{\underline{Q}}}\ {5} | ’udbl ’uinc cQ 5 |
| 33 | 5 'u:i_nc c:Q_1 'u:d_bl | {5}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{i}nc}}\ {{}^{\mathrm{c}}\mathrm{\underline{Q}1}}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{d}bl}} | 5 ’uinc cQ1 ’udbl |
| 34 | (5 c:Q_2 'u:i_nc)_ 'u:d_bl | {(}{5}\ {{}^{\mathrm{c}}\mathrm{\underline{Q}2}}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{i}nc}}{)}{\_}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{d}bl}} | (5 cQ2 ’uinc)_ ’udbl |
| 35 | 5 'u:d_bl c:Q_3 'u:i_nc | {5}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{d}bl}}\ {{}^{\mathrm{c}}\mathrm{\underline{Q}3}}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{i}nc}} | 5 ’udbl cQ3 ’uinc |
| 36 | (5 c:Q_4 'u:d_bl)_ 'u:i_nc | {(}{5}\ {{}^{\mathrm{c}}\mathrm{\underline{Q}4}}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{d}bl}}{)}{\_}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{i}nc}} | (5 cQ4 ’udbl)_ ’uinc |
| 37 | (1 c:R_ 'u:a_b)_ 2 | {(}{1}\ {{}^{\mathrm{c}}\mathrm{\underline{R}}}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}b}}{)}{\_}\ {2} | (1 cR ’uab)_ 2 |
| 38 | 'u:d_bl 'u:a_b c:S_ 3 | {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{d}bl}}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}b}}\ {{}^{\mathrm{c}}\mathrm{\underline{S}}}\ {3} | ’udbl ’uab cS 3 |
| 39 | (1 c:V_ 2)_ 'u:a_b | {(}{1}\ {{}^{\mathrm{c}}\mathrm{\underline{V}}}\ {2}{)}{\_}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}b}} | (1 cV 2)_ ’uab |
| 40 | (1 'u:a_bc c:C_s 2)_ 3 | {(}{1}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}bc}}\ {{}^{\mathrm{c}}\mathrm{\underline{C}s}}\ {2}{)}{\_}\ {3} | (1 ’uabc cCs 2)_ 3 |
| 41 | (1 'u:a_bc c:R_s 2)_ 3 | {(}{1}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}bc}}\ {{}^{\mathrm{c}}\mathrm{\underline{R}s}}\ {2}{)}{\_}\ {3} | (1 ’uabc cRs 2)_ 3 |
| 42 | (1 'u:a_bc c:F_s 2)_ 3 | {(}{1}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}bc}}\ {{}^{\mathrm{c}}\mathrm{\underline{F}s}}\ {2}{)}{\_}\ {3} | (1 ’uabc cFs 2)_ 3 |
| 43 | (1 'u:a_bc c:V_s 2)_ 3 | {(}{1}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}bc}}\ {{}^{\mathrm{c}}\mathrm{\underline{V}s}}\ {2}{)}{\_}\ {3} | (1 ’uabc cVs 2)_ 3 |
| 44 | 1 'u:a_bc c:W_s 2 | {1}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}bc}}\ {{}^{\mathrm{c}}\mathrm{\underline{W}s}}\ {2} | 1 ’uabc cWs 2 |
| 45 | ((1 'u:a_bcd c:C_ss 2)_ 3)_ 4 | {(}{(}{1}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}bcd}}\ {{}^{\mathrm{c}}\mathrm{\underline{C}ss}}\ {2}{)}{\_}\ {3}{)}{\_}\ {4} | ((1 ’uabcd cCss 2)_ 3)_ 4 |
| 46 | ((1 'u:a_bcd c:R_ss 2)_ 3)_ 4 | {(}{(}{1}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}bcd}}\ {{}^{\mathrm{c}}\mathrm{\underline{R}ss}}\ {2}{)}{\_}\ {3}{)}{\_}\ {4} | ((1 ’uabcd cRss 2)_ 3)_ 4 |
| 47 | ((1 'u:a_bcd c:F_ss 2)_ 3)_ 4 | {(}{(}{1}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}bcd}}\ {{}^{\mathrm{c}}\mathrm{\underline{F}ss}}\ {2}{)}{\_}\ {3}{)}{\_}\ {4} | ((1 ’uabcd cFss 2)_ 3)_ 4 |
| 48 | ((1 'u:a_bcd c:V_ss 2)_ 3)_ 4 | {(}{(}{1}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}bcd}}\ {{}^{\mathrm{c}}\mathrm{\underline{V}ss}}\ {2}{)}{\_}\ {3}{)}{\_}\ {4} | ((1 ’uabcd cVss 2)_ 3)_ 4 |
| 49 | (1 'u:a_bcd c:W_ss 2)_ 3 | {(}{1}\ {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{a}bcd}}\ {{}^{\mathrm{c}}\mathrm{\underline{W}ss}}\ {2}{)}{\_}\ {3} | (1 ’uabcd cWss 2)_ 3 |
| 50 | u:f_act := { ~s_elf n -> n <= 1 ? 1; n * s_elf n - 1 } | {{}^{\mathrm{u}}\mathrm{\underline{f}act}}\ {\leftarrow}\ {\{}\ {\sim}{\mathrm{\underline{s}elf}}\ {\mathrm{n}}\ {\to}\ {\mathrm{n}}\ {\leq}\ {1}\ {?}\ {1}{\diamond}\ {\mathrm{n}}\ {\times}\ {\mathrm{\underline{s}elf}}\ {\mathrm{n}}\ {-}\ {1}\ {\}} | ufact ← { ∼self n → n ≤ 1 ? 1⋄ n × self n − 1 } |
| 51 | 'u:f_act c:Y_ 5 | {\text{'}}{{}^{\mathrm{u}}\mathrm{\underline{f}act}}\ {{}^{\mathrm{c}}\mathrm{\underline{Y}}}\ {5} | ’ufact cY 5 |
| 5 | a := 2; b := 3; c := 4 | {\mathrm{a}}\ {\leftarrow}\ {2}{\diamond}\ {\mathrm{b}}\ {\leftarrow}\ {3}{\diamond}\ {\mathrm{c}}\ {\leftarrow}\ {4} | a ← 2⋄ b ← 3⋄ c ← 4 |
| 6 | a + b * c | {\mathrm{a}}\ {+}\ {\mathrm{b}}\ {\times}\ {\mathrm{c}} | a + b × c |
| 7 | x := 5 | {\mathrm{x}}\ {\leftarrow}\ {5} | x ← 5 |
| 8 | x > 0 | {\mathrm{x}}\ {>}\ {0} | x > 0 |
| 9 | y! := 5 | {\mathrm{y}!}\ {\leftarrow}\ {5} | y! ← 5 |
| 10 | y! := y! + 1 | {\mathrm{y}!}\ {\leftarrow}\ {\mathrm{y}!}\ {+}\ {1} | y! ← y! + 1 |
| 11 | y! | {\mathrm{y}!} | y! |
| 12 | u:s_q := { x -> x * x } | {{}^{\mathrm{u}}\mathrm{\underline{s}q}}\ {\leftarrow}\ {\{}\ {\mathrm{x}}\ {\to}\ {\mathrm{x}}\ {\times}\ {\mathrm{x}}\ {\}} | usq ← { x → x × x } |
| 13 | u:s_q 5 | {{}^{\mathrm{u}}\mathrm{\underline{s}q}}\ {5} | usq 5 |
| 14 | '{ _r * _r } e_ach 1 2 3 | {\text{'}}{\{}\ {\_\mathrm{r}}\ {\times}\ {\_\mathrm{r}}\ {\}}\ {\mathrm{\underline{e}ach}}\ {1}\ {2}\ {3} | ’{ _r × _r } each 1 2 3 |
| 15 | u:a_bs := { x -> x < 0 ? n_eg x; x } | {{}^{\mathrm{u}}\mathrm{\underline{a}bs}}\ {\leftarrow}\ {\{}\ {\mathrm{x}}\ {\to}\ {\mathrm{x}}\ {<}\ {0}\ {?}\ {\mathrm{\underline{n}eg}}\ {\mathrm{x}}{\diamond}\ {\mathrm{x}}\ {\}} | uabs ← { x → x < 0 ? neg x⋄ x } |
| 16 | u:a_bs -3 | {{}^{\mathrm{u}}\mathrm{\underline{a}bs}}\ {-3} | uabs −3 |
| 17 | u:n_ame := { x -> x = 0 ? "zero"; "other" } | {{}^{\mathrm{u}}\mathrm{\underline{n}ame}}\ {\leftarrow}\ {\{}\ {\mathrm{x}}\ {\to}\ {\mathrm{x}}\ {=}\ {0}\ {?}\ {\text{"zero"}}{\diamond}\ {\text{"other"}}\ {\}} | uname ← { x → x = 0 ? "zero"⋄ "other" } |
| 18 | u:n_ame 0 | {{}^{\mathrm{u}}\mathrm{\underline{n}ame}}\ {0} | uname 0 |
| 19 | u:n_ame 7 | {{}^{\mathrm{u}}\mathrm{\underline{n}ame}}\ {7} | uname 7 |
| 20 | r_ange 5 | {\mathrm{\underline{r}ange}}\ {5} | range 5 |
| 21 | xs := r_ange 6 | {\mathrm{xs}}\ {\leftarrow}\ {\mathrm{\underline{r}ange}}\ {6} | xs ← range 6 |
| 22 | xs * 2 | {\mathrm{xs}}\ {\times}\ {2} | xs × 2 |
| 23 | (w_here 0 = xs m_od 2) s_elect xs | {(}{\mathrm{\underline{w}here}}\ {0}\ {=}\ {\mathrm{xs}}\ {\mathrm{\underline{m}od}}\ {2}{)}\ {\mathrm{\underline{s}elect}}\ {\mathrm{xs}} | (where 0 = xs mod 2) select xs |
| 24 | '+ r_/ xs | {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{xs}} | ’+ r/ xs |
| 25 | s_ort 3 1 2 | {\mathrm{\underline{s}ort}}\ {3}\ {1}\ {2} | sort 3 1 2 |
| 26 | t_ally xs | {\mathrm{\underline{t}ally}}\ {\mathrm{xs}} | tally xs |
| 27 | s := "ab"; t := "cd" | {\mathrm{s}}\ {\leftarrow}\ {\text{"ab"}}{\diamond}\ {\mathrm{t}}\ {\leftarrow}\ {\text{"cd"}} | s ← "ab"⋄ t ← "cd" |
| 28 | s c_at t | {\mathrm{s}}\ {\mathrm{\underline{c}at}}\ {\mathrm{t}} | s cat t |
| 29 | p_rint! x | {\mathrm{\underline{p}rint}{!}}\ {\mathrm{x}} | print! x |
| 30 | n_umbers "1.5 2" | {\mathrm{\underline{n}umbers}}\ {\text{"1.5 2"}} | numbers "1.5 2" |
| 31 | "s:" u_se< "Stats" | {\text{"s:"}}\ {\mathrm{\underline{u}se}{<}}\ {\text{"Stats"}} | "s:" use< "Stats" |
| 32 | s:m_ean 1 2 3 | {{}^{\mathrm{s}}\mathrm{\underline{m}ean}}\ {1}\ {2}\ {3} | smean 1 2 3 |
| 33 | v := 3 1 2 | {\mathrm{v}}\ {\leftarrow}\ {3}\ {1}\ {2} | v ← 3 1 2 |
| 34 | '+ r_/ v | {\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\mathrm{v}} | ’+ r/ v |
| 35 | '+ s_\ v | {\text{'}}{+}\ {\mathrm{\underline{s}}{\backslash}}\ {\mathrm{v}} | ’+ s\ v |
| 36 | 2 3 r_eshape r_ange 6 | {2}\ {3}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{\underline{r}ange}}\ {6} | 2 3 reshape range 6 |
| 37 | s_hape 2 3 r_eshape r_ange 6 | {\mathrm{\underline{s}hape}}\ {2}\ {3}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{\underline{r}ange}}\ {6} | shape 2 3 reshape range 6 |
| 38 | t_ally v | {\mathrm{\underline{t}ally}}\ {\mathrm{v}} | tally v |
| 39 | r_ev v | {\mathrm{\underline{r}ev}}\ {\mathrm{v}} | rev v |
| 40 | 1 o_- v | {1}\ {\mathrm{\underline{o}}{-}}\ {\mathrm{v}} | 1 o− v |
| 41 | o_\ 2 3 r_eshape r_ange 6 | {\mathrm{\underline{o}}{\backslash}}\ {2}\ {3}\ {\mathrm{\underline{r}eshape}}\ {\mathrm{\underline{r}ange}}\ {6} | o\ 2 3 reshape range 6 |
| 42 | v '* t_able v | {\mathrm{v}}\ {\text{'}}{\times}\ {\mathrm{\underline{t}able}}\ {\mathrm{v}} | v ’× table v |
| 43 | m := 2 2 r_eshape 1 2 3 4 | {\mathrm{m}}\ {\leftarrow}\ {2}\ {2}\ {\mathrm{\underline{r}eshape}}\ {1}\ {2}\ {3}\ {4} | m ← 2 2 reshape 1 2 3 4 |
| 44 | m '+ '* i_nner m | {\mathrm{m}}\ {\text{'}}{+}\ {\text{'}}{\times}\ {\mathrm{\underline{i}nner}}\ {\mathrm{m}} | m ’+ ’× inner m |
| 45 | 'n_eg e_ach v | {\text{'}}{\mathrm{\underline{n}eg}}\ {\mathrm{\underline{e}ach}}\ {\mathrm{v}} | ’neg each v |
| 46 | 10 '- s_wap 3 | {10}\ {\text{'}}{-}\ {\mathrm{\underline{s}wap}}\ {3} | 10 ’− swap 3 |
| 47 | '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 |
| 48 | n_eg^3 5 | {\mathrm{\underline{n}eg}}^{3}\ {5} | neg3 5 |
| 49 | u:m_ean := ['+ r_/ / t_ally] | {{}^{\mathrm{u}}\mathrm{\underline{m}ean}}\ {\leftarrow}\ {[}{\text{'}}{+}\ {\mathrm{\underline{r}}{/}}\ {\div}\ {\mathrm{\underline{t}ally}}{]} | umean ← [’+ r/ ÷ tally] |
| 50 | u:m_ean 1 2 3 4 | {{}^{\mathrm{u}}\mathrm{\underline{m}ean}}\ {1}\ {2}\ {3}\ {4} | umean 1 2 3 4 |
| 51 | v i_ndexOf 2 | {\mathrm{v}}\ {\mathrm{\underline{i}ndexOf}}\ {2} | v indexOf 2 |
| 52 | 2 9 m_ember? v | {2}\ {9}\ {\mathrm{\underline{m}ember}{?}}\ {\mathrm{v}} | 2 9 member? v |
| 53 | v m_atch 3 1 2 | {\mathrm{v}}\ {\mathrm{\underline{m}atch}}\ {3}\ {1}\ {2} | v match 3 1 2 |
| 54 | w_here 0 1 1 0 | {\mathrm{\underline{w}here}}\ {0}\ {1}\ {1}\ {0} | where 0 1 1 0 |
| 55 | f_ormat v | {\mathrm{\underline{f}ormat}}\ {\mathrm{v}} | format v |
| 56 | "c:" u_se< "Combinators" | {\text{"c:"}}\ {\mathrm{\underline{u}se}{<}}\ {\text{"Combinators"}} | "c:" use< "Combinators" |
| 57 | 10 '- c:C_ 3 | {10}\ {\text{'}}{-}\ {{}^{\mathrm{c}}\mathrm{\underline{C}}}\ {3} | 10 ’− cC 3 |
| 58 | "1 d_iv 0" t_ry< "@ r_ecover< \"-1\"" | {\text{"1 d\_iv 0"}}\ {\mathrm{\underline{t}ry}{<}}\ {\text{"@ r\_ecover< \textbackslash{}"-1\textbackslash{}""}} | "1 d_iv 0" try< "@ r_ecover< \"-1\"" |