Skip to content

Instantly share code, notes, and snippets.

@rodrigoSaladoAnaya
Last active May 19, 2018 18:26
Show Gist options
  • Save rodrigoSaladoAnaya/dbc7056a101a4252041775df129f9eda to your computer and use it in GitHub Desktop.
Save rodrigoSaladoAnaya/dbc7056a101a4252041775df129f9eda to your computer and use it in GitHub Desktop.
FizzBuzz with RxGroovy
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 }
@rodrigoSaladoAnaya
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment