Skip to main content
Module

x/fun/mod.ts>set.flatmap

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Latest
function set.flatmap
import { set } from "https://deno.land/x/fun@v2.0.0/mod.ts";
const { flatmap } = set;

Given a function A -> ReadonlySet and a ReadonlySet return a ReadonlySet created by applying the function to every value A and joining all the resulting ReadonlySets.

Examples

Example 1

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

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

const result = pipe(
  set,
  S.flatmap(n => S.set(n, n + 1, n + 2)),
); // Set(1, 2, 3, 4, 5, 6, 7);

Parameters

fati: (a: A) => ReadonlySet<I>

Returns

(ua: ReadonlySet<A>) => ReadonlySet<I>