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模块之pxssh
pxssh模块用于在python中ssh远程连接,执行命令,返回结果,但注意不支持Windows系统 #!/usr/bin/env python #-*- coding:utf-8 -*- from ...
- solr应用
Solr是apache的顶级开源项目,它是使用java开发 ,基于lucene的全文检索服务器.Solr比lucene提供了更多的查询语句,而且它可扩展.可配置,同时它对lucene的性能进行了优化. ...
- Metro应用Json数据处理
Windows Phone 8 或者 Windows 8 平台对JSON数据的处理方式基本是一致的,需要使用DataContractJsonSerializer类将对象的实例序列化为JSON字符串,并 ...
- java基础10 单例模式之饿汉式和懒汉式单例
前言: 软件行业中有23中设计模式 单例模式 模版模式 装饰者模式 观察者模式 工厂模式 ........... 单例模式 1. 单例模式包括 1.1 饿汉式单例 1.2 ...
- Photon3Unity3D.dll 解析三——OperationRequest、OperationResponse
OperationRequest 代表Operation操作的Request,包含Code和Parameters OperationCode Byte类型的值,代表操作,由LiteOpCode定义了 ...
- 木块问题(UVa101)
题目具体描述见:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_prob ...
- 分子量(UVa1586)
题目具体描述见:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=830&a ...
- 10.Spark Streaming源码分析:Receiver数据接收全过程详解
原创文章,转载请注明:转载自 听风居士博客(http://www.cnblogs.com/zhouyf/) 在上一篇中介绍了Receiver的整体架构和设计原理,本篇内容主要介绍Receiver在 ...
- 【JavaWeb开发】初步实现网站应用钉钉扫码登录
http://blog.csdn.net/baofeidyz/article/details/59059379 版权声明:转载请注明我的个人微信平台 暴沸 目录(?)[+] 写在前面:如果你还不知道钉 ...
- Python之路【第一篇】:介绍、基本语法、流程控制
一.python 简介 python 特点 Python是一种计算机程序设计语言.你可能已经听说过很多种流行的编程语言,比如非常难学的C语言,非常流行的Java语言,适合初学者的Basic语言,适合网 ...