Skip to content

Instantly share code, notes, and snippets.

@nilp0inter
Last active January 7, 2020 13:06
Show Gist options
  • Save nilp0inter/24b39c8372a90c92cea7e681162701d2 to your computer and use it in GitHub Desktop.
Save nilp0inter/24b39c8372a90c92cea7e681162701d2 to your computer and use it in GitHub Desktop.
The first beautiful implementation of FizzBuzz?
#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
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment