We're a place where coders share, stay up-to-date and grow their careers.
Here's my implementation in Racket
(define (mult-15? n) (and (mult-5? n) (mult-3? n))) (define (mult-5? n) (= (modulo n 5) 0)) (define (mult-3? n) (= (modulo n 3) 0)) (define (fizzbuzz n) (cond [(mult-15? n) "FizzBuzz"] [(mult-5? n) "Buzz"] [(mult-3? n) "Fizz"] [else n])) (define (print-list xs) (map displayln xs)) (print-list (map fizzbuzz (range 1 101)))
The print-list function is a bit redundant, since (map fizzbuzz (range 1 101)) will already print the resulting list to the console.
print-list
(map fizzbuzz (range 1 101))
Ah come on @avalander - surely you should've written a FizzBuzz DSL in Racket? 😉
I should, but I don't know enough Racket for that yet 😅
Great stuff! I like racket a lot, but I haven't written any code in it myself. The fact that there are so many dialects of it is pretty cool to me.
Thanks! I've just started learning it myself. I can recommend the book Realm of Racket if you want to give it a shot.
Here's my implementation in Racket
The
print-list
function is a bit redundant, since(map fizzbuzz (range 1 101))
will already print the resulting list to the console.Ah come on @avalander - surely you should've written a FizzBuzz DSL in Racket? 😉
I should, but I don't know enough Racket for that yet 😅
Great stuff! I like racket a lot, but I haven't written any code in it myself. The fact that there are so many dialects of it is pretty cool to me.
Thanks! I've just started learning it myself. I can recommend the book Realm of Racket if you want to give it a shot.