层次性结构
来源:互联网 发布:淘宝灯具3c认证怎么弄 编辑:程序博客网 时间:2024/06/03 07:48
(define (append a b) (if (null? a) b (cons (car a) (append (cdr a) (cons (car a) b)))))(define nil (list))(define (count-leaves x) (cond ((null? x) 0) ((not (pair? x)) 1) (else (+ (count-leaves (car x)) (count-leaves (cdr x))))));;(define (reverse l) (define (reverse-iter tmp ans) (if (null? tmp) ans (reverse-iter (cdr tmp) (cons (car tmp) ans)))) (reverse-iter l nil));2.27(define (deep-reverse l) (define (deep-reverse-in tmp ans) (cond ((null? tmp) ans) ((pair? (car tmp)) (deep-reverse-in (cdr tmp) (cons (deep-reverse-in (car tmp) nil) ans))) (else (deep-reverse-in (cdr tmp) (cons (car tmp) ans))))) (deep-reverse-in l nil));2.28(define (fringe t) (define (fringe-in tmp ans) (cond ((null? tmp) ans) ((not (pair? tmp)) (cons tmp ans)) (else (fringe-in (car tmp) (fringe-in (cdr tmp) ans))))) (fringe-in t nil))(fringe (list (list 1 (list 5 6 7)) (list 3 4) 8));2.29(define (make-mobile left right) (cons left right))(define (make-branch length structure) (cons length structure))(define (left-branch x) (car x))(define (right-branch x) (cdr x))(define (branch-length x) (car x))(define (branch-structure x) (cdr x))(define (total-weight t) (if (not (pair? t)) t (+ (total-weight (branch-structure (left-branch t))) (total-weight (branch-structure (right-branch t))))))(define (mobile-balance t) (or (not (pair? t)) (and (mobile-balance (branch-structure (left-branch t))) (mobile-balance (branch-structure (right-branch t))) (= (* (total-weight (branch-structure (left-branch t))) (branch-length (left-branch t))) (* (total-weight (branch-structure (right-branch t))) (branch-length (right-branch t)))))))
0 0
- 层次性结构
- 层次结构
- 展开层次结构
- servlet层次结构
- 存储系统的层次结构
- BlackBerry UI层次结构
- JAVA层次结构开发
- javaee层次结构
- 存储器的层次结构
- unix的层次结构
- J2EE的层次结构
- Android 软件层次结构
- 存储器层次结构
- RTC 层次结构
- RTC m48t59 层次结构
- 存储器层次结构
- 驱动程序的层次结构
- 流层次结构
- CUDA学习笔记六
- Adnroid多媒体---音视频
- C++作业5
- Android-View的手势分发
- 用Java写脚本,常用的一些方法
- 层次性结构
- ASP.NET常见面试题及答案(130题)
- 5678
- Boostrap入门准备之border-box
- MYSQL操作中错误The user specified as a definer ('root'@'%') does not exist的解决
- extern "c"用法解析
- RRC Connection Reconfiguration
- 集成支付宝
- * 有一对兔子,从出生后第3个月起每个月都生一对兔子,这对小兔子长到第三个月后每个月又生一对 * 小兔子,如此循环下去。假如兔子都不死,问,两年内,每个月的兔子有多少对? * @author A