这个任务来自Induction to Programming using sml 5.14
这是我的代码,但我得到这个消息模式匹配在基本情况下并不详尽..
fun revrev [] = [[], []]
| revrev [x::xs,y::ys] = revrev[ys@[y], xs @ [x]];
val test1revrev = revrev [[1, 2],[3, 4, 5]];
From valtest1 I want the output [[5, 4, 3], [2, 1]]
我不明白为什么我的功能不起作用,也许需要一点洞察力。
例如,这有效...
fun rev [] = []
| rev (x::xs) = rev1 xs @ [x];
val test1rev = rev [1, 2, 3];
I get [3, 2, 1]