query
On this page

partition

lib.lists.partition

Primop
Docs pulled from | This Revision | about 1 hour ago

Takes 2 arguments

pred, list


Splits the elements of a list in two lists, right and wrong, depending on the evaluation of a predicate.

Inputs

pred

Predicate

list

Input list

Type

(a -> bool) -> [a] -> { right :: [a]; wrong :: [a]; }

Examples

lib.lists.partition usage example

partition (x: x > 2) [ 5 1 2 3 4 ]
=> { right = [ 5 3 4 ]; wrong = [ 1 2 ]; }

Noogle detected

Aliases

Implementation

This function is implemented in c++ and is part of the native nix runtime.

Implementation

The following is the current implementation of this function.

partition = builtins.partition;