tricu

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

choices.tri (567B)


      1 !export message
      2 
      3 -- Choose an answer by matching an input.
      4 message 0 = "Your basket is empty."
      5 message 1 = "You have one item."
      6 message _ = "You have several items."
      7 
      8 -- Evaluate message 0 with Text: Your basket is empty.
      9 -- These equations are tried from top to bottom.
     10 -- _ matches any remaining input: this is the fallback.
     11 -- Try message 1, then message 4, using Text.
     12 
     13 -- Exercise: add a message for 2 items before the fallback equation.
     14 -- Keep the equations together so they define one function.
     15 -- Next: try a Practical Example, or browse Language reference.