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

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

View Full Document Right Arrow Icon
CSE262: Programming Languages Instructor: Dr. Liang Cheng Department of Computer Science and Engineering Lehigh University March 20, 2007
Background image of page 1

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

View Full DocumentRight Arrow Icon
Instructor: Dr. Liang Cheng CSE262: Programming Languages 03/20/07 Outline ± Recap ± Scheme language ± Functional programming language (Chapter 15) ± Summary and homework
Background image of page 2
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
Background image of page 3

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

View Full DocumentRight Arrow Icon
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)
Background image of page 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
Background image of page 5

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

View Full DocumentRight Arrow Icon
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
Background image of page 6
Instructor: Dr. Liang Cheng CSE262: Programming Languages 03/20/07 Scheme - Predicate Functions
Background image of page 7

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

View Full DocumentRight Arrow Icon
Image of page 8
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 Right Arrow Icon
Ask a homework question - tutors are online