Fixing remove runtime

pull/2/head
Oliver Kennedy 2022-09-21 14:06:05 -04:00
parent 4e1ecbc83c
commit e2ded68b19
Signed by: okennedy
GPG Key ID: 3E5F9B3ABD3FDB60
1 changed files with 5 additions and 5 deletions

View File

@ -144,7 +144,7 @@ textbook: "Ch. 7"
<p>Implementing <tt>insert</tt>.</p>
<pre style="transform: scale(0.8); margin-top: -50px; margin-bottom: -50px;" class="fragment"><code class="scala">
<pre style="transform: scale(0.8); margin-top: -50px; margin-bottom: -50px;"><code class="scala">
def insert(idx: Int, value: T): Unit =
{
if(idx == 0){
@ -207,10 +207,10 @@ textbook: "Ch. 7"
def sum(list: List[Int]): Unit =
{
val total: Int = 0
val curr = list.head
while(curr.isDefined){
total += curr.get.value
curr = curr.get.next
val current = list.head
while(current.isDefined){
total += current.get.value
current = current.get.next
}
return total
}