パターンマッチングを使用してscala splitAtを実装しようとしていますが、これが私がやろうとしていることです:
def split[T](someIndex:Int,someList:List[T]):(List[T],List[T]) = {
def splitHelper[T](currentIndex:Int,someList:List[T],headList:List[T]):(List[T],List[T])= {
(currentIndex,someList) match {
case (someIndex,x::tail) => (x::headList,tail)
case (currentIndex,x::y) => splitHelper(currentIndex+1,y,x::headList)
case _ => (headList,headList)
}
}
splitHelper(0,someList,List[T]())
}
コンパイラは次のように不平を言っています。
<console>:15: error: unreachable code
case (currentIndex,x::y) => splitHelper(currentIndex+1,y,x::headList)
ここで私が間違っていることと、到達不能コードエラーが発生する理由を誰かが指摘できますか?
ありがとう