⍝ ⍺⍺-rational sum of ⍺ and ⍵:
⍝
⍝ Here's a handy little amuse gueule to convert
⍝ an array of regular integers into ⍺-numbers:

    encode←{⎕IO ⎕ML←0                           ⍝ ⍺-encode of int array ⍵.
        u←(2⊥'0'=2↑¯1⌽⍺)⊃0 1 ¯1                 ⍝ extremal '0': unsigned.
        (|u)^u∊-×⍵:((0>u××⍵)/¨'¯'),¨⍺ ∇ u×|⍵    ⍝ explicit '¯', where needed.
        min←⍺⍳'0'                               ⍝ - minimum value.
        width←1+⌈(⍴⍺)⍟⌈/1⌈,|⍵                   ⍝ upper bound for no of digits.
        base←width/⍴⍺                           ⍝ encode/decode vector.
        vals←-min-base⊤base⊥min+base⊤⍉⍵         ⍝ base-⍺ integers.
        nlz←{(-1⌈+/∨\⍵≠'0')↑⍵}                  ⍝ without surplus leading zeros.
        nlz¨↓⍺[min+⍉vals]                       ⍝ array of ⍺-numbers.
    }

    disp ⎕d encode ¯9 to 10                     ⍝ decimal ¯9..10
┌→─┬──┬──┬──┬──┬──┬──┬──┬──┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬──┐
│¯9│¯8│¯7│¯6│¯5│¯4│¯3│¯2│¯1│0│1│2│3│4│5│6│7│8│9│10│
└─→┴─→┴─→┴─→┴─→┴─→┴─→┴─→┴─→┴→┴→┴→┴→┴→┴→┴→┴→┴→┴→┴─→┘

    disp '-0+'encode ¯9 to 10                   ⍝ balanced ternary ¯9..10
┌→──┬───┬───┬───┬───┬──┬──┬──┬─┬─┬─┬──┬──┬──┬───┬───┬───┬───┬───┬───┐
│-00│-0+│-+-│-+0│-++│--│-0│-+│-│0│+│+-│+0│++│+--│+-0│+-+│+0-│+00│+0+│
└──→┴──→┴──→┴──→┴──→┴─→┴─→┴─→┴→┴→┴→┴─→┴─→┴─→┴──→┴──→┴──→┴──→┴──→┴──→┘

    enc←{                                       ⍝ E-encode of simple number.
        ⍺{                                      ⍝ ⍺ is base.
            '¯'=⊃⍵:⍺ ratsum ∇ 1↓⍵               ⍝ absorb neg sign.
            '<0|',⍵,'|0>'                       ⍝ RU-wrap of number.
        }⍕⍵                                     ⍝ format if numeric.
    }                                           ⍝ :: lmr ← base ∇ num

    dec←{                                       ⍝ decode of E-number.
        '<0||0>'≡3⌽6↑¯3⌽⍵:3↓¯3↓⍵                ⍝ null RUs: simple number.
        '<0|'≡3↑⍵:⍵                             ⍝ null LRU: done.
        c0←(⍺⍳'0')⊃⌽⍺                           ⍝ complement of 0.
        ('<',c0,'|')≡3↑⍵:'¯',∇ ⍺ ratsum ⍵       ⍝ ..99 → ¯complement.
        ⍵                                       ⍝ otherwise dump raw number.
    }                                           ⍝ :: num ← base ∇ lmr

    table←{                                     ⍝ addition table.
        ⍺∘dec¨∘.(⍺ ratsum)⍨ ⍺∘enc¨⍺ encode ⍵    ⍝
    }                                           ⍝ ::

    clru←{⍵∘dec∘neg∘(⍵∘enc)¨⍵∘.,⍵}              ⍝ check lru-clearing.

⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝ Decimal

    base ← '0123456789'                 ⍝ regular decimal.

    sum ← neg ← base ratsum             ⍝ derived sum and negation functions.

    '<0|234|0>'sum'<0|567|0>'           ⍝ decimal: 234 + 567 → 801
<0|801|0>

    ↑sum/base∘enc¨base                  ⍝ 0+1+2+3+4+5+6+7+8+9
<0|45|0>

    '<12|0|123>'sum'<123|0|12>'         ⍝ check internal replication of RUs.
<9|7|800982>

    '<0|123.95|0>'sum'<0|4|3>'          ⍝ LeRoy's first example.
<0|128.28|3>

    '<0|92|34>'sum'<0|8.6|1>'           ⍝ LeRoy's (carry-out from RRU) example.
<0|100.9|54>

    '<0|92|34>'sum neg'<0|8.6|1>'       ⍝ LeRoy's (subtraction) example.
<0|83.7|32>

    '<0|92|34>'sum    '<9|1.3|8>'       ⍝ ditto with explicit complement.
<0|83.7|32>

    '<8999|5|0>'sum'<0|5|0>'            ⍝ test overflow into lru.
<0|1|0001>

   '<12|3|456>'sum'<123|4|56>'          ⍝ lru-clearing example.
<0|5|578760>

    '<0|0|0>'sum'<0|4|9>'               ⍝ 4.999... → 5
<0|5|0>

    '<0|0|0>'sum'<0|98.3|9>'            ⍝ 98.3999... → 98.4
