defined function sum res16_1: Int = 6
Thursday, September 5, 2024
In-Class Slides
In-Class Jupyter
In-Class Jupyter of Homework 1
Book Chapter
filterPairsByBound
(and the filterPairsByBoundLinearTime
) "test1"
.
Because List
s are immutable, prepending is still a constant-time operation (i.e., \(O(1)\)). The consZero
and consTen
can share the same tail (i.e., numbers
).
How many nodes are needed total to represent the lists numbers
, consZero
, and consTen
? 5
Why must append :::
be a linear-time operation?
defined function sum res16_1: Int = 6
Maps are particularly useful data structures for storing associations between keys and values.
Observe that getOrElse
(as well as the MyNone
and MySome
constructors) have a type parameter list (written brackets []
) and a value parameter list (written in parentheses ()
).
The getOrElse
function is generic in the parametrized type A
. Being generic, the getOrElse
function is also called parametric polymorphic.