Reading Notes of SICP_02 Episode on Church Numerals

Here comes the exercise 2.6 from SICP,about Church Numerals--really make numbers into functions amazingly and beautifully !

In case representing pairs as procedures wasn't mind-boggling enough, consider that, in a language that can manipulate procedures, we can get by without numbers (at least insofar as non-negative integers are concerned) by implementing 0 and the operation of adding 1 as

(define zero (lambda (f) (lambda (x) x))) 
(define (add-1 n) 
  (lambda (f) (lambda (x) (f ((n f) x)))))

This representation is known as Church numerals, after its inventor, Alonzo Church, the logician who invented the <math>\lambda</math> calculus.

Define one and two directly (not in terms of zero and add-1). (Hint: Use substitution to evaluate (add-1 zero)). Give a direct definition of the addition procedure + (not in terms of repeated application of add-1).

First time I work on this problem,I was really confused,even if I got couple answers of this problem,so I took a note to analyse :


church数:

(数字是函数)

zero:
zero是一个函数 F1。
F1需要参数 f ~~so~~-->问题的关键在于参数 f~~
F1:
只包含了一个返回自己的函数

add-1:
是一个需要参数 n 的函数-->n也是一个函数
里面包含了一个函数  F1
F1需要参数 f-->是一个函数
包含一个函数F2
F2 需要参数 x
F2 调用函数 f--调用了上面的参数 x,n
f 的参数是 【(n f) x】-->这是一个以 x 为参数的复合函数

~~so~~ add-1 是需要函数 f 和函数 n 的函数
-->函数 f 是关键~~

key of all:把 f 当成黑箱处理以上问题~~


then,when looking at other guy's answers ,this thing become easier~~

They define the fuction f first~~

and the real thing about Church Numerals is how many times your number execute f~~


the following things about this theory is clearly discussed on other master's page ,like

http://jlongster.com/2011/12/16/sicp-26-church-notation.html

and an amazing guy named GenWang goes deep into this theory and discussed more about it

http://docs.huihoo.com/homepage/shredderyin/wiki/ChurchNumber.html


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值