Last active
May 19, 2018 18:26
-
-
Save rodrigoSaladoAnaya/dbc7056a101a4252041775df129f9eda to your computer and use it in GitHub Desktop.
FizzBuzz with RxGroovy
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
import rx.Observable | |
def numbers = Observable.range(1, 100) | |
def fizz = numbers.map { n -> n % 3 == 0 ? 'Fizz' : '' } | |
def buzz = numbers.map { n -> n % 5 == 0 ? 'Buzz' : '' } | |
Observable.zip(fizz, buzz, numbers) { fz, bz, n -> fz || bz ? fz+bz : n } | |
.subscribe { println it } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From http://wiki.c2.com/?FizzBuzzTest