Skip to main content
Module

x/fun/mod.ts>set.elemOf

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

Given an instance of Comparable create a function that uakes a ReadonlySet and returns a predicate over a value A the returns true if the value is a member of the set. This is like elem but with the set and value parameters swapped.

Examples

Example 1

import * as S from "./set.ts";
import * as N from "./number.ts";

const elemOf = S.elemOf(N.ComparableNumber);

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

const result1 = inSet(1); // true
const result2 = inSet(10); // false

Parameters

S: Comparable<A>

Returns

(ua: ReadonlySet<A>) => (a: A) => boolean