DOC PREVIEW
Berkeley COMPSCI 61A - Lecture 30

This preview shows page 1-2-3-4-5-6-7-51-52-53-54-55-56-57-58-102-103-104-105-106-107-108 out of 108 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 108 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

61A Lecture 30Wednesday, November 9Wednesday, November 9, 2011Functional Programming2Wednesday, November 9, 2011Functional ProgrammingAll functions are pure functions2Wednesday, November 9, 2011Functional ProgrammingAll functions are pure functionsNo assignment and no mutable data types2Wednesday, November 9, 2011Functional ProgrammingAll functions are pure functionsNo assignment and no mutable data typesName-value bindings are permanent2Wednesday, November 9, 2011Functional ProgrammingAll functions are pure functionsNo assignment and no mutable data typesName-value bindings are permanentAdvantages of functional programming:2Wednesday, November 9, 2011Functional ProgrammingAll functions are pure functionsNo assignment and no mutable data typesName-value bindings are permanentAdvantages of functional programming:•The value of an expression is independent of the order in which sub-expressions are evaluated2Wednesday, November 9, 2011Functional ProgrammingAll functions are pure functionsNo assignment and no mutable data typesName-value bindings are permanentAdvantages of functional programming:•The value of an expression is independent of the order in which sub-expressions are evaluated•Sub-expressions can safely be evaluated in parallel or lazily2Wednesday, November 9, 2011Functional ProgrammingAll functions are pure functionsNo assignment and no mutable data typesName-value bindings are permanentAdvantages of functional programming:•The value of an expression is independent of the order in which sub-expressions are evaluated•Sub-expressions can safely be evaluated in parallel or lazily•Referential transparency: The value of an expression does not change when we substitute one of its subexpression with the value of that subexpression.2Wednesday, November 9, 2011Functional ProgrammingAll functions are pure functionsNo assignment and no mutable data typesName-value bindings are permanentAdvantages of functional programming:•The value of an expression is independent of the order in which sub-expressions are evaluated•Sub-expressions can safely be evaluated in parallel or lazily•Referential transparency: The value of an expression does not change when we substitute one of its subexpression with the value of that subexpression.The subset of Logo we have considered so far is functional(except for print/show)2Wednesday, November 9, 2011The Logo Assignment Procedure3Wednesday, November 9, 2011The Logo Assignment ProcedureLogo binds variable names to values, as in Python3Wednesday, November 9, 2011The Logo Assignment ProcedureLogo binds variable names to values, as in PythonAn environment stores name bindings in a sequence of frames3Wednesday, November 9, 2011The Logo Assignment ProcedureLogo binds variable names to values, as in PythonAn environment stores name bindings in a sequence of framesEach frame can have at most one value bound to a given name 3Wednesday, November 9, 2011The Logo Assignment ProcedureLogo binds variable names to values, as in PythonAn environment stores name bindings in a sequence of framesEach frame can have at most one value bound to a given name The make procedure adds or changes variable bindings3Wednesday, November 9, 2011The Logo Assignment ProcedureLogo binds variable names to values, as in PythonAn environment stores name bindings in a sequence of framesEach frame can have at most one value bound to a given name The make procedure adds or changes variable bindings3? make "x 2Wednesday, November 9, 2011The Logo Assignment ProcedureLogo binds variable names to values, as in PythonAn environment stores name bindings in a sequence of framesEach frame can have at most one value bound to a given name The make procedure adds or changes variable bindings3? make "x 2Values bound to names are looked up using variable expressionsWednesday, November 9, 2011The Logo Assignment ProcedureLogo binds variable names to values, as in PythonAn environment stores name bindings in a sequence of framesEach frame can have at most one value bound to a given name The make procedure adds or changes variable bindings3? make "x 2Values bound to names are looked up using variable expressions? print :x2Wednesday, November 9, 2011The Logo Assignment ProcedureLogo binds variable names to values, as in PythonAn environment stores name bindings in a sequence of framesEach frame can have at most one value bound to a given name The make procedure adds or changes variable bindings3? make "x 2Values bound to names are looked up using variable expressions? print :x2DemoWednesday, November 9, 2011Namespaces for Variables and Procedures4Wednesday, November 9, 2011Namespaces for Variables and Procedures4FRAMESWednesday, November 9, 2011Namespaces for Variables and Procedures4FRAMES PROCEDURESWednesday, November 9, 2011Namespaces for Variables and Procedures4x: 2FRAMES PROCEDURESWednesday, November 9, 2011Namespaces for Variables and Procedures4x: 2FRAMES PROCEDURESsum :x :y<built-in>first :x<built-in>sum:first:make :n :v<built-in>make:...Wednesday, November 9, 2011Namespaces for Variables and Procedures4x: 2FRAMES PROCEDURESsum :x :y<built-in>first :x<built-in>sum:first:make :n :v<built-in>make:...? make "sum 3Wednesday, November 9, 2011Namespaces for Variables and Procedures4x: 2FRAMES PROCEDURESsum :x :y<built-in>first :x<built-in>sum:first:make :n :v<built-in>make:...? make "sum 3sum: 3Wednesday, November 9, 2011Namespaces for Variables and Procedures4x: 2FRAMES PROCEDURESsum :x :y<built-in>first :x<built-in>sum:first:make :n :v<built-in>make:...? make "sum 3sum: 3DemoWednesday, November 9, 2011Assignment Rules5Wednesday, November 9, 2011Assignment RulesLogo assignment has different rules from Python assignment:5Wednesday, November 9, 2011Assignment RulesLogo assignment has different rules from Python assignment:5? make <name> <value>Wednesday, November 9, 2011Assignment RulesLogo assignment has different rules from Python assignment:5•If the name is already bound, make re-binds that name in the first frame in which the name is bound.? make <name> <value>Wednesday, November 9, 2011Assignment RulesLogo assignment has different rules from Python assignment:5•If the name is already bound, make re-binds that name in the first frame in which the name is bound.? make <name> <value>Like non-local Python assignmentWednesday, November 9, 2011Assignment RulesLogo assignment has different rules from Python assignment:5•If the name is already bound, make re-binds that name


View Full Document

Berkeley COMPSCI 61A - Lecture 30

Documents in this Course
Lecture 1

Lecture 1

68 pages

Midterm

Midterm

5 pages

Midterm

Midterm

6 pages

Lecture 35

Lecture 35

250 pages

Lecture 14

Lecture 14

125 pages

Lecture 2

Lecture 2

159 pages

Lecture 6

Lecture 6

113 pages

Lecture 3

Lecture 3

162 pages

Homework

Homework

25 pages

Lecture 13

Lecture 13

117 pages

Lecture 29

Lecture 29

104 pages

Lecture 11

Lecture 11

173 pages

Lecture 7

Lecture 7

104 pages

Midterm

Midterm

6 pages

Midterm

Midterm

6 pages

Lecture 8

Lecture 8

108 pages

Lab 4

Lab 4

4 pages

Lecture 7

Lecture 7

52 pages

Lecture 20

Lecture 20

129 pages

Lecture 15

Lecture 15

132 pages

Lecture 9

Lecture 9

95 pages

Lecture 17

Lecture 17

106 pages

Load more
Download Lecture 30
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 30 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 30 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?