~jojo/Carth

ref: 749208029494a7c48ce04444a513424f4b998416 Carth/examples/fizzbuzz.carth -rw-r--r-- 422 bytes
74920802JoJo update TODO 6 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
(import std)

(define main fizzbuzz)

(define fizzbuzz
  (io/for (range 1 100)
          (<o display fizzbuzz')))

(define (fizzbuzz' n)
  (match [(divisible? n 3) (divisible? n 5)]
    (case [False False] (my-show-int n))
    (case [True  False] "Fizz")
    (case [False True ] "Buzz")
    (case [True  True ] "Fizzbuzz")))

(define my-show-int
  (fmatch
    (case 1 "one")
    (case 2 "two")
    (case n (show-int n))))