转:implementing cons/car/cdr without explicit storage
2024-09-24 10:53:24
I know this is old wine but it’s just too cool! It elegantly demonstrates closure and higher-order functions in a dozen lines, yet retains the robustness. The “intuitive” idea of storage is totally absent, replaced by the “environment” reserved by the interpreter. The first time I saw this is in the SICP videos.
(define (cons a d)
(lambda (op) (op a d))) (define (car p)
(p (lambda (a d) a))) (define (cdr p)
(p (lambda (a d) d)))
> (car2 (cons2 1 2))
1
> (cdr2 (cons2 1 2))
2
>转自:http://pro.harrypan.net/wp/?p=835
最新文章
- 数据库管理工具GUI - PremiumSoft Navicat Premium Enterprise 11.2.15 x86/x64 KEY
- jQuery ui autocomplete 与easyUI冲突解决办法(重命名ui的autocomplete 和menu部分)
- asp.net mvc ajax 异步刷新例子
- PopupWindow事件分发冲突解决
- noi 9267 核电站
- pentaho kettle svn
- Zend Studio下调试PHP的一点注意事项
- memcached 简介
- POJ 1930
- 使用AFNetworking时, 控制器点击返回销毁了, 但还是会执行请求成功或失败的block, 导致野指针异常
- Linux定时任务crontab命令使用详解
- [编译] 3、在Linux下搭建51单片机的开发烧写环境(makefile版)
- C++常用代码优化策略
- 导出使用NPOI
- (二)windows上使用docker
- 微信小程序开发1_资料收集
- 阿里云短信发送服务SDK-Python3
- 如何用Latex合并多个pdf文件?
- dropload.js下拉加载更多
- 遍历properties文件