The HW for next week will be on Scheme + Scheme Data Abstractions, so just get ready for that!
Notes from last section
good disc today/nice work
ty
I appreciate how you help students by guiding them with questions instead of telling them the answer
this is the sort of thing i try and go for even during lab/oh - if you haven't noticed by now, i tend to ask questions in response to other questions (and if you haven't, now you know )
btw if you use osx i highly recommend switching over to arc as your main browser
it's very good (it's what i personally have been using for a while)
Do you have any favorite memes?
not that i can think of off the top of my head, but you will find a few good ones during the sql lecture i'm giving lol
In the game Undertale, sometimes a rare theme plays while fighting Sans in the Genocide route. It's a rather delicate tune. Additionally, Sans is one of two characters within the game that is aware that the player can reset the game, the only other one being the final bosses of the pacifist and normal route
i think i've heard the alternate song, and it's kinda - very interesting composition/arrangement
Temperature Check
Interpreters
Tail Calls
Scheme Data Abstractions
Interpreters
What is an interpreter
An interpreter is a program used to understand other programs
We will start off with the Calculator language to look at Scheme Syntax (and how to interpret it)
You will be writing an interpreter for the final project (this is a super cool project)
note to anto: open discussion worksheet
How does it work
Essentially is the code version of what we've studied during week 1!
Evaluate operators/operands, apply operands to operators; this whole process is done through our own interpreter
Pair Class
We will be using the Pair class (very similar to Link, but with a few added bonuses/slight differences)
Has a first and rest attribute
Also has a map method where it applies a function to every argument
Must provide nil, does not default to Link.empty like with our Link class
If p is a Pair containing a proper call expression, we get the operator by doing p.first, and get the operands with p.rest. To get the first operand, we need to do p.rest.first
Pair class
classPair:"""Represents the built-in pair data structure in Scheme."""def__init__(self, first, rest):
self.first = first
ifnot scheme_valid_cdrp(rest):
raise SchemeError("cdr can only be a pair, nil, or a promise but was {}".format(rest))
self.rest = rest
defmap(self, fn):"""Maps fn to every element in a list, returning a new
Pair.
>>> Pair(1, Pair(2, Pair(3, nil))).map(lambda x: x * x)
Pair(1, Pair(4, Pair(9, nil)))
"""assertisinstance(self.rest, Pair) or self.rest is nil, \
"rest element in pair must be another pair or nil"return Pair(fn(self.first), self.rest.map(fn))