ZVON > References > Haskell reference
| Indexes | Syntax | Prelude | Ratio | Complex | Numeric | Ix | Array | List | >> Maybe << | Char | Monad | IO | Directory | System | Time | Locale | CPUTime | Random

Module: Maybe
Function: maybeToList
Type: Maybe a -> [a]
Description: If the argument is Just, it returns a list with the Just value as its element, otherwise it returns empty list
Related: fromJust, fromMaybe, listToMaybe, mapMaybe

Example 1

Input: maybeToList (lookup 3 [(1,'A'),(2,'B'),(3,'C')])

Output: "C"

Example 2

Input: maybeToList (lookup 3 [(1,11),(2,22),(3,33)])

Output: [33]

Example 3

Input: maybeToList (lookup 32 [(1,'A'),(2,'B'),(3,'C')])

Output: ""

Example 4

Input: maybeToList (lookup 32 [(1,11),(2,22),(3,33)])

Output: []