query
On this page

flatten

lib.lists.flatten

Docs pulled from | This Revision | 21 minutes ago


Flatten the argument into a single list; that is, nested lists are spliced into the top-level lists.

Inputs

x

1. Function argument

Examples

lib.lists.flatten usage example

flatten [1 [2 [3] 4] 5]
=> [1 2 3 4 5]
flatten 1
=> [1]

Noogle detected

Aliases

Implementation

The following is the current implementation of this function.

flatten = x:
    if isList x
    then concatMap (y: flatten y) x
    else [x];