DOC PREVIEW
Columbia COMS W4115 - Haskell Computer Algebra System

This preview shows page 1-2-3-4-24-25-26-50-51-52-53 out of 53 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 53 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Haskell Computer Algebra System (HCAS) Final ReportRob Tougher ([email protected])December 15, 20071Contents1 Introduction 32 Language Tutorial 32.1 Command Line Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.2 Hello World! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 Language Manual 63.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63.2 Top-Level Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63.3 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73.3.1 Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73.3.2 Expression Atoms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83.3.3 Boolean Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103.3.4 Math Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.3.5 List Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.3.6 Miscellaneous Expressions . . . . . . . . . . . . . . . . . . . . . . . . 123.4 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123.4.1 Function Precedence . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.4.2 Applicative-Order Argument Evaluation . . . . . . . . . . . . . . . . 143.5 Syntax Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 Project Plan 1525 Architectural Design 166 Test Plan 176.1 Example Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176.1.1 Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176.1.2 Calculus Derivatives . . . . . . . . . . . . . . . . . . . . . . . . . . . 196.1.3 Simplification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196.2 Unit Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 Lessons Learned 218 Appendix - Code Listing 218.1 AST.hs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218.2 Parser.hs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268.3 Interpreter.hs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328.4 MainInterpreter.hs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388.5 AllTests.hs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3931 IntroductionFor the class project I implemented a simple computer algebra system, HCAS. HCAS isa purely functional programming language that provides a set of basic operations for con-structing and manipulating algebraic expressions. Simply put, you can think of HCAS as asubset of Haskell, plus support for computer algebra.HCAS has three main features:• Purely Functional Language. HCAS is a purely functional subset of Haskell. Thereare functions, recursion, lists, strings, pattern matches for function arguments, etc.No variables, sequencing of operations, or other items from imperative programminglanguages.• Construction of Mathematical Expressions. HCAS allows you to construct math-ematical expressions using an intuitive syntax. You are able to define mathematicalexpressions inline. That is, if you write the expression x + y − z, this is automaticallyconstructed as a math expression.• Navigation of Mathematical Expressions. HCAS uses the concept of patternmatching in function arguments to allow you to navigate mathematical expressions.Consider the following simple function:printType ( l e f t ∗ r i g h t ) =” M u l t i p l i c a t i o n ”printType ( l e f t+r i g h t ) =” Addition ”This function has two definitions, one for addition and one for multiplication. Theversion that gets executed at runtime is chosen based on the expression argument thatyou pass in. So if you call the function as “printType(x*y+z)”, the version for additionwill be called, because addition binds the loosest. In the body of the function “left”refers to “x*y”, and “right” refers to “z”.2 Language Tutorial2.1 Command Line UsageOne command line utility is shipped with this project: hcasi, the HCAS interpreter. Thisutility uses standard input for the HCAS input and standard output for the program output:4$ ./hcasi < myscript.hcas > out.txt2.2 Hello World!Every good language tutorial contains a few “Hello …


View Full Document

Columbia COMS W4115 - Haskell Computer Algebra System

Documents in this Course
YOLT

YOLT

13 pages

Lattakia

Lattakia

15 pages

EasyQL

EasyQL

14 pages

Photogram

Photogram

163 pages

Espresso

Espresso

27 pages

NumLang

NumLang

6 pages

EMPATH

EMPATH

14 pages

La Mesa

La Mesa

9 pages

JTemplate

JTemplate

238 pages

MATVEC

MATVEC

4 pages

TONEDEF

TONEDEF

14 pages

SASSi

SASSi

16 pages

JTemplate

JTemplate

39 pages

BATS

BATS

10 pages

Synapse

Synapse

11 pages

c.def

c.def

116 pages

TweaXML

TweaXML

108 pages

Load more
Download Haskell Computer Algebra System
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Haskell Computer Algebra System and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Haskell Computer Algebra System 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?