I am using Scala for studying purpose I wrote this code to sort the elements in list
def isort(xs:List[Int]):List[Int]=
xs match{
case List() => xs
case y::ys => insert(y,isort(ys))
}
def insert(x:Int,xs:List[Int]):List[Int]=
xs match{
case List() => List(x)
case y::ys => if(x<y) x::xs else y :: insert(x,ys)
}
but I am getting the following error:
Constructor can not be instantiated to expected type found Scala.collection.Immutable required List[Int]
in
`y::ys => insert(y,isort(ys))`
and similar error where I use ::
I refer tutorial : https://class.coursera.org/progfun-005/lecture