Haskell语言Prelude模块中函数maybe的用法及代码示例。
用法类型:
a -> (b -> a) -> Maybe b -> a
示例1:
输入:
maybe 5 negate (lookup 1 [(1,10),(2,20)])
输出:
-10
示例2:
输入:
maybe 5 negate (lookup 9 [(1,10),(2,20)])
输出:
5
注:本文由纯净天空筛选整理自 haskell maybe。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。