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 ...
随机推荐
- 修改vs17中的cordova模板
因为visual studio 2017创建的默认cordova-ios的版本自动编译带有swift语言的插件会出现异常,cordova-ios升级到4.3.1,并且配置build.json能解决问题 ...
- 服务器Java环境配置
/* 当要在服务器里搭建Java web项目时, 要先配置好Java需要的环境 */ //jdk [root@localhost ~]# cd /usr/local/src [root@localho ...
- django时差8个小时问题
问题现象: 在用django做好的网站,上传图片后显示的发布时间比当前时间差了8小时 查找问题: 查看服务器系统时间,经查与当前时间一致,无问题 查看数据库中的时间也一样 最终原因: 在setting ...
- LeetCode862. Shortest Subarray with Sum at Least K
Return the length of the shortest, non-empty, contiguous subarray of A with sum at least K. If there ...
- Hilite代码高亮工具
在用<有道云笔记>等软件时候,软件自身不提供代码高亮功能,对于需要记录code的学习笔记,视觉效果丢失. 有很多在线工具能用来代码高亮,比如oschina就有代码高亮页面用于着色. 但是我 ...
- 05 java 基础:运算符、程序结构
赋值运算符 : = 三元运算符 : ? 算术运算符 : +.- .*./.% 自增自减运算符: ++.-- 关系运算符:>.<.==.>=.<=.!= 逻辑运算符 :& ...
- SaltStack的配置管理--jinja (七)
SaltStack的配置管理--jinja 需求场景:使用jinja模板,让各节点的httpd都监听在本机的ip [root@7mini-node1 apache]# vim files/httpd. ...
- Java 8 对 List<List<String>> 排序
Java 8 对 List<List> 排序 import java.util.ArrayList; import java.util.List; import java.util.str ...
- Spring中@Transactional事务回滚
转载: Spring中@Transactional事务回滚 一.使用场景举例 在了解@Transactional怎么用之前我们必须要先知道@Transactional有什么用.下面举个栗子:比如一个部 ...
- 429.N叉树的层次遍历
给定一个 N 叉树,返回其节点值的层序遍历. (即从左到右,逐层遍历). 例如,给定一个 3叉树 : 返回其层序遍历: [ [1], [3,2,4], [5,6] ] 说明: 树的深度不会超过 100 ...