Skip to content

Instantly share code, notes, and snippets.

@cbumgard
Created December 15, 2012 19:53
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 cbumgard/4298666 to your computer and use it in GitHub Desktop.
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.
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