Fixing remove runtime
parent
4e1ecbc83c
commit
e2ded68b19
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue