I am still relatively very new to Scala. I was going through the List implementation of Scala, where I saw that a lot of funcitons still use "var" in the implementation. I have been reading how scala is more functional oriented, therefore instead of using "var" should the library not use tail recursion where possible.
For example exsits could be re-written as:
@tailrec
def exists[A](f : A => Boolean) : Boolean = this match {
case Nil => false
case l:LinearSeq[A]=> if (f(l.head)) true else exists(l.tail,f)
}
The reason I ask is as I have being reading a lot of material where it is discouraged to use "var", but I see a lot of that being used in the List implementation.
Thanks!