Created
December 15, 2012 19:53
-
-
Save cbumgard/4298666 to your computer and use it in GitHub Desktop.
FizzBuzz in Javascript using pattern-matching library Funcy (https://github.com/bramstein/funcy). Inspired by this Clojure example: https://github.com/clojure/core.match.
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
var fun = require('funcy') | |
, _ = fun.wildcard | |
, n; | |
for (n = 1; n <= 100; n++) { | |
console.log( | |
fun( | |
[[0, 0], function() { return 'FizzBuzz'; }], | |
[[0, _], function() { return 'Fizz'; }], | |
[[_, 0], function() { return 'Buzz'; }], | |
[_, function() { return n; }] | |
)([n % 3, n % 5]) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment