如何擁有多個不相互交錯的陳述陳述? 例如玩具例子:SML:多個案例陳述
fun multi_cases(xs) =
case xs of
[] => 5
| x::ys => case x of
1 => 2
|_ => 3
| x::[] => case x of
1 => 5
| _ => 7
;
stdIn:59.17-64.28 Error: types of rules don't agree [overload conflict]
earlier rule(s): [int ty] -> [int ty]
this rule: [int ty] list -> [int ty]
in rule:
:: (x,nil) =>
(case x
of 1 => 5
| _ => 7)
最後兩個case語句得到混合起來,我怎麼能告訴SML,他們確實是兩個獨立的case語句,而不是1情況下,x的延續/獨立分支=> 2 ...
上面的答案在下面的答案中指出了它們的一般性問題。
[巢式病例中陳述的可能的複製SML](http://stackoverflow.com/questions/14708732/nested-case-statements-in-sml) –