~jojo/Carth

ref: ae1d242d7d48292779dcbd953e5864bb4211e1ca Carth/examples/fizzbuzz.carth -rw-r--r-- 422 bytes
ae1d242dJoJo Update stackage release & use default-extensions in cabal file 9 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))))