Taking Notes from http://learnyouahaskell.com
Pattern matching
|
|
|
|
你若要绑定多个变量(用 _ 也是如此),我们必须用括号将其括起
error 函数,它可以生成一个运行时错误
|
|
‘as’ model
|
|
Guards
类似if语句,更好的可读性
|
|
通过 `,我们不仅可以以中缀形式调用函数,也可以在定义函数的时候使用它
Where
|
|
pattern matching
Another example
Where binding function
where 绑定可以定义名字,也可以定义函数
let
where 绑定是在函数底部定义名字,对包括所有 guard 在内的整个函数可见。let 绑定则是个 表达式,允许你在任何位置定义局部变量,而对不同的 guard 不可见
let [bindings] in [expressions]
在 let 中绑定的名字仅对 in 部分可见
作为表达式
list comprehension
Case expressions
pattern matching
is syntax suger of case expr
|
|
|
|