Seite 1 von 1

### Calculating WAE Expressions

Verfasst: 20. Jan 2019 12:48
Hello,

I didn't understand the topic: "Calculating WAE Expressions" in V02.pdf > slide 21. Can someone please explain these things simply:

How come we get these lines?:
...
case Let(boundId, namedExpr, boundExpr) => {
interp(subst(boundExpr, boundId, Num(interp(namedExpr))))
}
case Id(name) => sys.error("found unbound id " + name)
...

where are we using the "subst" function?

[I already know the definition of substitution, also know Binding instance, scope, bound instance, free instance and their positions in a function]

Also, didn't understand this part (slide 26), how come we are getting these:
...
case Sub(lhs, rhs) => Sub(subst(lhs, substId, value), subst(rhs, substId, value))
case Let(boundId, namedExpr, boundExpr) => {
val substNamedExpr = subst(namedExpr, substId, value)
if (boundId == substId)
Let(boundId, substNamedExpr, boundExpr)
else
Let(boundId, substNamedExpr, subst(boundExpr, substId, value))
}
...

And if you know, please refer book chapter or link that elaborates the topic.