Haskell语言Maybe模块中函数maybeToList的用法及代码示例。
用法类型:
Maybe a -> [a]
如果参数是Just,则返回以Just值为元素的列表,否则返回空列表
示例1:
输入:
maybeToList (lookup 3 [(1,'A'),(2,'B'),(3,'C')])
输出:
"C"
示例2:
输入:
maybeToList (lookup 3 [(1,11),(2,22),(3,33)])
输出:
[33]
示例3:
输入:
maybeToList (lookup 32 [(1,'A'),(2,'B'),(3,'C')])
输出:
""
示例4:
输入:
maybeToList (lookup 32 [(1,11),(2,22),(3,33)])
输出:
[]
相关用法
注:本文由纯净天空筛选整理自 haskell maybeToList。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。