SICP 第一章小结

--包括一些摘录和感言,和零碎的代码

1、要素

 

写道
Every powerful language has three mechanisms for accomplishing this:

* primitive expressions , which represent the simplest entities the language is concerned with,
* 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.

 重点在于combination和abstraction, 我觉得FP将function也作为元素,使得它可以进一步的组合,这样在抽象和结合的能力上更进了一步。

 

2、First-class elements

写道
In general, programming languages impose restrictions on the ways in which computational elements can be manipulated. Elements with the fewest restrictions are said to have first-class status. Some of the ``rights and privileges'' of first-class elements are

* They may be named by variables.
* They may be passed as arguments to procedures.
* They may be returned as the results of procedures.
* They may be included in data structures.

 FP语言中函数是作为First-class elements,相比于常用的c,c++,pascal,java...命令式语言中函数只是一种数据的结合和抽象的方式,函数在里面不能作为参数和结果,当然也不能包含在数据结构中,只是将数据结构和之上的运算用类封装在了一起。

FP的优势当然就是更强大的抽象能力,这还需要多多体会。

 

3、Substitution Model for Procedure Application
一种分析的方式

 

4、Higher-Order Procedure

除了前面提到的能力,多了一个匿名函数的概念,我主要是认为它使得函数变得更灵活,如同基本数据一样。

 

5、Recursion VS Iteration

需要体会二者的联系与转换,后者在命令式语言中一般可以用for表示。迭代不会改善时间复杂度,节约空间,相比速度会有一些提高。

 

6、算法

A. Exponentiation

O(n)

  a1. Recurse version

  a2. Iterate version

O(logn)

  b1. Recurse version

  b2. Iterate version

 

B. GCD

C. Testing for Primality
a.试除法

b.Miller-Rabin Test

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值