Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

LiveScript

Name: Anonymous 2013-11-11 22:20

Did you ever tried this thing?

FizzBuzzBazz in 62 characters:

[++x>?[k+\zz for k,v of{Fi:3,Bu:5,Ba:7}|x%v<1]*'' for x to 99]


Currying:

times = (x, y) --> x * y
times 2, 3 #=> 6 (normal use works as expected)
double = times 2
double 5 #=> 10


Composing Functions:

even = (x) -> x % 2 == 0
invert = (x) -> not x
odd = invert << even


Comprehensions:

r = [x + y for x in [1, 2] for y in ['a', 'b']]
r #=> ['1a', '1b', '2a', '2b']


It compiles to JavaScript, so basically is a CoffeeScript well done.
http://livescript.net/

Name: Anonymous 2013-11-12 17:38

[++x>?[k+\zz for k,v of{Fi:3,Bu:5,Ba:7}|x%v<1]*'' for x to 99]

Wow, thats unreadable.

Here's much more clear FIOC solution. Only 33 characters more (note that it prints correctly Fizz instead of Fi)

[''.join(int(b<1)*a for (a,b) in [('Fizz',x%3),('Buzz',x%5),('Bazz',x%7)]) for x in range(100)]

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List