Haskell语言Maybe模块中函数mapMaybe的用法及代码示例。
用法类型:
(a -> Maybe b) -> [a] -> [b]
示例1:
输入:
mapMaybe (`lookup` [(1,11),(2,22),(3,33)]) [1,2,11]
输出:
[11,22]
示例2:
输入:
mapMaybe (`lookup` [('a',"AAA"),('b',"BBB"),('c',"CCC")]) "acfg"
输出:
["AAA","CCC"]
相关用法
注:本文由纯净天空筛选整理自 haskell mapMaybe。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。