Class Notes (809,487)
United States (313,610)
COMPSCI 61A (130)
De Nero (43)
Lecture

# CS61A Lecture 01 & 02: Functions & Environment Diagrams

3 Pages
137 Views

School
University of California - Berkeley
Department
Computer Science
Course
COMPSCI 61A
Professor
De Nero
Semester
Summer

Description
Expressions - an expression describes a computation and evaluates to a value All expressions use function call notation Ex: max (1, 2, 3) = 3 min (1, 2, 3) = 1 from operator import add, mil add (2, 3) = 5 mul (4, 5) = 20 mul (add(2, mul(4, 6)), add(3, 5)) --> NEST --> 208 Call Expression add ( 2 , 3 ) Operator Operand Operand Operator + Operand = Expressions Evaluate to values Procedure 1. Eval. operator + operand 2. Apply function that is value of operator subexpression Evaluating nested expressions mul ( add ( 2 , mul(4, 6), add (3, 5)) mul add ( 2, mul ( 4, 6 ) ) add ( 3, 5 ) = 8 add 2 + 24 (4 * 6) Expression Tree ^^^ Open ('file') len = length text.count('.') 'word' in words [ :: - 1 ] backwards Data: things that programs fiddle with Functions: Rules for manipulating data Interpreter: An implementation of the procedure for evaluation Names, User Defined Functions, Assignments Name - expression refer to some value , can bind multiple names to multiple values def square(x): return mul(x, x) --> Also nest functions square (3) 9 Types of Expressions Primitive Expressions: Number, Name, Strings Call Expressions: operator, operand, operand ***Operands can also be call expression Environment Diagrams visualize interpreter's process Execution rule for assignment statements 1. Evaluate all expression to right of = left to right 2. Bind all names to left of
More Less

Related notes for COMPSCI 61A

OR

Don't have an account?

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Join to view

OR

By registering, I agree to the Terms and Privacy Policies
Just a few more details

So we can recommend you notes for your school.