<0|98.4|0>

    neg'<0|1|0>'                        ⍝ decimal ¯1
<9|9|0>

    neg neg'<0|1|0>'                    ⍝ round-trip negative qualifier.
<0|1|0>

    '<0|1234|0>'sum neg'<0|1234|0>'     ⍝ 0=⍵+-⍵
<0|0|0>

    disp base table ¯5 to 5             ⍝ decimal addition table ¯5..5
┌→──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐
↓¯10│¯9│¯8│¯7│¯6│¯5│¯4│¯3│¯2│¯1│0 │
├──→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┤
│¯9 │¯8│¯7│¯6│¯5│¯4│¯3│¯2│¯1│0 │1 │
├──→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┤
│¯8 │¯7│¯6│¯5│¯4│¯3│¯2│¯1│0 │1 │2 │
├──→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┤
│¯7 │¯6│¯5│¯4│¯3│¯2│¯1│0 │1 │2 │3 │
├──→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┤
│¯6 │¯5│¯4│¯3│¯2│¯1│0 │1 │2 │3 │4 │
├──→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┤
│¯5 │¯4│¯3│¯2│¯1│0 │1 │2 │3 │4 │5 │
├──→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┤
│¯4 │¯3│¯2│¯1│0 │1 │2 │3 │4 │5 │6 │
├──→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┤
│¯3 │¯2│¯1│0 │1 │2 │3 │4 │5 │6 │7 │
├──→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┤
│¯2 │¯1│0 │1 │2 │3 │4 │5 │6 │7 │8 │
├──→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┤
│¯1 │0 │1 │2 │3 │4 │5 │6 │7 │8 │9 │
├──→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┤
│ 0 │1 │2 │3 │4 │5 │6 │7 │8 │9 │10│
└──→┴─→┴─→┴─→┴─→┴─→┴─→┴─→┴─→┴─→┴─→┘

    disp clru base                      ⍝ check LRU-clearing.
┌→──┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
↓ 0 │¯1 │¯2 │¯3 │¯4 │¯5 │¯6 │¯7 │¯8 │¯9 │
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│¯10│¯11│¯12│¯13│¯14│¯15│¯16│¯17│¯18│¯19│
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│¯20│¯21│¯22│¯23│¯24│¯25│¯26│¯27│¯28│¯29│
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│¯30│¯31│¯32│¯33│¯34│¯35│¯36│¯37│¯38│¯39│
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│¯40│¯41│¯42│¯43│¯44│¯45│¯46│¯47│¯48│¯49│
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│¯50│¯51│¯52│¯53│¯54│¯55│¯56│¯57│¯58│¯59│
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│¯60│¯61│¯62│¯63│¯64│¯65│¯66│¯67│¯68│¯69│
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│¯70│¯71│¯72│¯73│¯74│¯75│¯76│¯77│¯78│¯79│
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│¯80│¯81│¯82│¯83│¯84│¯85│¯86│¯87│¯88│¯89│
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│¯90│¯91│¯92│¯93│¯94│¯95│¯96│¯97│¯98│¯99│
└──→┴──→┴──→┴──→┴──→┴──→┴──→┴──→┴──→┴──→┘

⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝ Balanced Ternary

    base ← '-0+'                        ⍝ balanced ternary.

    sum  ← neg ← base ratsum            ⍝ derived sum and neg functions.

    '<0|+--|0>'sum'<0|+-+|0>'           ⍝ 5 + 7 → 12
<0|++0|0>

    '<0|-|0>'sum'<0|---|0>'             ⍝ ¯1 + ¯13 → ¯14
<0|-+++|0>

    hlvs←'<-|-|0>' '<0|0|+>' '<0|+|->'  ⍝ three representations of one half.

    hlvs ∘.sum hlvs                     ⍝ half + half → 1
 <0|+|0>  <0|+|0>  <0|+|0> 
 <0|+|0>  <0|+|0>  <0|+|0> 
 <0|+|0>  <0|+|0>  <0|+|0> 

    '<-0|+|+>'sum'<-+|0|+>'             ⍝ LeRoy's example.
<0|++|0->

    disp base table ¯6 to 6             ⍝ balanced ternary addition table ¯6..6
┌→──┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
↓--0│--+│-0-│-00│-0+│-+-│-+0│-++│-- │-0 │-+ │ - │ 0 │
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│--+│-0-│-00│-0+│-+-│-+0│-++│-- │-0 │-+ │ - │ 0 │ + │
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│-0-│-00│-0+│-+-│-+0│-++│-- │-0 │-+ │ - │ 0 │ + │+- │
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│-00│-0+│-+-│-+0│-++│-- │-0 │-+ │ - │ 0 │ + │+- │+0 │
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│-0+│-+-│-+0│-++│-- │-0 │-+ │ - │ 0 │ + │+- │+0 │++ │
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│-+-│-+0│-++│-- │-0 │-+ │ - │ 0 │ + │+- │+0 │++ │+--│
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│-+0│-++│-- │-0 │-+ │ - │ 0 │ + │+- │+0 │++ │+--│+-0│
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│-++│-- │-0 │-+ │ - │ 0 │ + │+- │+0 │++ │+--│+-0│+-+│
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│-- │-0 │-+ │ - │ 0 │ + │+- │+0 │++ │+--│+-0│+-+│+0-│
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│-0 │-+ │ - │ 0 │ + │+- │+0 │++ │+--│+-0│+-+│+0-│+00│
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│-+ │ - │ 0 │ + │+- │+0 │++ │+--│+-0│+-+│+0-│+00│+0+│
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│ - │ 0 │ + │+- │+0 │++ │+--│+-0│+-+│+0-│+00│+0+│++-│
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│ 0 │ + │+- │+0 │++ │+--│+-0│+-+│+0-│+00│+0+│++-│++0│
└──→┴──→┴──→┴──→┴──→┴──→┴──→┴──→┴──→┴──→┴──→┴──→┴──→┘

    disp clru base                      ⍝ check LRU clearing.
