# Mar22 - CSE262 Programming Languages Instructor Dr Liang...

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

CSE262: Programming Languages Instructor: Dr. Liang Cheng Department of Computer Science and Engineering P.C. Rossin College of Engineering & Applied Science Lehigh University March 22, 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/22/07 Outline ± Recap ± Functional programming language (Chapter 15) ± Subprogram (Chapter 9) ± Homework and summary
Instructor: Dr. Liang Cheng CSE262: Programming Languages 03/22/07 Scheme - Functions ± Primitive functions ± Arithmetic, QUOTE, CAR, CDR, CONS, LIST, Lambda functions ± Predicate functions ± EQ?, LIST?, NULL? ± Numeric predicate functions =, <>, >, <, >=, <=, EVEN?, ODD?, ZERO?, NEGATIVE? ± User-defined functions ± DEFINE binds names to lambda expressions

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

View Full Document
Instructor: Dr. Liang Cheng CSE262: Programming Languages 03/22/07 Scheme - Control Flow ± Two-way selections: IF (IF predicate then_exp else_exp) ± Multiple-way selections: COND (COND (predicate_1 expr {expr}) (predicate_2 expr {expr}) ... (predicate_n expr {expr}) (ELSE expr {expr}) ) ± Returns the value of the last expr in the first pair whose predicate evaluates to true
Instructor: Dr. Liang Cheng CSE262: Programming Languages 03/22/07 Fundamentals of FPL ± Functional programming languages (FPL) ± To mimic mathematical functions ± A mathematical function is a mapping of members of one set, called the domain set , to another set, called the range set. ± FPL vs. imperative languages ± Variable usage ± Recursion usage ± Complexity of syntax and semantics ± Execution speed

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

View Full Document
Instructor: Dr. Liang Cheng CSE262: Programming Languages 03/22/07 Function Forms ± A higher-order function, or functional form ± Takes functions as parameters, or ± Yields a function as its result, or ± Both ± Composition ± Apply-to-all
Instructor: Dr. Liang Cheng CSE262: Programming Languages 03/22/07 Functional Forms – Composition ± Takes two functions as parameters and yields a function ± h f ° g which means h (x) f ( g (x)) For f (x) x * x * x and g (x) x + 3, h f ° g yields (x + 3)* (x + 3)* (x + 3)

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

View Full Document
Instructor: Dr. Liang Cheng CSE262: Programming Languages 03/22/07 Functional Forms – Apply-to-all ± Takes a single function as a parameter and yields a list of values ± Denoted as α For h (x) x * x * x α ( h, (3, 2, 4)) yields (27, 8, 64)
Instructor: Dr. Liang Cheng

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 / 32

Mar22 - CSE262 Programming Languages Instructor Dr Liang...

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

View Full Document
Ask a homework question - tutors are online