-
-
Save spdegabrielle/db2b8ba5e1c888a01e9ba5c0dbe9a5dc to your computer and use it in GitHub Desktop.
The first beautiful implementation of FizzBuzz?
This file contains hidden or 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 2d racket | |
(require 2d/match) | |
(define (fizz? n) | |
(zero? (modulo n 5))) | |
(define (buzz? n) | |
(zero? (modulo n 3))) | |
(define (fizzbuzz n) | |
#2dmatch | |
╔═════════════════════╦══════════════╦════════════════════╗ | |
║ (fizz? n) (buzz? n) ║ #t ║ #f ║ | |
╠═════════════════════╬══════════════╬════════════════════╣ | |
║ #t ║ "FizzBuzz" ║ "Buzz" ║ | |
╠═════════════════════╬══════════════╬════════════════════╣ | |
║ #f ║ "Fizz" ║ (number->string n) ║ | |
╚═════════════════════╩══════════════╩════════════════════╝) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment