码迷,mamicode.com
首页 > 其他好文 > 详细

Compose

时间:2016-04-17 22:07:05      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:

object Compose {

  def compose[A, B, C](f: B => C, g: A => B): A => C = {
    (a: A) => f(g(a))
  }

  def main(args: Array[String]): Unit = {
    def int2String(a: Int): String = a.toString
    def stringLength(b: String): Int = b.length
    def composed = compose(stringLength, int2String)
    println(composed(1234))
  }
}

 

4

 

Compose

标签:

原文地址:http://www.cnblogs.com/JonkeyGuan/p/5402390.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!