Home
Alexander Lu
Cancel

CS61A: Lecture 28

Interpreters The scheme interpreter represents expressions as Pairs. For the operands, we must evaluate each of the values individually. This is because we may have compound expressio...

CS61A: Interpreters

Interpreting Scheme There are two parts to an interpreter Eval: The eval evaluates primitive and combined expressions. It calls apply to apply a procedure to certain arguments in expr...

CS61A: Lecture 27

List Processing Procedures Review Built-in Methods: -(append s t): Concatenates two or more lists together into a new list -(map f s): Call a procedures f on each element of a list and retur...

CS61A: Calculator

Exceptions Exceptions allow us to raise an error for unexpected behaviors We may raise exceptions with the raise statement in Python: raise <expression> Expression must evaluate t...

CS61A: Scheme Lists

Lists Every list in Scheme is a linked list. Names for linked list: cons: Two-argument procedure that creates a linked list car: Procedure that returns the first element of a ...

CS61A: Lecture 26

Scheme Lists Scheme lists are written in parentheses with elements separated by spaces Procedures cons: Procedure that creates a new list. car: Procedure that prints out the f...

CS61A: Scheme

Scheme Scheme is a dialect of lisp Scheme programs consist of expressions: Primitive expressions: 2, 3.3, true, +, quotient, … “quotient” names Scheme’s built-in ...

CS61A: Lecture 25

Lecture - The Scheme Programming Language 2 Reasons Concepts in Python transfers into another programing language Build an interpreter for Scheme A program th...

CS61A: Lecture 22

Lecture Tree Class A Tree has a label and a list of branches; each branch is also a Tree class Tree: def __init__(self, label, branches=[]): self.label = label for branch i...

CS61A: Lecture 23

Measuring Efficiency Efficiency is the measure of how long our program would take to run. Ex: The recursive computation of the fibonacci sequence def fib(n): if n == 0: return 0 ...