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

Info iconThis preview shows pages 1–10. 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 P.C. Rossin College of Engineering & Applied Science Lehigh University March 22, 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/22/07 Outline ± Recap ± Functional programming language (Chapter 15) ± Subprogram (Chapter 9) ± Homework and summary
Background image of page 2
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
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/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
Background image of page 4
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
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/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
Background image of page 6
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)
Background image of page 7

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/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)
Background image of page 8
Instructor: Dr. Liang Cheng
Background image of page 9

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

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

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 Right Arrow Icon
Ask a homework question - tutors are online