┌→─┬──┬──┐
↓++│+0│+-│
├─→┼─→┼─→┤
│+ │0 │- │
├─→┼─→┼─→┤
│-+│-0│--│
└─→┴─→┴─→┘

⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝ Binary

    base ← '01'                         ⍝ regular binary.

    sum ← neg ← base ratsum             ⍝ derived sum and negation functions.

    disp base table ¯4 to 4             ⍝ addition table ¯4..4
┌→────┬────┬────┬────┬────┬───┬───┬───┬────┐
↓¯1000│¯111│¯110│¯101│¯100│¯11│¯10│¯1 │ 0  │
├────→┼───→┼───→┼───→┼───→┼──→┼──→┼──→┼───→┤
│¯111 │¯110│¯101│¯100│¯11 │¯10│¯1 │ 0 │ 1  │
├────→┼───→┼───→┼───→┼───→┼──→┼──→┼──→┼───→┤
│¯110 │¯101│¯100│¯11 │¯10 │¯1 │ 0 │ 1 │ 10 │
├────→┼───→┼───→┼───→┼───→┼──→┼──→┼──→┼───→┤
│¯101 │¯100│¯11 │¯10 │ ¯1 │ 0 │ 1 │10 │ 11 │
├────→┼───→┼───→┼───→┼───→┼──→┼──→┼──→┼───→┤
│¯100 │¯11 │¯10 │ ¯1 │ 0  │ 1 │10 │11 │100 │
├────→┼───→┼───→┼───→┼───→┼──→┼──→┼──→┼───→┤
│ ¯11 │¯10 │ ¯1 │ 0  │ 1  │10 │11 │100│101 │
├────→┼───→┼───→┼───→┼───→┼──→┼──→┼──→┼───→┤
│ ¯10 │ ¯1 │ 0  │ 1  │ 10 │11 │100│101│110 │
├────→┼───→┼───→┼───→┼───→┼──→┼──→┼──→┼───→┤
│ ¯1  │ 0  │ 1  │ 10 │ 11 │100│101│110│111 │
├────→┼───→┼───→┼───→┼───→┼──→┼──→┼──→┼───→┤
│  0  │ 1  │ 10 │ 11 │100 │101│110│111│1000│
└────→┴───→┴───→┴───→┴───→┴──→┴──→┴──→┴───→┘

    disp clru base                      ⍝ check LRU clearing.
┌→──┬───┐
↓ 0 │¯1 │
├──→┼──→┤
│¯10│¯11│
└──→┴──→┘

⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝ Skewed fours

    base ← '-0+#'               ⍝ positively-skewed four ("#" is double-plus).

    sum  ← neg ← base ratsum    ⍝ derived sum and negation functions.

    disp base table ¯6 to 6     ⍝ addition table ¯6..6
┌→──┬───┬───┬───┬───┬───┬───┬──┬──┬──┬──┬───┬───┐
↓-+0│-++│-+#│-#-│-#0│-#+│-##│--│-0│-+│-#│ - │ 0 │
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼─→┼─→┼─→┼─→┼──→┼──→┤
│-++│-+#│-#-│-#0│-#+│-##│-- │-0│-+│-#│- │ 0 │ + │
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼─→┼─→┼─→┼─→┼──→┼──→┤
│-+#│-#-│-#0│-#+│-##│-- │-0 │-+│-#│- │0 │ + │ # │
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼─→┼─→┼─→┼─→┼──→┼──→┤
│-#-│-#0│-#+│-##│-- │-0 │-+ │-#│- │0 │+ │ # │+- │
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼─→┼─→┼─→┼─→┼──→┼──→┤
│-#0│-#+│-##│-- │-0 │-+ │-# │- │0 │+ │# │+- │+0 │
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼─→┼─→┼─→┼─→┼──→┼──→┤
│-#+│-##│-- │-0 │-+ │-# │ - │0 │+ │# │+-│+0 │++ │
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼─→┼─→┼─→┼─→┼──→┼──→┤
│-##│-- │-0 │-+ │-# │ - │ 0 │+ │# │+-│+0│++ │+# │
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼─→┼─→┼─→┼─→┼──→┼──→┤
│-- │-0 │-+ │-# │ - │ 0 │ + │# │+-│+0│++│+# │#- │
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼─→┼─→┼─→┼─→┼──→┼──→┤
│-0 │-+ │-# │ - │ 0 │ + │ # │+-│+0│++│+#│#- │#0 │
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼─→┼─→┼─→┼─→┼──→┼──→┤
│-+ │-# │ - │ 0 │ + │ # │+- │+0│++│+#│#-│#0 │#+ │
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼─→┼─→┼─→┼─→┼──→┼──→┤
│-# │ - │ 0 │ + │ # │+- │+0 │++│+#│#-│#0│#+ │## │
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼─→┼─→┼─→┼─→┼──→┼──→┤
│ - │ 0 │ + │ # │+- │+0 │++ │+#│#-│#0│#+│## │+--│
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼─→┼─→┼─→┼─→┼──→┼──→┤
│ 0 │ + │ # │+- │+0 │++ │+# │#-│#0│#+│##│+--│+-0│
└──→┴──→┴──→┴──→┴──→┴──→┴──→┴─→┴─→┴─→┴─→┴──→┴──→┘

    disp clru base                      ⍝ check LRU clearing.
