Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/fun/set.ts>partition

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Go to Latest
function partition
import { partition } from "https://deno.land/x/fun@v.2.0.0-alpha.11/set.ts";

Given a Predicate or Refinement over A and a ReadonlySet return a Pair with a first value being a ReadonlySet of values that return true when applied to the refinement or predicate and a second value being a ReadonlySet of values that return false when applied to the predicate.

Examples

Example 1

import * as S from "./set.ts";
import { pipe } from "./fn.ts";

const set = S.set(1, 2, 3, 4);

const result = pipe(
  set,
  S.partition(n => n > 2),
); // [Set(3, 4), Set(1, 2)]

Type Parameters

A
B extends A

Parameters

refinement: Refinement<A, B>

Returns

(ua: ReadonlySet<A>) => Pair<ReadonlySet<B>, ReadonlySet<A>>

Returns

(ua: ReadonlySet<A>) => Pair<ReadonlySet<A>, ReadonlySet<A>>