Last active
January 7, 2020 13:06
-
-
Save nilp0inter/24b39c8372a90c92cea7e681162701d2 to your computer and use it in GitHub Desktop.
The first beautiful implementation of FizzBuzz?
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 2d racket | |
(require 2d/match) | |
(define (fizz? n) | |
(= 0 (modulo n 5))) | |
(define (buzz? n) | |
(= 0 (modulo n 3))) | |
(define (fizzbuzz n) | |
#2dmatch | |
╔═════════════════════╦══════════════╦════════════════════╗ | |
║ (fizz? n) (buzz? n) ║ #t ║ #f ║ | |
╠═════════════════════╬══════════════╬════════════════════╣ | |
║ #t ║ "FizzBuzz" ║ "Buzz" ║ | |
╠═════════════════════╬══════════════╬════════════════════╣ | |
║ #f ║ "Fizz" ║ (number->string n) ║ | |
╚═════════════════════╩══════════════╩════════════════════╝) |
CesarGallego
commented
Feb 13, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment