September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -1,7 +1,7 @@
|
|||
fun fizzBuzz() {
|
||||
fun fizzbuzz(x: Int) = if(x % 15 == 0) "FizzBuzz" else x
|
||||
fun fizz(x: Any) = if(x is Int && x % 3 == 0) "Buzz" else x
|
||||
fun buzz(x: Any) = if(x is Int && x.toInt() % 5 == 0) "Fizz" else x
|
||||
fun fizzBuzz1() {
|
||||
fun fizzBuzz(x: Int) = if (x % 15 == 0) "FizzBuzz" else x.toString()
|
||||
fun fizz(x: Any) = if (x is Int && x % 3 == 0) "Buzz" else x
|
||||
fun buzz(x: Any) = if (x is Int && x.toInt() % 5 == 0) "Fizz" else x
|
||||
|
||||
(1..100).map { fizzbuzz(it) }.map { fizz(it) }.map { buzz(it) }.forEach { println(it) }
|
||||
(1..100).map { fizzBuzz(it) }.map { fizz(it) }.map { buzz(it) }.forEach { println(it) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
fun fizzBuzz() {
|
||||
fun fizzBuzz2() {
|
||||
fun fizz(x: Pair<Int, StringBuilder>) = if(x.first % 3 == 0) x.apply { second.append("Fizz") } else x
|
||||
fun buzz(x: Pair<Int, StringBuilder>) = if(x.first % 5 == 0) x.apply { second.append("Buzz") } else x
|
||||
fun none(x: Pair<Int, StringBuilder>) = if(x.second.isBlank()) x.second.apply { append(x.first) } else x.second
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue