Created
December 23, 2014 22:19
-
-
Save timyates/32207c13b1cda05d5393 to your computer and use it in GitHub Desktop.
FizzBuzz with groovy-stream and no conditionals
This file contains 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
@Grab('com.bloidonia:groovy-stream:0.9.0') | |
import groovy.stream.* | |
def (n, f, b, fb) = [Closure.IDENTITY, { 'fizz' }, { 'buzz' }, {'fizzbuzz'}] | |
def fns = Stream.from([n, n, f, n, b, f, n, n, f, b, n, f, n, n, fb]).repeat() | |
def num = Stream.from(1..100).zip(fns) { counter, fn -> fn(counter) } | |
num.each { println it } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It got this, but it lacks your elegance