def isLegalFor(board:Board) =
(board(from), board(to)) match {
case (Nil, _) => false
case (x :: _, Nil) => true
case (x :: _, y :: _) if x < y => true
case (x :: _, y :: _) if x > y => false
}
board(from) and board(to) are both List[Int]
produces warning:
[warn] missing combination * Nil * *
This seems really confusing.
The first case should cover list1 being empty and list2 being anything at all
The last three cases should cover list1 having at least one element and list2 being either empty or at least one element.
List can be either empty or not … thats four total combinations. Seems ok. What is missing?
You are missing a condition when both lists have at least one element
xandyandx == y:or if you decide what to do with
x == yyou can combine the last two cases and include the third one above with simple: