tricu

A lazy functional language based on Tree Calculus
Log | Files | Refs | README | LICENSE

layouts.tri (1131B)


      1 -- Pure binary64 implementation; trusted internal helpers.
      2 !import native_math as N
      3 !export drop1
      4 !export drop11
      5 !export drop16
      6 !export drop2
      7 !export drop32
      8 !export drop52
      9 !export low11
     10 !export low52
     11 
     12 triage leaf stem fork = t (t leaf stem) fork
     13 choose yes no value = triage no (_ : yes) (_ _ : yes) value
     14 head value = triage t (_ : t) (a _ : a) value
     15 tail value = triage t (_ : t) (_ b : b) value
     16 drop1 = tail
     17 drop2 x = drop1 (drop1 x)
     18 drop4 x = drop2 (drop2 x)
     19 drop8 x = drop4 (drop4 x)
     20 drop16 x = drop8 (drop8 x)
     21 drop32 x = drop16 (drop16 x)
     22 drop52 x = drop4 (drop16 (drop32 x))
     23 drop11 x = drop1 (drop2 (drop8 x))
     24 node bit rest = choose (t bit rest) (choose t (t bit rest) (N.zero rest)) bit
     25 join1 low high = node (head low) high
     26 join2 low high = join1 low (join1 (drop1 low) high)
     27 join4 low high = join2 low (join2 (drop2 low) high)
     28 join8 low high = join4 low (join4 (drop4 low) high)
     29 join16 low high = join8 low (join8 (drop8 low) high)
     30 join32 low high = join16 low (join16 (drop16 low) high)
     31 low11 x = join8 x (join2 (drop8 x) (join1 (drop2 (drop8 x)) t))
     32 low52 x = join32 x (join16 (drop32 x) (join4 (drop16 (drop32 x)) t))