┌→──┬───┬───┬───┐
↓++ │+0 │+- │ # │
├──→┼──→┼──→┼──→┤
│ + │ 0 │ - │-# │
├──→┼──→┼──→┼──→┤
│-+ │-0 │-- │-##│
├──→┼──→┼──→┼──→┤
│-#+│-#0│-#-│-+#│
└──→┴──→┴──→┴──→┘

⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝

    base ← '=-0+'               ⍝ negatively-skewed four ("=" is double-minus).

    sum  ← neg ← base ratsum    ⍝ derived sum and negative functions.

    disp base table ¯6 to 6     ⍝ addition table ¯6..6
┌→──┬───┬──┬──┬──┬──┬───┬───┬───┬───┬───┬───┬───┐
↓-+0│-++│==│=-│=0│=+│-= │-- │-0 │-+ │ = │ - │ 0 │
├──→┼──→┼─→┼─→┼─→┼─→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│-++│== │=-│=0│=+│-=│-- │-0 │-+ │ = │ - │ 0 │ + │
├──→┼──→┼─→┼─→┼─→┼─→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│== │=- │=0│=+│-=│--│-0 │-+ │ = │ - │ 0 │ + │+= │
├──→┼──→┼─→┼─→┼─→┼─→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│=- │=0 │=+│-=│--│-0│-+ │ = │ - │ 0 │ + │+= │+- │
├──→┼──→┼─→┼─→┼─→┼─→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│=0 │=+ │-=│--│-0│-+│ = │ - │ 0 │ + │+= │+- │+0 │
├──→┼──→┼─→┼─→┼─→┼─→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│=+ │-= │--│-0│-+│= │ - │ 0 │ + │+= │+- │+0 │++ │
├──→┼──→┼─→┼─→┼─→┼─→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│-= │-- │-0│-+│= │- │ 0 │ + │+= │+- │+0 │++ │+==│
├──→┼──→┼─→┼─→┼─→┼─→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│-- │-0 │-+│= │- │0 │ + │+= │+- │+0 │++ │+==│+=-│
├──→┼──→┼─→┼─→┼─→┼─→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│-0 │-+ │= │- │0 │+ │+= │+- │+0 │++ │+==│+=-│+=0│
├──→┼──→┼─→┼─→┼─→┼─→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│-+ │ = │- │0 │+ │+=│+- │+0 │++ │+==│+=-│+=0│+=+│
├──→┼──→┼─→┼─→┼─→┼─→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│ = │ - │0 │+ │+=│+-│+0 │++ │+==│+=-│+=0│+=+│+-=│
├──→┼──→┼─→┼─→┼─→┼─→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│ - │ 0 │+ │+=│+-│+0│++ │+==│+=-│+=0│+=+│+-=│+--│
├──→┼──→┼─→┼─→┼─→┼─→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┤
│ 0 │ + │+=│+-│+0│++│+==│+=-│+=0│+=+│+-=│+--│+-0│
└──→┴──→┴─→┴─→┴─→┴─→┴──→┴──→┴──→┴──→┴──→┴──→┴──→┘

    disp clru base                      ⍝ check LRU clearing.
┌→──┬───┬───┬───┐
↓+-=│+=+│+=0│+=-│
├──→┼──→┼──→┼──→┤
│+==│++ │+0 │+- │
├──→┼──→┼──→┼──→┤
│+= │ + │ 0 │ - │
├──→┼──→┼──→┼──→┤
│ = │-+ │-0 │-- │
└──→┴──→┴──→┴──→┘

⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝ Pos-skewed five

    base ← '-0⌿≠≢'                      ⍝ Pos-skewed five (⌿ ≠ ≢  →  + ++ +++)

    sum  ← neg ← base ratsum            ⍝ sum and negative functions. 

    disp base table ¯8 to 8             ⍝ addition table ¯8..8 
