~jojo/Carth

ref: 2ffd86d155a095c6a5293cc68fe7ac02daed235e Carth/examples/fizzbuzz.carth -rw-r--r-- 422 bytes
2ffd86d1JoJo Fix partitionWith reversing lists. Caused def order issue in genInit 1 year, 2 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))))