1.3 较大两个数之和

 (define (MaxSum x y z)
(+ (cond ((or (> x y) (> x z)) x)
(else ))
(cond ((or (> y x) (> y z)) y)
(else ))
(cond ((or (> z x) (> z y)) z)
(else ))))
(MaxSum )

较大两个数之和

牛顿迭代

 (define (Abs x)
(cond ((> x ) x)
((= x ) )
((< x ) (- x))))
(define (Square x) (* x x))
(define (Average x y)
(/ (+ x y) ))
(define (Improve guess x)
(Average guess (/ x guess)))
(define (GoodEnough? guess x)
(< (Abs (- (Square guess) x)) 0.001))
(define (SqrtIter guess x)
(if (GoodEnough? guess x)
guess
(SqrtIter (Improve guess x)
x)))
(SqrtIter )

牛顿迭代

一个表的最后一个表

 (define (last-pair lst)
(if (<= (length lst) )
lst
(last-pair (cdr lst))))

最后一个表

集合操作

 (define (element-of-set? x set)
(cond ((null? set) false)
((equal? x (car set)) true)
(else (element-of-set? x (cdr set))))) (define (adjoin-set x set)
(if (element-of-set? x set)
set
(cons x set))) (define (intersection-set set1 set2)
(cond ((or (null? set1) (null? set2)) '())
((element-of-set? (car set1) set2)
(cons (car set1)
(intersection-set (cdr set1) set2)))
(else (intersection-set (cdr set1) set2)))) (define (union-set set1 set2)
(cond ((null? set1) set2)
((null? set2) set1)
((element-of-set? (car set1) set2)
(union-set (cdr set1) set2))
(else (cons (car set1) (union-set (cdr set1) set2))))) (define set1 (list ))
(define set2 (list ))
(element-of-set? set1)
(element-of-set? set1)
(intersection-set set1 set2)
(union-set set1 set2)

集合

SICP的一些练习题的更多相关文章

  1. sicp第1章

    牛顿迭代法求平方: (define (sqrt-iter guess x) (if (good-enough? guess x) guess (sqrt-iter (improve guess x) ...

  2. Lisp和SICP

         大概不少programmer都看过<黑客与画家>,作者用了整整一章的篇幅讨论Lisp的强大.我自然就会手痒痒.      几个月前,几天内攻城略地搞定了Python,用的方法便是 ...

  3. Linux基础练习题(二)

    Linux基础练习题(二) 1.复制/etc/skel目录为/home/tuer1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限. [root@www ~]# cp -r ...

  4. shell 脚本之 shell 练习题汇总

    整理了一些 shell 相关的练习题,记录到这里. 1. 请按照这样的日期格式 xxxx-xx-xx 每日生成一个文件,例如:今天生成的文件为 2013-09-23.log, 并且把磁盘的使用情况写到 ...

  5. MySQL练习题

    MySQL练习题 一.表关系 请创建如下表,并创建相关约束 二.操作表 1.自行创建测试数据 2.查询“生物”课程比“物理”课程成绩高的所有学生的学号: 3.查询平均成绩大于60分的同学的学号和平均成 ...

  6. MySQL练习题参考答案

    MySQL练习题参考答案 2.查询“生物”课程比“物理”课程成绩高的所有学生的学号: 思路: 获取所有有生物课程的人(学号,成绩) - 临时表 获取所有有物理课程的人(学号,成绩) - 临时表 根据[ ...

  7. mysql练习题-查询同时参加计算机和英语考试的学生的信息-遁地龙卷风

    (-1)写在前面 文章参考http://blog.sina.com.cn/willcaty. 针对其中的一道练习题想出两种其他的答案,希望网友给出更多回答. (0) 基础数据 student表 +-- ...

  8. 【UOJ#228】基础数据结构练习题 线段树

    #228. 基础数据结构练习题 题目链接:http://uoj.ac/problem/228 Solution 这题由于有区间+操作,所以和花神还是不一样的. 花神那道题,我们可以考虑每个数最多开根几 ...

  9. 【Java EE 学习 28 下】【Oracle面试题2道】【Oracle练习题3道】

    一.已知程序和数据 create table test1 (id int primary key, name ), money int); ,); ,); ,); ,); 要求根据下图写出相应的sql ...

随机推荐

  1. js特效第九天

    offset家族(获取元素尺寸) offsetWidth得到对象的宽度,自己的,与他人无关 offsetWidth = width+border+padding,不包含margin offsetHei ...

  2. bzoj 3124 [Sdoi2013]直径(dfs)

    Description 小Q最近学习了一些图论知识.根据课本,有如下定义.树:无回路且连通的无向图,每条边都有正整数的权值来表示其长度.如果一棵树有N个节点,可以证明其有且仅有N-1 条边. 路径:一 ...

  3. 谷歌官方刷新组件SwipeRefreshLayout

    今天开始使用谷歌的SwipeRefreshLayout,会记下一些坑 1.手动调用setRefreshing(true)不会出现刷新动画 原因是:SwipeRefreshLayout indicato ...

  4. Android实例-调用GOOGLE的TTS实现文字转语音(XE7+小米2)(无图)

    注意:在手机上必须选安装文字转语音引擎“google Text To Speech”地址:http://www.shouji56.com/soft/GoogleWenZiZhuanYuYinYinQi ...

  5. 高性能mysql主主架构

    A.环境描述 服务器A(主) 192.168.0.105 服务器B(主) 192.168.0.108 Mysql版本: 5.6.21 System OS:CentOS release 6.5 主从需同 ...

  6. ASP.NET中配置应用程序

    1.   配置文件简介 1.1 分类 1.2关系 Machine.Config和Web.Config都是设置应用程序的配置信息,它们按照类似于继承的关系对应用程序起作用. Machine.Config ...

  7. NOTES : A Model of Gas Exchange for Hyperpolarized Xe(129) Magnetic Resonance of the Lung

    NOTES :  A Model of Gas Exchange for Hyperpolarized Xe(129) Magnetic Resonance of the Lung  背景知识: Ga ...

  8. Cocos2dx 小技巧(十一) 小人虽短,但能够旋转

    转眼五一就到了,放假三天应该做些什么呢?窝在家里钻研技术?写博客?no no no no,这样的"伤害"自己的方式实在让我无法忍受.本来和大学那伙人越好了一起去哪里玩玩,喝酒聊天啥 ...

  9. 如何用JAVA生成注册序列号

    原文:http://blog.csdn.net/eagleking012/article/details/7099900 平常我们都接触过软件注册,输入序列号.激活码.注册码.授权码:对于这些字符码到 ...

  10. Oracle VM Virtual Box 4.3 小巧精悍的虚拟机软件

    https://www.virtualbox.org/wiki/Downloads Download VirtualBox Here, you will find links to VirtualBo ...