【发布时间】:2018-10-08 17:56:42
【问题描述】:
什么是嵌套模式?我不明白为什么以下有嵌套模式:
exception BadTriple
fun zip3 list_triple =
case list_triple of
([],[],[]) => []
| (hd1::tl1,hd2::tl2,hd3::tl3) => (hd1,hd2,hd3)::zip3(tl1,tl2,tl3)
| _ => raise BadTriple
fun unzip3 lst =
case lst of
[] => ([],[],[])
| (a,b,c)::tl => let val (l1,l2,l3) = unzip3 tl
in
(a::l1,b::l2,c::l3)
end
另外,我不明白 nested pattern 和 nested case-expression 有什么不同,我能举一些关于这些事情的例子吗?
【问题讨论】: