Created
October 26, 2018 18:12
-
-
Save 8q/6bf771404824eb194671e6ed57c4e22e to your computer and use it in GitHub Desktop.
scalaでmapを畳み込みを使って作ってみる
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
object Main { | |
def main(args: Array[String]): Unit = { | |
def map[T, U](ls: List[T])(f: T => U): List[U] = ls.foldRight(Nil: List[U])((x, y) => f(x) :: y) | |
println(map(List(1, 2, 3))(x => x * 2)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment