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 ...
随机推荐
- Python如何实现文本转语音
准备 我测试使用的Python版本为2.7.10,如果你的版本是Python3.5的话,这里就不太适合了. 使用Speech API 原理 我们的想法是借助微软的语音接口,所以我们肯定是要进行调用 相 ...
- Suse Linux下NTP缓慢调整配置,转载至http://www.gpstime.com.cn/
(1)系统内若有使用crontab 进行与时间调整相关的例行性工作排程,应注释掉(命令人工crontab -e修改,删除定时同步任务ntpdate -s ntpserver). (2)修改ntp配置文 ...
- EasyUi–8.datebox赋值的问题
这个问题要从EasyUI的datebox组件说起,小菜用这个组件的时候,发现用$("#id").val()这种形式,居然拿不到文本框的值! 经过度娘的帮助,发现可以用$(" ...
- Ant, JUnit以及Sonar的安装+入门资料
Ant 感觉是个和Make/Grunt类似的东东,build一个项目用的.安装很容易,跟装JDK类似,就是解压->设环境变量->没了.注意装之前要先确认Java装好了(有点废话). 下载地 ...
- awk书上练习
文件car: plym fury chevy malibu ford mustang volvo s80 ford thundbd chevy malibu bmw 325i honda accord ...
- ubuntu 防火墙关闭的80端口,开启方法
#关闭防火墙 /etc/init.d/iptables stopservice iptables stop # 停止服务#查看防火墙信息/etc/init.d/iptables status #开放端 ...
- HTTP缓存了解(一)
引言 HTTP/1.1 200 OK X-Powered-By: Express Content-Type: text/html; charset=utf-8 Content-Length: 3 ET ...
- angular4 动态Form中获取表单字段并在页面中使用的方法
主要有两种方式 第一种 使用get属性 页面中使用如下: 第二种 使用普通方法事件 页面中使用如下 *转载请附出处
- 二. 创建Series和DataFrame对象
创建对象 创建Series对象 Series可以通过列表,标量值,字典,ndarray,其他函数来创建 a = pf.Series([1,2,3,4]) # 列表创建 b = pd.Series(25 ...
- 【并查集】【枚举倍数】UVALive - 7638 - Number of Connected Components
题意:n个点,每个点有一个点权.两个点之间有边相连的充要条件是它们的点权不互素,问你这张图的连通块数. 从小到大枚举每个素数,然后枚举每个素数的倍数,只要这个素数的某个倍数存在,就用并查集在这些倍数之 ...