tricu

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

fizzbuzz.scp (491B)


      1 -- Initial state: (2, 4), two compact phase values.
      2 -- Zero labels the current position for period three or five, respectively.
      3 !export fizzbuzz
      4 consumer fizzbuzz
      5   []         @ _             => []
      6   [n | rest] @ (three, five) => [
      7     match (three, five) of (
      8       (0, 0) => "FizzBuzz"
      9       | (0, _) => "Fizz"
     10       | (_, 0) => "Buzz"
     11       | _ => n)
     12     | recur rest @ (
     13       match three of (0 => 2 | 1 => 0 | 2 => 1),
     14       match five of (0 => 4 | 1 => 0 | 2 => 1 | 3 => 2 | 4 => 3))]