-
-
Save dyoo/4696161 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang typed/racket | |
(define-type T (U String Integer)) | |
(: fizzbuzz/1 : (Integer -> T)) | |
(define (fizzbuzz/1 x) | |
(define mod3 (zero? (modulo x 3))) | |
(define mod5 (zero? (modulo x 5))) | |
(cond [(and mod3 mod5) "fizzbuzz"] | |
[mod3 "fizz"] | |
[mod5 "buzz"] | |
[else x])) | |
(for: ([i : Integer (in-range 100)]) | |
(print (fizzbuzz/1 i)) | |
(newline)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment