Last active
December 31, 2015 08:38
-
-
Save daneko/7961311 to your computer and use it in GitHub Desktop.
たろー先生助けて!
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
fun hoge(i : Int) = if(i % 3 == 0 ) null else i | |
val sum = (1 .. 10).map(::hoge).filterNotNull().reduce{ a, b -> a + b} | |
println(sum) | |
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
def hoge(i :Int ) = if( i % 3 == 0) None else Some(i) | |
val sum = (1 to 10).map(hoge).flatten.reduce(_ + _) |
ngsw-taro
commented
Dec 15, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment