The differentiation program with abstract data
#!r6rs
( import ( rnrs base ( 6 ) )
( rnrs io simple ( 6 ) ) )
( define ( deriv exp var )
( define ( variable? x )
( symbol? x ) )
( define ( =number? exp num )
( and ( number? exp )
( = exp num ) ) )
( define ( same-variable? x1 x2 )
( and ( variable? x1 )
( variable? x2 )
( eq? x1 x2 ) ) )
( define ( make-sum a1 a2 )
( cond ( ( =number? a1 0 )
a2 )
( ( =number? a2 0 )
a1 )
( ( and ( number? a1 )
( number? a2 ) )
( + a1 a2 ) )
( else
( list '+ a1 a2 ) ) ) )
( define ( make-product m1 m2 )
( cond ( ( or ( =number? m1 0 )
( =number? m2 0 ) )
0 )
( ( =number? m1 1 )
m2 )
( ( =number? m2 1 )
m1 )
( ( and ( number? m1 )
( number? m2 ) )
( * m1 m2 ) )
( else
( list '* m1 m2 ) ) ) )
( define ( sum? x )
( and ( pair? x )
( eq? ( car x ) '+ ) ) )
( define ( addend s )
( cadr s ) )
( define ( augend s )
( caddr s ) )
( define ( product? x )
( and ( pair? x )
( eq? ( car x ) '* ) ) )
( define ( multiplier p )
( cadr p ) )
( define ( multiplicand p )
( caddr p ) )
( cond ( ( number? exp ) 0 )
( ( variable? exp )
( if ( same-variable? exp var ) 1
0 ) )
( ( sum? exp )
( make-sum ( deriv ( addend exp ) var )
( deriv ( augend exp ) var ) ) )
( ( product? exp )
( make-sum ( make-product ( multiplier exp )
( deriv ( multiplicand exp ) var ) )
( make-product ( deriv ( multiplier exp ) var )
( multiplicand exp ) ) ) )
( else
( error "unknown expression type: DERIV" exp ) ) ) )
The differentiation program with abstract data的更多相关文章
- ADT(abstract data types)抽象数据类型
1.What is it? An abstract data type is a set of objects together with a set of operations. 抽象数据类型是带有 ...
- 20182320《Program Design and Data Structures》Learning Summary Week9
20182320<Program Design and Data Structures>Learning Summary Week9 1.Summary of Textbook's Con ...
- Rocket - debug - TLDebugModuleInner - Abstract Data
https://mp.weixin.qq.com/s/DOLkEi-_qQt6lWOhJ2hxVQ 简单介绍TLDebugModuleInner中抽象数据寄存器的实现. 1. abstractData ...
- STM8S——Flash program memory and data EEPROM
1.简介 STM8S内部的FLASH程序存储器和数据EEPROM是由一组通用寄存器来控制的:所以我们可以通过这些通用寄存器来编程或擦除存储器的内容.设置写保护.或者配置特定的低功耗模式.我们也可以自己 ...
- Abstract Data Types in C
Interface declares operations, not data structure Implementation is hidden from client (encapsulatio ...
- Abstract Data Type
- 20162314 《Program Design & Data Structures》Learning Summary Of The Fifth Week
20162314 2017-2018-1 <Program Design & Data Structures>Learning Summary Of The Fifth Week ...
- detect data races The cost of race detection varies by program, but for a typical program, memory usage may increase by 5-10x and execution time by 2-20x.
小结: 1. conflicting access 2.性能危害 优化 The cost of race detection varies by program, but for a typical ...
- Core Java Volume I — 3.3. Data Types
3.3. Data TypesJava is a strongly typed language(强类型语音). This means that every variable must have a ...
随机推荐
- 9.Python3标准库--数据压缩与归档
''' 尽管现代计算机系统的存储能力日益增长,但生成数据的增长是永无休止的. 无损(lossless)压缩算法以压缩或解压缩数据花费的时间来换取存储数据所需要的空间,以弥补存储能力的不足. Pytho ...
- javascript初步了解
0.1 <script> 和 </script> 会告诉 JavaScript 在何处开始和结束. <script> 和 </script> 之间的 ...
- Linux下如何创建新用户
Linux下如何创建新用户 Linux系统中,只有root用户有创建其他用户的权限.创建过程如下: useradd -d /home/newuser newuser(设定了该用户的主目录和用户名) ...
- 看懂 MySQL 慢查询日志
MySQL中的日志包括: 错误日志.二进制日志.通用查询日志.慢查询日志等等. 这里主要介绍下比较常用的两个功能:通用查询日志和慢查询日志. 1)通用查询日志:记录建立的客户端连接和执行的语句. 2) ...
- HDU 17111 Number Sequence(KMP裸题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1711 题目大意:给你两个数字数组a和b,若b是a的子序列则输出b在a中第一次出现的位置,否则输出-1. ...
- Linux 用户篇——用户管理的配置文件
一.用户管理之配置文件的重要性 在Linux系统中,用户账户的相关信息是存放在相关配置文件中.而Linux安全系统的核心是用户账号,用户对系统中各种对象的访问权限取决于他们登录系统时用的账户,并且Li ...
- JS 数据类型转换以其他
JavaScript 是一种弱类型的语言,也就是没有类型限制,变量可以随时被赋予任意值. 同时,在程序运行过程中,类型会被自动确认的.因此,这就是涉及到数据的类型转换.在 JS 的世界中,数据类型转换 ...
- spring_150906_sqlmapclientdaosupport_getSqlMapClientTemplate
添加到ibatis相关jar包! 实体类: package com.spring.model; public class DogPet { private int id; private String ...
- 解析Excel
package com.jpcar.utils; import java.io.File; import java.io.FileInputStream; import java.io.IOExcep ...
- cf 633B A trivial problem
Mr. Santa asks all the great programmers of the world to solve a trivial problem. He gives them an i ...