SICP 习题2.38 fold-left fold-right
来源:互联网 发布:成都cnc编程招聘 编辑:程序博客网 时间:2024/06/07 19:20
要使fold-left和fold-right达到同样的结果,要求op对操作顺序无关,譬如+
(define (accumulate op initial sequence) (if (null? sequence) initial (op (car sequence) (accumulate op initial (cdr sequence)))))(define fold-right accumulate)(define (fold-left op initial sequence) (define (iter result rest) (if (null? rest) result (iter (op result (car rest)) (cdr rest)))) (iter initial sequence))(newline)(display (fold-right / 1 (list 1 2 3)))(newline)(display (fold-left / 1 (list 1 2 3)))(newline)(display (fold-right list '() (list 1 2 3)))(newline)(display (fold-left list '() (list 1 2 3)))(newline)(display (fold-right + 0 (list 1 2 3)))(newline)(display (fold-left + 0 (list 1 2 3)))
0 0
- SICP 习题2.38 fold-left fold-right
- the Differences of Fold-left and Fold-right
- Fold
- fold
- vim fold
- Fold expressions
- 关于fold
- Rust :fold
- 10-fold cross-validation
- VIM fold 折叠
- linux命令--fold
- vim fold code
- POJ2139 Fold-warshall算法
- Sicily 1207. No Fold
- k fold cross validation
- Stratified k-fold
- K-fold 交叉验证
- K-Fold Cross Validation
- leetcode 36. Valid Sudoku
- php 进行子网换算(二进制,解决32位/64位系统超出最大int)
- java同时配置多个数据库连接池
- [疯狂Java]面向对象:自发性多态问题
- Eclipse快捷方式
- SICP 习题2.38 fold-left fold-right
- Python点滴(七)—pandas 记录
- git报错集合
- Android中的集中常用布局方式和按钮事件的处理方式
- 如何查找死锁问题
- c++中的强制转换static_cast、dynamic_cast、reinterpret_cast的不同用法儿
- 上传jar包到nexus私服
- js拼接字符中包含的js方法无法解析
- Spring连接两个以上的数据库