tricu

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

transform-list.tri (439B)


      1 !import bd2c14d6db6b69308a5252a8e839705a55d30e815f012900b094315263e08d81 *
      2 !export *
      3 
      4 -- Functions are values too. We can pass one to another function.
      5 double number = mul number 2
      6 numbers = [2 4 6]
      7 
      8 -- map takes a function, then a list, and applies it to every item.
      9 doubled = map double numbers
     10 -- map builds a new list; the original numbers are unchanged.
     11 total = sum doubled
     12 
     13 -- Try multiplying by 3 instead.
     14 -- Next: Making a choice.