tricu

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

arithmetic.tri (677B)


      1 !import 7f87549d587fa8c3be88af0ea988db3adcc3b35f1ffb48973553491b075614db as Math
      2 !export *
      3 
      4 -- Add the prices of two items.
      5 total = Math.add 5 7
      6 -- Evaluate total with Natural number.
      7 -- Result: 12.
      8 -- Add import supplies the library identity; Math is our short name.
      9 
     10 -- Function calls use spaces: Math.multiply takes two numbers.
     11 product = Math.multiply 5 7
     12 
     13 -- Parentheses make one calculation the input to another.
     14 grouped = Math.multiply (Math.add 5 7) 2
     15 
     16 -- Try product (35), then grouped (24), with Natural number.
     17 -- Exercise: change total to add the prices of two things you would buy.
     18 -- Numbers here are whole numbers starting at zero.
     19 -- Next: Your first function.