Lazy Pattern Matching

2011-05-14 黄毅

看代码,不解释。

普通pattern match:

Prelude> let f (x, y) = [1, x]
Prelude> let a = f undefined
Prelude> head a
*** Exception: Prelude.undefined

Lazy pattern matching:

Prelude> let f ~(x, y) = [1, x]
Prelude> let a = f undefined
Prelude> head a
1
Prelude> a !! 1
*** Exception: Prelude.undefined

blog comments powered by Disqus

转载请注明出处,收藏或分享这篇文章到: