# Mar20 - CSE262: Programming Languages Instructor: Dr. Liang...

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

CSE262: Programming Languages Instructor: Dr. Liang Cheng Department of Computer Science and Engineering Lehigh University March 20, 2007

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

View Full Document
Instructor: Dr. Liang Cheng CSE262: Programming Languages 03/20/07 Outline ± Recap ± Scheme language ± Functional programming language (Chapter 15) ± Summary and homework
Instructor: Dr. Liang Cheng CSE262: Programming Languages 03/20/07 Scheme - Primitive Functions ± Arithmetic: +, -, *, /, ABS, SQRT, REMAINDER, MIN, MAX ± ( + 5 2) yields 7 ± QUOTE (apostrophe prefix operator) ± '(a b) is equivalent to ( QUOTE (a b)) ± CAR, CDR, CONS, LIST ± Lambda expressions can be applied ± ((LAMBDA (L) (CAR (CAR L))) '((A B) C D)) yields A

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

View Full Document
Instructor: Dr. Liang Cheng CSE262: Programming Languages 03/20/07 Constructing Functions ± A function for constructing functions: DEFINE has two forms 1. To bind a symbol to an expression ± (DEFINE pi 3.141593) ± (DEFINE two_pi (* 2 pi)) 2. To bind names to lambda expressions ± (DEFINE (cube x) (* x x x)) ± Example use: (cube 4)
Instructor: Dr. Liang Cheng CSE262: Programming Languages 03/20/07 Constructing Functions ± More examples (DEFINE (square x) (* x x)) (DEFINE (hypotenuse side1 side2) (SQRT (+ (square side1) (square side2))) ) ± ex1.scm

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

View Full Document
Instructor: Dr. Liang Cheng CSE262: Programming Languages 03/20/07 Scheme Function Evaluation ± Evaluation process 1. Parameters are evaluated, in no particular order 2. The values of the parameters are substituted into the function body 3. The function body is evaluated 4. The value of the last expression in the body is the value of the function
Instructor: Dr. Liang Cheng CSE262: Programming Languages 03/20/07 Scheme - Predicate Functions

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.

## This note was uploaded on 08/06/2008 for the course CSE 262 taught by Professor Cheng during the Spring '07 term at Lehigh University .

### Page1 / 25

Mar20 - CSE262: Programming Languages Instructor: Dr. Liang...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online