Skip to content

Instantly share code, notes, and snippets.

@dyoo
Forked from bradclawsie/fizzbuzz.rkt
Last active December 12, 2015 02:08
Show Gist options
  • Save dyoo/4696161 to your computer and use it in GitHub Desktop.
Save dyoo/4696161 to your computer and use it in GitHub Desktop.
#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