CSE 130 Lecture Notes - Lecture 3: Syntactic Sugar, Evaluation Strategy, Function Application

11 views3 pages
17 Jan 2018
School
Course
Professor
JS functions
( function() { w/ syntactic sugar: ( () => {
}) (); }) ();
Fundamentals and Lambda Calculus
-simplest “reasonable” programming language
-one feature: functions
-good for studying binding
-competes against “Turing machines”
-use lambda calculus to extend to different features
- control flow, operators, classes, etc…
-”evaluation strategy” - only evaluate IF it needs to be used
Syntax - symbols used to describe programs
Def func:, x+y, cout << “yo”;
Semantics - the “meaning” of the program and how we interpret it
-what’s a PL implementation of Syntax -> Semantics? Functions
Expressions: e ::= x | ƛx.e | e1e2
- Variables: x,y,z,etc.
-ƛ abstractions (function): ƛx . e
Name arg whatever in function
- same a s x => e in JS
- Do something w/ functions:e1 e2
- Function e1 is “applied” to function/var/etc. E2
- Same as e1(e2) in JS
Examples:
-ƛx.(2+x) ← NOT valid! There is NO + in ƛ calculus
Assume 2 AND + are encoded by functions
- In JS: x => 2 + x
- (ƛx.(2+x)) 5
- In JS: (x => 2+x) (5)
x = > { return 2 + x; }
- (ƛf.(f 3)) (ƛx.(x + 1))
- In JS: ( f => f(3) ) ( x => x+1 )
Composition: (f o f) (x)
In JS:
f => (x => f ( (x))) //argument f that returns a function which takes in x as an argument and
//returns f(f(x))
In ƛ:
ƛf. (ƛx. f (f x))
Unlock document

This preview shows page 1 of the document.
Unlock all 3 pages and 3 million more documents.

Already have an account? Log in

Get OneClass Notes+

Unlimited access to class notes and textbook notes.

YearlyBest Value
75% OFF
$8 USD/m
Monthly
$30 USD/m
You will be charged $96 USD upfront and auto renewed at the end of each cycle. You may cancel anytime under Payment Settings. For more information, see our Terms and Privacy.
Payments are encrypted using 256-bit SSL. Powered by Stripe.