tricu

An interpreted language for exploring Tree Calculus
Log | Files | Refs | README | LICENSE

lists.tri (565B)


      1 !import bd2c14d6db6b69308a5252a8e839705a55d30e815f012900b094315263e08d81 as List
      2 !export count
      3 !export total
      4 
      5 -- Collect values in a list.
      6 numbers = [2 4 6]
      7 count = List.length numbers
      8 total = List.sum numbers
      9 
     10 -- Evaluate count with Natural number: the result is 3.
     11 -- Spaces separate items. [] is the empty list.
     12 -- Add import supplies List, including length and sum.
     13 
     14 -- Try total with Natural number: the result is 12.
     15 -- Exercise: add 8 to numbers. Check count (4) and total (20).
     16 -- Then try numbers = []: both results become 0.
     17 -- Next: Transforming a list.