┌→──┬───┬───┬───┬───┬───┬───┬───┬───┬───┬──┬──┬──┬──┬──┬──┬──┐
↓-≠-│-≠0│-≠⌿│-≠≠│-≠≢│-≢-│-≢0│-≢⌿│-≢≠│-≢≢│--│-0│-⌿│-≠│-≢│- │0 │
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┤
│-≠0│-≠⌿│-≠≠│-≠≢│-≢-│-≢0│-≢⌿│-≢≠│-≢≢│-- │-0│-⌿│-≠│-≢│- │0 │⌿ │
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┤
│-≠⌿│-≠≠│-≠≢│-≢-│-≢0│-≢⌿│-≢≠│-≢≢│-- │-0 │-⌿│-≠│-≢│- │0 │⌿ │≠ │
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┤
│-≠≠│-≠≢│-≢-│-≢0│-≢⌿│-≢≠│-≢≢│-- │-0 │-⌿ │-≠│-≢│- │0 │⌿ │≠ │≢ │
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┤
│-≠≢│-≢-│-≢0│-≢⌿│-≢≠│-≢≢│-- │-0 │-⌿ │-≠ │-≢│- │0 │⌿ │≠ │≢ │⌿-│
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┤
│-≢-│-≢0│-≢⌿│-≢≠│-≢≢│-- │-0 │-⌿ │-≠ │-≢ │- │0 │⌿ │≠ │≢ │⌿-│⌿0│
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┤
│-≢0│-≢⌿│-≢≠│-≢≢│-- │-0 │-⌿ │-≠ │-≢ │ - │0 │⌿ │≠ │≢ │⌿-│⌿0│⌿⌿│
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┤
│-≢⌿│-≢≠│-≢≢│-- │-0 │-⌿ │-≠ │-≢ │ - │ 0 │⌿ │≠ │≢ │⌿-│⌿0│⌿⌿│⌿≠│
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┤
│-≢≠│-≢≢│-- │-0 │-⌿ │-≠ │-≢ │ - │ 0 │ ⌿ │≠ │≢ │⌿-│⌿0│⌿⌿│⌿≠│⌿≢│
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┤
│-≢≢│-- │-0 │-⌿ │-≠ │-≢ │ - │ 0 │ ⌿ │ ≠ │≢ │⌿-│⌿0│⌿⌿│⌿≠│⌿≢│≠-│
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┤
│-- │-0 │-⌿ │-≠ │-≢ │ - │ 0 │ ⌿ │ ≠ │ ≢ │⌿-│⌿0│⌿⌿│⌿≠│⌿≢│≠-│≠0│
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┤
│-0 │-⌿ │-≠ │-≢ │ - │ 0 │ ⌿ │ ≠ │ ≢ │⌿- │⌿0│⌿⌿│⌿≠│⌿≢│≠-│≠0│≠⌿│
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┤
│-⌿ │-≠ │-≢ │ - │ 0 │ ⌿ │ ≠ │ ≢ │⌿- │⌿0 │⌿⌿│⌿≠│⌿≢│≠-│≠0│≠⌿│≠≠│
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┤
│-≠ │-≢ │ - │ 0 │ ⌿ │ ≠ │ ≢ │⌿- │⌿0 │⌿⌿ │⌿≠│⌿≢│≠-│≠0│≠⌿│≠≠│≠≢│
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┤
│-≢ │ - │ 0 │ ⌿ │ ≠ │ ≢ │⌿- │⌿0 │⌿⌿ │⌿≠ │⌿≢│≠-│≠0│≠⌿│≠≠│≠≢│≢-│
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┤
│ - │ 0 │ ⌿ │ ≠ │ ≢ │⌿- │⌿0 │⌿⌿ │⌿≠ │⌿≢ │≠-│≠0│≠⌿│≠≠│≠≢│≢-│≢0│
├──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼──→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┤
│ 0 │ ⌿ │ ≠ │ ≢ │⌿- │⌿0 │⌿⌿ │⌿≠ │⌿≢ │≠- │≠0│≠⌿│≠≠│≠≢│≢-│≢0│≢⌿│
└──→┴──→┴──→┴──→┴──→┴──→┴──→┴──→┴──→┴──→┴─→┴─→┴─→┴─→┴─→┴─→┴─→┘

    disp clru base                      ⍝ check LRU clearing.
┌→──┬───┬───┬───┬───┐
↓⌿⌿ │⌿0 │⌿- │ ≢ │ ≠ │
├──→┼──→┼──→┼──→┼──→┤
│ ⌿ │ 0 │ - │-≢ │-≠ │
├──→┼──→┼──→┼──→┼──→┤
│-⌿ │-0 │-- │-≢≢│-≢≠│
├──→┼──→┼──→┼──→┼──→┤
│-≢⌿│-≢0│-≢-│-≠≢│-≠≠│
├──→┼──→┼──→┼──→┼──→┤
│-≠⌿│-≠0│-≠-│-⌿≢│-⌿≠│
└──→┴──→┴──→┴──→┴──→┘

⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝ Skewed six

    base ← '≡=-0+#'                     ⍝ Skewed six: ≡ is triple-minus.

    sum  ← neg ← base ratsum            ⍝ sum and negative functions.

    disp base table ¯8 to 8             ⍝ addition table ¯8..8
