defined object MyList
Thursday, September 12, 2024
What questions does your neighbor have?
Lab1.scala
. Just read Jupyter notebook or use it for scratch work.A list is an inductive data type:
defined object MyList
defined function length
defined function length
Could l.tail
fail?
defined function append
Now, we see why append
(and :::
in the Scala library) has to be linear time.
What does buggyAppend
do?
defined function buggyAppend
defined function reverse
defined function reverse
:
Compilation Failed
m: Map[Int, List[String]] = Map( 2 -> List("two", "dos", "\u4e8c"), 10 -> List("ten", "diez", "\u5341") ) newm: Map[Int, List[String]] = Map( 2 -> List("two", "dos", "\u4e8c"), 10 -> List("ten", "diez", "\u5341"), 14 -> List("fourteen", "catorce", "\u5341\u56db") )
Since we want to study small sub-languages common to programming languages in general, we don’t care much about concrete syntax.
Let’s consider JavaScripty to be the subset of JavaScript we want to study at the moment, for example, number literals and +
:
Our goal is to implement semantics following JavaScript (for this small JavaScripty).
The process of converting a program in concrete syntax (i.e., as a string) to a program in abstract syntax (i.e., as a tree) is called parsing.
:
Compilation Failed
defined function eval