diff --git a/src/main/scala/example/Vector.scala b/src/main/scala/example/Vector.scala index 85b0c8cf36d15cb95d2583273c77cb867aa87477..8fdcf6dc45150e0550bc26c12695c909a022d8f4 100644 --- a/src/main/scala/example/Vector.scala +++ b/src/main/scala/example/Vector.scala @@ -3,10 +3,19 @@ import scala.math.sqrt case class Vector(var list : List[Double]) { + // return the number of elements in the vector val size = () => this.list.size + + // return the element at index i val get = (i : Int) => this.list(i) + + // verify if two vectors are equals val equals = (v : Vector) => this.list == v.list + + // update an element with a value at index i val update = (i : Int, value : Double) => this.list = this.list.updated(i, value) + + // verify if two vectors have the same size val sameSize = (v : Vector) => this.size() == v.size() // Add Terminal recursive