flatten
lib.lists.flatten
Docs pulled from | This Revision | about 1 hour ago
Flatten the argument into a single list; that is, nested lists are spliced into the top-level lists.
Inputs
x-
1. Function argument
Type
flatten :: [a | [a | [a | ...]]] -> [a]
Examples
lib.lists.flatten usage example
flatten [1 [2 [3] 4] 5]
=> [1 2 3 4 5]
flatten 1
=> [1]
Noogle detected
Implementation
The following is the current implementation of this function.
flatten = x: if isList x then concatMap (y: flatten y) x else [ x ];