~jojo/Carth

ref: 55fb4f948f1f3797078b584dc60b4f7dd68b37ed Carth/examples/fizzbuzz.carth -rw-r--r-- 422 bytes
55fb4f94JoJo Check `cast` in Infer instead of Gen 5 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))))