┌→─┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬───┬───┐
↓≡#│=≡│==│=-│=0│=+│=#│-≡│-=│--│-0│-+│-#│≡ │= │ - │ 0 │
├─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼──→┼──→┤
│=≡│==│=-│=0│=+│=#│-≡│-=│--│-0│-+│-#│≡ │= │- │ 0 │ + │
├─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼──→┼──→┤
│==│=-│=0│=+│=#│-≡│-=│--│-0│-+│-#│≡ │= │- │0 │ + │ # │
├─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼──→┼──→┤
│=-│=0│=+│=#│-≡│-=│--│-0│-+│-#│≡ │= │- │0 │+ │ # │+≡ │
├─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼──→┼──→┤
│=0│=+│=#│-≡│-=│--│-0│-+│-#│≡ │= │- │0 │+ │# │+≡ │+= │
├─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼──→┼──→┤
│=+│=#│-≡│-=│--│-0│-+│-#│≡ │= │- │0 │+ │# │+≡│+= │+- │
├─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼──→┼──→┤
│=#│-≡│-=│--│-0│-+│-#│≡ │= │- │0 │+ │# │+≡│+=│+- │+0 │
├─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼──→┼──→┤
│-≡│-=│--│-0│-+│-#│≡ │= │- │0 │+ │# │+≡│+=│+-│+0 │++ │
├─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼──→┼──→┤
│-=│--│-0│-+│-#│≡ │= │- │0 │+ │# │+≡│+=│+-│+0│++ │+# │
├─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼──→┼──→┤
│--│-0│-+│-#│≡ │= │- │0 │+ │# │+≡│+=│+-│+0│++│+# │#≡ │
├─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼──→┼──→┤
│-0│-+│-#│≡ │= │- │0 │+ │# │+≡│+=│+-│+0│++│+#│#≡ │#= │
├─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼──→┼──→┤
│-+│-#│≡ │= │- │0 │+ │# │+≡│+=│+-│+0│++│+#│#≡│#= │#- │
├─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼──→┼──→┤
│-#│≡ │= │- │0 │+ │# │+≡│+=│+-│+0│++│+#│#≡│#=│#- │#0 │
├─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼──→┼──→┤
│≡ │= │- │0 │+ │# │+≡│+=│+-│+0│++│+#│#≡│#=│#-│#0 │#+ │
├─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼──→┼──→┤
│= │- │0 │+ │# │+≡│+=│+-│+0│++│+#│#≡│#=│#-│#0│#+ │## │
├─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼──→┼──→┤
│- │0 │+ │# │+≡│+=│+-│+0│++│+#│#≡│#=│#-│#0│#+│## │+≡≡│
├─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼─→┼──→┼──→┤
│0 │+ │# │+≡│+=│+-│+0│++│+#│#≡│#=│#-│#0│#+│##│+≡≡│+≡=│
└─→┴─→┴─→┴─→┴─→┴─→┴─→┴─→┴─→┴─→┴─→┴─→┴─→┴─→┴─→┴──→┴──→┘

    disp clru base                      ⍝ check LRU clearing.
┌→──┬───┬───┬───┬───┬───┐
↓+=≡│+≡#│+≡+│+≡0│+≡-│+≡=│
├──→┼──→┼──→┼──→┼──→┼──→┤
│+≡≡│## │#+ │#0 │#- │#= │
├──→┼──→┼──→┼──→┼──→┼──→┤
│#≡ │+# │++ │+0 │+- │+= │
├──→┼──→┼──→┼──→┼──→┼──→┤
│+≡ │ # │ + │ 0 │ - │ = │
├──→┼──→┼──→┼──→┼──→┼──→┤
│ ≡ │-# │-+ │-0 │-- │-= │
├──→┼──→┼──→┼──→┼──→┼──→┤
│-≡ │=# │=+ │=0 │=- │== │
└──→┴──→┴──→┴──→┴──→┴──→┘

⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝ Errors

    bad ← ⎕d ratsum

    bad'1|2|3'
11::bad <>s

    bad'<1|2>'              ⍝ (for the moment)
11::bad ||s

    bad'<123>'              ⍝ (for the moment)
11::bad ||s

    bad'<0|3x|0>'
11::bad char

    bad'<9|5|>'
11::null field

    '123'ratsum'1'          ⍝ no zero.
11::missing zero

    '101'ratsum'1'          ⍝ too many ones.
11::duplicate digits

    '{012}3'ratsum'0'       ⍝ special chars excluded as digits.
11::bad digit

⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝ Reciprocals

    recip←{                             ⍝ check ⍵≡÷⍺ in current base.
        one←base enc(1+base⍳'0')⊃base   ⍝ unity in current base.
        sum←↑base ratsum/⍺/⊂⍵~' '       ⍝ sum of ⍺ reciprocals
        ~sum≡,one:'wrong:',sum          ⍝   should be unity.
    }                                   ⍝ :: n ∇ rexp

    base ← '{0123456789}'               ⍝ decimal reciprocals:

        1 recip' <0|1|0>        '
        2 recip' <0|0.5|0>      '
        3 recip' <0|0|3>        '
        4 recip' <0|0.25|0>     '
        5 recip' <0|0.2|0>      '
        6 recip' <0|0.1|6>      '
        7 recip' <0|0|142857>   '
        8 recip' <0|0.125|0>    '
        9 recip' <0|0|1>        '

    base ← '{01}'                       ⍝ binary reciprocals:

        1 recip' <0|1|0>        '
        2 recip' <0|0.1|0>      '
        3 recip' <0|0|01>       '
        4 recip' <0|0.01|0>     '
        5 recip' <0|0|0011>     '
        6 recip' <0|0.0|01>     '
        7 recip' <0|0|001>      '
        8 recip' <0|0.001|0>    '
        9 recip' <0|0|000111>   '

    base ← '{0123456789abcdef}'         ⍝ hexadecimal reciprocals:

        1 recip' <0|1|0>        '
        2 recip' <0|0.8|0>      '
        3 recip' <0|0|5>        '
        4 recip' <0|0.4|0>      '
        5 recip' <0|0|3>        '
        6 recip' <0|0.2|a>      '
        7 recip' <0|0|249>      '
        8 recip' <0|0.2|0>      '
        9 recip' <0|0|1c7>      '

    base ← '{-0+}'                      ⍝ balanced ternary reciprocals:

        1 recip' <0|+|0>      '
        2 recip' <0|0|+>      '
        3 recip' <0|0.+|0>    '
        4 recip' <0|0|+->     '
        5 recip' <0|0|+--+>   '
        6 recip' <0|0.0|+>    '
        7 recip' <0|0|0++0--> '
        8 recip' <0|0|0+>     '
        9 recip' <0|0.0+|0>   '

    base ← '{-0+#}'                     ⍝ pos-skewed four reciprocals:

        1 recip' <0|+|0>    '
        2 recip' <0|0.#|0>  '
        3 recip' <0|0|+>    '
        4 recip' <0|0.+|0>  '
        5 recip' <0|0|+->   '
        6 recip' <0|0.0|#>  '
        7 recip' <0|0|0#+>  '
        8 recip' <0|0.0#|0> '
        9 recip' <0|0|0#->  '

    base ← '{=-0+}'                     ⍝ neg-skewed four reciprocals:

        1 recip' <0|+|0>    '
        2 recip' <0|+.=|0>  '
        3 recip' <0|0|+>    '
        4 recip' <0|0.+|0>  '
        5 recip' <0|0|+->   '
        6 recip' <0|0.+|->  '
        7 recip' <0|0|+=+>  '
        8 recip' <0|0.+=|0> '
        9 recip' <0|0|+=->  '

⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝ Misc

    bt_r64 ← '<0|0|000++-++---0-+0->'               ⍝ balanced ternary ÷64.

    6('-0+'ratsum{⍵ ⍺⍺ ⍵})pow bt_r64                ⍝ 6-fold doubling of ÷64 → 1
<0|+|0>

    r99_2 ← {'<0|0|',⍵,'99>'}↑,/1↓∘⍕¨100 to 197     ⍝ decimal ÷99×99

    r99_2                                           ⍝ (longish rru):
<0|0|000102030405060708091011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969799>

    ↑⎕d ratsum/99/⊂r99_2                            ⍝ 99 × ÷99×99 → ÷99
<0|0|01>

⍝⍝⍝⍝ Various number systems ⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝

    bases  ← ⍬                          ⍝ description       signature
                                        ⍝ ¯¯¯¯¯¯¯¯¯¯¯       ¯¯¯¯¯¯¯¯¯
    bases ,←⊂ '0123456789'              ⍝ decimal           _0_9
    bases ,←⊂ '01'                      ⍝ binary            _0_1
    bases ,←⊂ '210'                     ⍝ negative ternary  _2_0
    bases ,←⊂ '0123456789abcdef'        ⍝ hexadecimal       _0_15
    bases ,←⊂ '-0+'                     ⍝ balanced ternary  _1_1
    bases ,←⊂ '-0+#'                    ⍝ pos-skewed four   _1_2
    bases ,←⊂ '=-0+'                    ⍝ neg-skewed four   _2_1
    bases ,←⊂ '≡=-0+'                   ⍝ neg-skewed five   _3_1
    bases ,←⊂ '=-0+#'                   ⍝ balanced five     _2_2
    bases ,←⊂ '-0⌿≠≢'                   ⍝ pos-skewed five   _1_3
    bases ,←⊂ '≡=-0+#'                  ⍝ skewed six        _3_2
    bases ,←⊂ '=-0⌿≠≢'                  ⍝ skewed six        _2_3
    bases ,←⊂ '-0⌿≠≢#'                  ⍝ skewed six        _1_4
    bases ,←⊂ '≡=-0⌿≠≢'                 ⍝ balanced seven    _3_3

    disp ↑bases encode¨⊂¯5 to 12        ⍝ ¯5..12 per number system.
