hnock

A Nock interpreter.
git clone git://git.jtobin.io/hnock.git
Log | Files | Refs | README | LICENSE

5.txt (876B)


      1 A noun is an atom or a cell.  An atom is a natural number.  A cell is an ordered
      2 pair of nouns.
      3 
      4 nock(a)          *a
      5 [a b c]          [a [b c]]
      6 
      7 ?[a b]           0
      8 ?a               1
      9 +[a b]           +[a b]
     10 +a               1 + a
     11 =[a a]           0
     12 =[a b]           1
     13 =a               =a
     14 
     15 /[1 a]           a
     16 /[2 a b]         a
     17 /[3 a b]         b
     18 /[(a + a) b]     /[2 /[a b]]
     19 /[(a + a + 1) b] /[3 /[a b]]
     20 /a               /a
     21 
     22 *[a [b c] d]     [*[a b c] *[a d]]
     23 
     24 *[a 0 b]         /[b a]
     25 *[a 1 b]         b
     26 *[a 2 b c]       *[*[a b] *[a c]]
     27 *[a 3 b]         ?*[a b]
     28 *[a 4 b]         +*[a b]
     29 *[a 5 b]         =*[a b]
     30 
     31 *[a 6 b c d]     *[a 2 [0 1] 2 [1 c d] [1 0] 2 [1 2 3] [1 0] 4 4 b]
     32 *[a 7 b c]       *[a 2 b 1 c]
     33 *[a 8 b c]       *[a 7 [[7 [0 1] b] 0 1] c]
     34 *[a 9 b c]       *[a 7 c 2 [0 1] 0 b]
     35 *[a 10 [b c] d]  *[a 8 c 7 [0 3] d]
     36 *[a 10 b c]      *[a c]
     37 
     38 *a               *a
     39