COMPSCI 61A Lecture Notes - Lecture 14: Mutation, Referential Transparency, Higher-Order Function

24 views5 pages
zogo39484755 and 6 others unlocked
COMPSCI 61A Full Course Notes
22
COMPSCI 61A Full Course Notes
Verified Note
22 documents

Document Summary

Functions that have data associated with them that changes. Ex: model of a bank account w/ 100 dollars. >>> withdraw = make_withdraw(100) create a higher order function. Within the parent frame of the function, function has a body and a parent environment, data will live in the parent environment. All calls to the same function have the same parent. Assignment statement inside def statement, bound to first frame in the currrent einvornment. Effect: future assignments to that name change its pre-existing binding in the first. Always refer to value of balance with withdraw, now can change values in parent frames, but need nonlocal statement. Nonlocal statements: non-local frame of the current environment in which that name is bound. Names listed in nonlocal statement must refer to pre-existing bindings in an enclosing scope. Names listed in a nonlocal statement must not collide with pre-existing bindings in the local scope current frame x = 2.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents