functionalscript
Version:
FunctionalScript is a purely functional subset of JavaScript
31 lines (30 loc) • 1.05 kB
TypeScript
/**
* A set of strings implemented as a B-Tree.
*
* @module
*
* @example
*
* ```js
* import { set, contains, remove, fromValues, values, empty } from './module.d.ts';
*
* let mySet = fromValues(['apple', 'banana', 'cherry']);
* if (!contains('banana')(mySet)) { throw '1' }
* if (contains('date')(mySet)) { throw '2' }
*
* mySet = set('date')(mySet);
* if (!contains('date')(mySet)) { throw '3' }
*
* mySet = remove('banana')(mySet);
* if (contains('banana')(mySet)) { throw '4' }
* ```
*/
import type { Tree } from '../btree/types/module.f.ts';
import { type List } from '../list/module.f.ts';
export declare const values: (s: StringSet) => List<string>;
export declare const empty: null;
export type StringSet = Tree<string>;
export declare const contains: (value: string) => (set: StringSet) => boolean;
export declare const set: (value: string) => (s: StringSet) => StringSet;
export declare const fromValues: (input: List<string>) => StringSet;
export declare const remove: (value: string) => (s: StringSet) => StringSet;