{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

scheme_part1

# scheme_part1 - CSC 324 Principles of Programming Languages...

This preview shows pages 1–8. Sign up to view the full content.

CSC 324: Principles of Programming Languages Functional Programming c circlecopyrt Suzanne Stevenson 2001,2002 with revisions by Cathy Jansen 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Part III: Functional Programming Pure Functional Languages Fundamental concept: application of (mathematical) functions to values 1. Referential transparency: The value of a function application is independent of the context in which it occurs value of f(a,b,c) depends only on the values of f , a , b and c It does not depend on the global state of computation all vars in function must be parameters 2
Pure Functional Languages 2. The concept of assignment is not part of functional programming no explicit assignment statements variables bound to values only through the association of actual parameters to formal parameters in function calls function calls have no side effects thus no need to consider global state 3. Control flow is governed by function calls and conditional expressions no iteration recursion is widely used 3

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Pure Functional Languages 4. All storage management is implicit needs garbage collection 5. Functions are First Class Values Can be returned as the value of an expression Can be passed as an argument Can be put in a data structure as a value Unnamed functions exist as values 4
A program includes: 1. A set of function definitions 2. An expression to be evaluated E.g. in Scheme: 1 ]=> (define (abs-val x) (if (>= x 0) x (- x))) ;Value: abs-val 1 ]=> (abs-val (- 3 5)) ;Value: 2 5

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
LISP Functional language developed by John McCarthy in the mid 50’s Semantics based on Lambda Calculus All functions operate on lists or atomic symbols: (called “S-expressions”) Only five basic functions: list functions cons, car, cdr, equal, atom and one conditional construct: cond Useful for list-processing applications Programs and data have the same syntactic form: S-expressions Used in Artificial Intelligence 6
COMMON LISP Implementations of LISP did not

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}