┌→───┬────┬───┬───┬──┬─┬──┬──┬───┬───┬───┬───┬───┬────┬────┬────┬────┬────┐
↓ ¯5 │ ¯4 │¯3 │¯2 │¯1│0│1 │2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8  │ 9  │ 10 │ 11 │ 12 │
├───→┼───→┼──→┼──→┼─→┼→┼─→┼─→┼──→┼──→┼──→┼──→┼──→┼───→┼───→┼───→┼───→┼───→┤
│¯101│¯100│¯11│¯10│¯1│0│1 │10│11 │100│101│110│111│1000│1001│1010│1011│1100│
├───→┼───→┼──→┼──→┼─→┼→┼─→┼─→┼──→┼──→┼──→┼──→┼──→┼───→┼───→┼───→┼───→┼───→┤
│ 12 │ 11 │10 │ 2 │1 │0│¯1│¯2│¯10│¯11│¯12│¯20│¯21│¯22 │¯100│¯101│¯102│¯110│
├───→┼───→┼──→┼──→┼─→┼→┼─→┼─→┼──→┼──→┼──→┼──→┼──→┼───→┼───→┼───→┼───→┼───→┤
│ ¯5 │ ¯4 │¯3 │¯2 │¯1│0│1 │2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8  │ 9  │ a  │ b  │ c  │
├───→┼───→┼──→┼──→┼─→┼→┼─→┼─→┼──→┼──→┼──→┼──→┼──→┼───→┼───→┼───→┼───→┼───→┤
│-++ │ -- │-0 │-+ │- │0│+ │+-│+0 │++ │+--│+-0│+-+│+0- │+00 │+0+ │++- │++0 │
├───→┼───→┼──→┼──→┼─→┼→┼─→┼─→┼──→┼──→┼──→┼──→┼──→┼───→┼───→┼───→┼───→┼───→┤
│ -- │ -0 │-+ │-# │- │0│+ │# │+- │+0 │++ │+# │#- │ #0 │ #+ │ ## │+-- │+-0 │
├───→┼───→┼──→┼──→┼─→┼→┼─→┼─→┼──→┼──→┼──→┼──→┼──→┼───→┼───→┼───→┼───→┼───→┤
│ -- │ -0 │-+ │ = │- │0│+ │+=│+- │+0 │++ │+==│+=-│+=0 │+=+ │+-= │+-- │+-0 │
├───→┼───→┼──→┼──→┼─→┼→┼─→┼─→┼──→┼──→┼──→┼──→┼──→┼───→┼───→┼───→┼───→┼───→┤
│ -0 │ -+ │ ≡ │ = │- │0│+ │+≡│+= │+- │+0 │++ │+≡≡│+≡= │+≡- │+≡0 │+≡+ │+=≡ │
├───→┼───→┼──→┼──→┼─→┼→┼─→┼─→┼──→┼──→┼──→┼──→┼──→┼───→┼───→┼───→┼───→┼───→┤
│ -0 │ -+ │-# │ = │- │0│+ │# │+= │+- │+0 │++ │+# │ #= │ #- │ #0 │ #+ │ ## │
├───→┼───→┼──→┼──→┼─→┼→┼─→┼─→┼──→┼──→┼──→┼──→┼──→┼───→┼───→┼───→┼───→┼───→┤
│ -0 │ -⌿ │-≠ │-≢ │- │0│⌿ │≠ │ ≢ │⌿- │⌿0 │⌿⌿ │⌿≠ │ ⌿≢ │ ≠- │ ≠0 │ ≠⌿ │ ≠≠ │
├───→┼───→┼──→┼──→┼─→┼→┼─→┼─→┼──→┼──→┼──→┼──→┼──→┼───→┼───→┼───→┼───→┼───→┤
│ -+ │ -# │ ≡ │ = │- │0│+ │# │+≡ │+= │+- │+0 │++ │ +# │ #≡ │ #= │ #- │ #0 │
├───→┼───→┼──→┼──→┼─→┼→┼─→┼─→┼──→┼──→┼──→┼──→┼──→┼───→┼───→┼───→┼───→┼───→┤
│ -⌿ │ -≠ │-≢ │ = │- │0│⌿ │≠ │ ≢ │⌿= │⌿- │⌿0 │⌿⌿ │ ⌿≠ │ ⌿≢ │ ≠= │ ≠- │ ≠0 │
├───→┼───→┼──→┼──→┼─→┼→┼─→┼─→┼──→┼──→┼──→┼──→┼──→┼───→┼───→┼───→┼───→┼───→┤
│ -⌿ │ -≠ │-≢ │-# │- │0│⌿ │≠ │ ≢ │ # │⌿- │⌿0 │⌿⌿ │ ⌿≠ │ ⌿≢ │ ⌿# │ ≠- │ ≠0 │
├───→┼───→┼──→┼──→┼─→┼→┼─→┼─→┼──→┼──→┼──→┼──→┼──→┼───→┼───→┼───→┼───→┼───→┤
│ -≠ │ -≢ │ ≡ │ = │- │0│⌿ │≠ │ ≢ │⌿≡ │⌿= │⌿- │⌿0 │ ⌿⌿ │ ⌿≠ │ ⌿≢ │ ≠≡ │ ≠= │
└───→┴───→┴──→┴──→┴─→┴→┴─→┴─→┴──→┴──→┴──→┴──→┴──→┴───→┴───→┴───→┴───→┴───→┘

    ⍝ Various answers to the meaning of Life, the Universe, and Everything:

    disp ↑bases encode¨42
┌→─┬──────┬─────┬──┬─────┬───┬────┬────┬───┬───┬───┬───┬───┬───┐
│42│101010│¯1120│2a│+---0│###│+--=│+≡-≡│#=#│⌿≢≠│++0│⌿⌿0│⌿⌿0│⌿-0│
└─→┴─────→┴────→┴─→┴────→┴──→┴───→┴───→┴──→┴──→┴──→┴──→┴──→┴──→┘

Back to: code

Back to: Workspaces

Trouble seeing APL font?