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,布布扣,bubuko.com

时间: 2024-08-06 20:08:25

The differentiation program with abstract data的相关文章

Classic Abstract Data Types--C

本文内容来自<pointers on C> 栈的接口 /* Interface for a stack module */ #define STACK_TYPE int void push(STACK_TYPE value); void pop(void); STACK_TYPE top(void); int is_empty(void); int is_full(void); 2.使用动态数组实现栈 /* a stack implemented with a dynamically allo

ADT (Abstract Data Type)

抽象数据类型 ADT (Abstract Data Type) 是一个实现包括储存数据元素的存储结构以及实现基本操作的算法.在这个数据抽象思想中,数据类型的定义和它的实现是分开的,这在软件设计中是一个重要的概念.这使得只研究和使用它的结构而不用考虑它的实现细节成为可能. ADT包括数据数据元素,数据关系以及相关的操作. 即ADT { 数据对象:(数据元素集合) 数据关系:(数据关系二元组结合) 基本操作:(操作函数的罗列) }

ADT(Abstract Data Type)抽象数据类型

ADT(Abstract Data Type)抽象数据类型 为了便于理解,以复数为例: (1)定义: ADT Complex{ 数据对象:D={e1,e2|e1,e2为实数} 数据关系:S={<e1,e2>|e1是实部,e2是虚部} 基本操作: Creat(&C , x, y) GetReal(C) GetImage(C) Add(c1,c2) Sub(C1,C2) } ADT Complex; (2)表示: typedef struct{ float Realpart; float

ADT(abstract data types)抽象数据类型

1.What is it? An abstract data type is a set of objects together with a set of operations. 抽象数据类型是带有一组操作的一组对象的集合. ADTS=objects+operations 2.How to define? ADT Name Describe of data; Operations; End ADT Operations description: Name(parameter list) Inp

Flash program memory and data EEPROM

1.简介 STM8S内部的FLASH程序存储器和数据EEPROM是由一组通用寄存器来控制的:所以我们可以通过这些通用寄存器来编程或擦除存储器的内容.设置写保护.或者配置特定的低功耗模式.我们也可以自己对器件的 option byte 进行编程.在这里我们只简单的讲解如何对STM8S内部的数据存储区域(data memory)进行写操作.读操作.擦除操作. 2.存储架构图 STM8S内部存储包括:FLASH程序存储器(FLASH program memory)和数据EEPROM(DATA EEPR

Abstract Data Types in C

Interface declares operations, not data structure Implementation is hidden from client (encapsulation) Use features of programming language to ensure encapsulation Common practice Allocation and deallocation of data structure handled by module Names

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 declared type(每个变量都必须声明类型). There are eight primitive types in Java(Java有8种原始类型). Four of them are integer types; two are floatingpoint number types;

Data type-数据类型

操作方式.含义.存储方式. In computer science and computer programming, a data type or simply type is a classification of data which tells the compiler or interpreter how the programmer intends to use the data. Most programming languages support various types of

Method and apparatus for encoding data to be self-describing by storing tag records describing said data terminated by a self-referential record

A computer-implemented method and apparatus in a computer system of processing data generated by a first application program in a second application program during runtime. During runtime, the first application program generates a record including a