Skip to content

Instantly share code, notes, and snippets.

@spdegabrielle
Forked from nilp0inter/fizzbuzz.rkt
Last active September 26, 2020 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spdegabrielle/db2b8ba5e1c888a01e9ba5c0dbe9a5dc to your computer and use it in GitHub Desktop.
Save spdegabrielle/db2b8ba5e1c888a01e9ba5c0dbe9a5dc to your computer and use it in GitHub Desktop.
The first beautiful implementation of FizzBuzz?
#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