scala25-CurringCurring(柯里化)
2015-12-20 12:32
246 查看
<span style="font-size:14px;"> def main(args: Array[String]) { def multiple(x: Int, y: Int) = x * y def multipleOne(x: Int) = (y: Int) => x * y //multipleOne类似于第一个函数会做的事情 val multipleTwo = multipleOne(1) //在第一个函数上应用1,换句话说,调用第一个函数并传入1,产生第二个函数 multipleTwo(2) //在第二个函数上应用2,产生结果 // println(multipleOne(6)(7)) //上述三行代码就是curing的过程,等价于下面2行代码 def curring(x: Int)(y: Int) = x * y println(curring(1)(2)) val a = Array("Hello", "Spark") val b = Array("hello", "spark") println(a.corresponds(b)(_.equalsIgnoreCase(_))) /* * curring:实际链接两个传统函数,第一个函数调用带单个名为x的参数,并返回第二个函数的函数值,第二个函数带Int参数y */ }</span>
相关文章推荐
- jquery mobile 移动web(4)
- 关于slmgr命令
- 黑马程序员--C语言自学笔记---08数组
- .msi安装包安装方法(安装错误2503和2502)
- 30天30个Golang程序学习(一):格式化输出
- 第一篇: 了解 Objective-C语言的起源
- 初学unslider
- SizeClass介绍
- BIOS相关
- C和C#的区别
- Linux 文件共享之SMB服务
- 2015.12.20周末
- ruby中的reject和reject!
- 关于del命令
- 思考2015.12.20
- 《JS修炼之道》—— 读后总结
- 虚拟与现实的距离——VR 产业链史上最全梳理收藏版本
- win8快捷键
- Linux 下mysql数据库导入导出
- Leetcode: Sliding Window Maximum