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

1 Building Abstractions with Functions

时间:2015-07-18 10:53:09      阅读:109      评论:0      收藏:0      [点我收藏+]

标签:

Every powerful language has three such mechanisms:

  • primitive expressions and statements, which represent the simplest building blocks that the language provides,
  • means of combination, by which compound elements are built from simpler ones, and
  • means of abstraction, by which compound elements can be named and manipulated as units.

 

A critical aspect of a programming language is the means it provides for using names to refer to computational objects. If a value has been given a name, we say that the name binds to the value.

 

nested expression (嵌套表达式)
Pure function and Non-Pure functions

 

function abstraction (将计算过程抽象成函数)

To master the use of a functional abstraction, it is often useful to consider its three core attributes. The domain of a function is the set of arguments it can take. Therange of a function is the set of values it can return. The intent of a function is the relationship it computes between inputs and output (as well as any side effects it might generate)

 

Decomposing a complex task into concise functions
some ideas of good function:

  • Each function should have exactly one job
  • Don‘t repeat yourself
  • Functions should be defined generally

 

Higher-order Functions

  • Functions as Arguments
  • Functions as General Methods
  • Functions as Returned Values

 

闭包(closure)

科里化(currying)

 

 

2015-07-18

1 Building Abstractions with Functions

标签:

原文地址:http://www.cnblogs.com/whuyt/p/4656296.html

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