4 ms·
Oh! I see. It's much more concise and clean now. But still I prefer the clojure version using pattern matching over the scala one: http://blog.klipse.tech/cloj
by viebel 10y ago
Oh! I see. It's much more concise and clean now.
But still I prefer the clojure version using pattern matching over the scala one: http://blog.klipse.tech/clojure/2016/10/25/core-match.html#fizzbuzz http://blog.klipse.tech/clojure/2016/10/25/core-match.html#f...
- AdieuToLogic 10y agoGotcha. Then here's a translation into Scala from the link you provided which I believe maintains the spirit of the clojure version: object Fizzbuzz { def apply (amount : Int) : TraversableOnce[String] = 1.to (amount).map { n => (n % 3, n % 5) match { case (0, 0) => "FizzBuzz"; case (0, _) => "Fizz"; case (_, 0) => "Buzz"; case _ => n.toString } } } Fizzbuzz (100).foreach (println); EDIT: When I said "Gotcha", I meant that as in "understood" and not in an adversarial manner. Quite the opposite, actually, as this is a respectful thread which I believe both parties have enjoyed.