functionalscript 0.3.8 → 0.3.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/package.json +1 -1
  2. package/types/bigint/module.f.d.ts +19 -2
  3. package/types/bigint/module.f.js +23 -9
  4. package/types/bigint/test.f.d.ts +7 -0
  5. package/types/bigint/test.f.js +74 -0
  6. package/types/btree/find/module.f.d.ts +11 -10
  7. package/types/btree/find/module.f.js +1 -5
  8. package/types/btree/find/test.f.js +1 -2
  9. package/types/btree/module.f.d.ts +2 -2
  10. package/types/btree/remove/module.f.d.ts +2 -2
  11. package/types/btree/remove/module.f.js +0 -3
  12. package/types/btree/remove/test.f.js +2 -4
  13. package/types/btree/set/module.f.d.ts +2 -2
  14. package/types/btree/set/module.f.js +2 -6
  15. package/types/btree/test.f.js +9 -12
  16. package/types/btree/types/module.f.d.ts +1 -3
  17. package/types/byte_set/module.f.d.ts +3 -3
  18. package/types/byte_set/module.f.js +1 -2
  19. package/types/byte_set/test.f.js +2 -4
  20. package/types/function/compare/module.f.d.ts +1 -5
  21. package/types/map/module.f.d.ts +4 -6
  22. package/types/map/test.f.js +2 -2
  23. package/types/nibble_set/test.f.js +25 -25
  24. package/types/nullable/test.f.js +2 -2
  25. package/types/number/module.f.d.ts +2 -2
  26. package/types/number/module.f.js +1 -2
  27. package/types/object/test.f.js +3 -3
  28. package/types/range/test.f.js +6 -6
  29. package/types/range_map/module.f.d.ts +6 -6
  30. package/types/range_map/test.f.js +2 -4
  31. package/types/sorted_list/module.f.d.ts +4 -4
  32. package/types/sorted_list/test.f.js +8 -8
  33. package/types/sorted_set/module.f.d.ts +2 -2
  34. package/types/sorted_set/test.f.js +10 -10
  35. package/types/string/module.f.d.ts +2 -2
  36. package/types/string/module.f.js +1 -2
  37. package/types/string_set/module.f.d.ts +2 -2
  38. package/types/string_set/test.f.js +25 -25
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.3.8",
3
+ "version": "0.3.10",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "**/*.f.d.ts",
@@ -1,4 +1,21 @@
1
- import * as compare from '../function/compare/module.f.ts';
1
+ /**
2
+ * A collection of utility functions for working with `bigint` values.
3
+ *
4
+ * @module
5
+ *
6
+ * @example
7
+ *
8
+ * ```js
9
+ * import { sum, abs, log2, bitLength, mask } from './module.f.ts'
10
+ *
11
+ * const total = sum([1n, 2n, 3n]) // 6n
12
+ * const absoluteValue = abs(-42n) // 42n
13
+ * const logValue = log2(8n) // 3n
14
+ * const bitCount = bitLength(255n) // 8n
15
+ * const bitmask = mask(5n) // 31n
16
+ * ```
17
+ */
18
+ import { type Sign } from '../function/compare/module.f.ts';
2
19
  import type * as Operator from '../function/operator/module.f.ts';
3
20
  import { type List } from '../list/module.f.ts';
4
21
  export type Unary = Operator.Unary<bigint, bigint>;
@@ -6,7 +23,7 @@ export type Reduce = Operator.Reduce<bigint>;
6
23
  export declare const addition: Reduce;
7
24
  export declare const sum: (input: List<bigint>) => bigint;
8
25
  export declare const abs: Unary;
9
- export declare const sign: (a: bigint) => compare.Sign;
26
+ export declare const sign: (a: bigint) => Sign;
10
27
  export declare const serialize: (a: bigint) => string;
11
28
  /**
12
29
  * Calculates the base-2 logarithm (floor).
@@ -1,5 +1,21 @@
1
- import * as compare from "../function/compare/module.f.js";
2
- const { unsafeCmp } = compare;
1
+ /**
2
+ * A collection of utility functions for working with `bigint` values.
3
+ *
4
+ * @module
5
+ *
6
+ * @example
7
+ *
8
+ * ```js
9
+ * import { sum, abs, log2, bitLength, mask } from './module.f.ts'
10
+ *
11
+ * const total = sum([1n, 2n, 3n]) // 6n
12
+ * const absoluteValue = abs(-42n) // 42n
13
+ * const logValue = log2(8n) // 3n
14
+ * const bitCount = bitLength(255n) // 8n
15
+ * const bitmask = mask(5n) // 31n
16
+ * ```
17
+ */
18
+ import { unsafeCmp } from "../function/compare/module.f.js";
3
19
  import { reduce } from "../list/module.f.js";
4
20
  export const addition = a => b => a + b;
5
21
  export const sum = reduce(addition)(0n);
@@ -25,13 +41,11 @@ export const serialize = (a) => `${a}n`;
25
41
  * determining the exact value of the logarithm.
26
42
  */
27
43
  export const log2 = (v) => {
28
- // TODO: use step 32 and `Math.clz32()` at the end.
29
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32
30
44
  if (v <= 0n) {
31
45
  return -1n;
32
46
  }
33
- let result = 0n;
34
- let i = 1n;
47
+ let result = 31n;
48
+ let i = 32n;
35
49
  while (true) {
36
50
  const n = v >> i;
37
51
  if (n === 0n) {
@@ -43,8 +57,8 @@ export const log2 = (v) => {
43
57
  i <<= 1n;
44
58
  }
45
59
  // We know that `v` is not 0 so it doesn't make sense to check `n` when `i` is 0.
46
- // Because of this, We check if `i` is greater than 1 before we divide it by 2.
47
- while (i !== 1n) {
60
+ // Because of this, We check if `i` is greater than 32 before we divide it by 2.
61
+ while (i !== 32n) {
48
62
  i >>= 1n;
49
63
  const n = v >> i;
50
64
  if (n !== 0n) {
@@ -52,7 +66,7 @@ export const log2 = (v) => {
52
66
  v = n;
53
67
  }
54
68
  }
55
- return result;
69
+ return result - BigInt(Math.clz32(Number(v)));
56
70
  };
57
71
  /**
58
72
  * Calculates the bit length of a given BigInt.
@@ -1,4 +1,11 @@
1
1
  declare const _default: {
2
+ example: () => void;
3
+ benchmark: {
4
+ str: () => void;
5
+ stringHexLog2: () => void;
6
+ oldLog2: () => void;
7
+ log2: () => void;
8
+ };
2
9
  mask: () => void;
3
10
  sum: () => void;
4
11
  abs: (() => void)[];
@@ -1,5 +1,79 @@
1
1
  import { sum, abs, serialize, log2, bitLength, mask } from "./module.f.js";
2
+ const oldLog2 = (v) => {
3
+ if (v <= 0n) {
4
+ return -1n;
5
+ }
6
+ let result = 0n;
7
+ let i = 1n;
8
+ while (true) {
9
+ const n = v >> i;
10
+ if (n === 0n) {
11
+ // overshot
12
+ break;
13
+ }
14
+ v = n;
15
+ result += i;
16
+ i <<= 1n; // multiple by two
17
+ }
18
+ // We know that `v` is not 0 so it doesn't make sense to check `n` when `i` is 0.
19
+ // Because of this, We check if `i` is greater than 1 before we divide it by 2.
20
+ while (i !== 1n) {
21
+ i >>= 1n;
22
+ const n = v >> i;
23
+ if (n !== 0n) {
24
+ result += i;
25
+ v = n;
26
+ }
27
+ }
28
+ return result;
29
+ };
30
+ const stringLog2 = (v) => BigInt(v.toString(2).length) - 1n;
31
+ const stringHexLog2 = (v) => {
32
+ const len = (BigInt(v.toString(16).length) - 1n) << 2n;
33
+ const x = v >> len;
34
+ return len + 31n - BigInt(Math.clz32(Number(x)));
35
+ };
36
+ const benchmark = (f) => () => {
37
+ let e = 1048575n;
38
+ let c = 1n << e;
39
+ for (let i = 0n; i < 1_000; ++i) {
40
+ const x = f(c);
41
+ if (x !== e) {
42
+ throw x;
43
+ }
44
+ c >>= 1n;
45
+ --e;
46
+ }
47
+ };
2
48
  export default {
49
+ example: () => {
50
+ const total = sum([1n, 2n, 3n]); // 6n
51
+ if (total !== 6n) {
52
+ throw total;
53
+ }
54
+ const absoluteValue = abs(-42n); // 42n
55
+ if (absoluteValue !== 42n) {
56
+ throw total;
57
+ }
58
+ const logValue = log2(8n); // 3n
59
+ if (logValue !== 3n) {
60
+ throw total;
61
+ }
62
+ const bitCount = bitLength(255n); // 8n
63
+ if (bitCount !== 8n) {
64
+ throw total;
65
+ }
66
+ const bitmask = mask(5n); // 31n
67
+ if (bitmask !== 31n) {
68
+ throw total;
69
+ }
70
+ },
71
+ benchmark: {
72
+ str: benchmark(stringLog2),
73
+ stringHexLog2: benchmark(stringHexLog2),
74
+ oldLog2: benchmark(oldLog2),
75
+ log2: benchmark(log2),
76
+ },
3
77
  mask: () => {
4
78
  const result = mask(3n); // 7n
5
79
  if (result !== 7n) {
@@ -1,20 +1,21 @@
1
- import * as _ from '../types/module.f.ts';
2
- import * as List from '../../list/module.f.ts';
3
- import * as cmp from '../../function/compare/module.f.ts';
4
- type FirstLeaf1<T> = readonly [cmp.Index3, _.Leaf1<T>];
5
- type FirstBranch3<T> = readonly [1, _.Branch3<T>];
6
- type FirstLeaf2<T> = readonly [cmp.Index5, _.Leaf2<T>];
7
- type FirstBranch5<T> = readonly [1 | 3, _.Branch5<T>];
1
+ import type { Leaf1, Leaf2, Branch3, Branch5, TNode } from '../types/module.f.ts';
2
+ import type * as List from '../../list/module.f.ts';
3
+ import { type Compare } from '../../function/compare/module.f.ts';
4
+ import type { Index3, Index5 } from "../../array/module.f.ts";
5
+ type FirstLeaf1<T> = readonly [Index3, Leaf1<T>];
6
+ type FirstBranch3<T> = readonly [1, Branch3<T>];
7
+ type FirstLeaf2<T> = readonly [Index5, Leaf2<T>];
8
+ type FirstBranch5<T> = readonly [1 | 3, Branch5<T>];
8
9
  type First<T> = FirstLeaf1<T> | FirstBranch3<T> | FirstLeaf2<T> | FirstBranch5<T>;
9
- type PathItem3<T> = readonly [0 | 2, _.Branch3<T>];
10
- type PathItem5<T> = readonly [0 | 2 | 4, _.Branch5<T>];
10
+ type PathItem3<T> = readonly [0 | 2, Branch3<T>];
11
+ type PathItem5<T> = readonly [0 | 2 | 4, Branch5<T>];
11
12
  export type PathItem<T> = PathItem3<T> | PathItem5<T>;
12
13
  export type Path<T> = List.List<PathItem<T>>;
13
14
  export type Result<T> = {
14
15
  readonly first: First<T>;
15
16
  readonly tail: Path<T>;
16
17
  };
17
- export declare const find: <T>(c: cmp.Compare<T>) => (node: _.TNode<T>) => Result<T>;
18
+ export declare const find: <T>(c: Compare<T>) => (node: TNode<T>) => Result<T>;
18
19
  export declare const isFound: <T>([i]: First<T>) => boolean;
19
20
  export declare const value: <T>([i, r]: First<T>) => T | null;
20
21
  export {};
@@ -1,8 +1,4 @@
1
- import * as _ from "../types/module.f.js";
2
- import * as List from "../../list/module.f.js";
3
- import * as cmp from "../../function/compare/module.f.js";
4
- const { index3, index5 } = cmp;
5
- import * as Array from "../../array/module.f.js";
1
+ import { index3, index5 } from "../../function/compare/module.f.js";
6
2
  const child = (item) => item[1][item[0]];
7
3
  export const find = (c) => {
8
4
  const i3 = index3(c);
@@ -2,8 +2,7 @@ import * as _ from "./module.f.js";
2
2
  import * as list from "../../list/module.f.js";
3
3
  import * as json from "../../../json/module.f.js";
4
4
  import { sort } from "../../object/module.f.js";
5
- import * as string from "../../string/module.f.js";
6
- const { cmp } = string;
5
+ import { cmp } from "../../string/module.f.js";
7
6
  import * as s from "../set/module.f.js";
8
7
  const jsonStr = json.stringify(sort);
9
8
  const set = node => value => s.set(cmp(value))(() => value)(node);
@@ -1,4 +1,4 @@
1
1
  import { type List } from '../list/module.f.ts';
2
- import type * as _ from './types/module.f.ts';
2
+ import type { Tree } from './types/module.f.ts';
3
3
  export declare const empty: null;
4
- export declare const values: <T>(tree: _.Tree<T>) => List<T>;
4
+ export declare const values: <T>(tree: Tree<T>) => List<T>;
@@ -1,4 +1,4 @@
1
- import * as _ from '../types/module.f.ts';
2
- import * as Cmp from '../../function/compare/module.f.ts';
1
+ import type * as _ from '../types/module.f.ts';
2
+ import type * as Cmp from '../../function/compare/module.f.ts';
3
3
  export declare const nodeRemove: <T>(c: Cmp.Compare<T>) => (node: _.TNode<T>) => _.Tree<T>;
4
4
  export declare const remove: <T>(c: Cmp.Compare<T>) => (tree: _.Tree<T>) => _.Tree<T>;
@@ -1,9 +1,6 @@
1
- import * as _ from "../types/module.f.js";
2
- import * as Cmp from "../../function/compare/module.f.js";
3
1
  import * as find from "../find/module.f.js";
4
2
  import * as list from "../../list/module.f.js";
5
3
  const { fold, concat, next } = list;
6
- import * as Array from "../../array/module.f.js";
7
4
  import * as n from "../../nullable/module.f.js";
8
5
  const { map } = n;
9
6
  const path = tail => n => {
@@ -1,10 +1,8 @@
1
1
  import * as _ from "./module.f.js";
2
2
  import * as s from "../set/module.f.js";
3
- import * as str from "../../string/module.f.js";
4
- const { cmp } = str;
3
+ import { cmp } from "../../string/module.f.js";
5
4
  import * as json from "../../../json/module.f.js";
6
- import * as o from "../../object/module.f.js";
7
- const { sort } = o;
5
+ import { sort } from "../../object/module.f.js";
8
6
  const set = (node) => (value) => s.set(cmp(value))(() => value)(node);
9
7
  const remove = (node) => (value) => _.nodeRemove(cmp(value))(node);
10
8
  const jsonStr = json.stringify(sort);
@@ -1,3 +1,3 @@
1
- import * as _ from '../types/module.f.ts';
2
- import * as Cmp from '../../function/compare/module.f.ts';
1
+ import type * as _ from '../types/module.f.ts';
2
+ import type * as Cmp from '../../function/compare/module.f.ts';
3
3
  export declare const set: <T>(c: Cmp.Compare<T>) => (f: (value: T | null) => T) => (tree: _.Tree<T>) => _.TNode<T>;
@@ -1,9 +1,5 @@
1
- import * as _ from "../types/module.f.js";
2
- import * as btreeFind from "../find/module.f.js";
3
- const { find } = btreeFind;
4
- import * as Cmp from "../../function/compare/module.f.js";
5
- import * as list from "../../list/module.f.js";
6
- const { fold } = list;
1
+ import { find } from "../find/module.f.js";
2
+ import { fold } from "../../list/module.f.js";
7
3
  const b57 = b => b.length === 5 ? [b] : [[b[0], b[1], b[2]], b[3], [b[4], b[5], b[6]]];
8
4
  const reduceOp = ([i, x]) => a => {
9
5
  switch (i) {
@@ -1,15 +1,12 @@
1
- import * as _ from "./module.f.js";
2
- const { values } = _;
1
+ import { values } from "./module.f.js";
3
2
  import * as json from "../../json/module.f.js";
4
- import * as o from "../object/module.f.js";
5
- const { sort } = o;
6
- import * as str from "../string/module.f.js";
7
- const { cmp } = str;
8
- import * as list from "../list/module.f.js";
3
+ import { sort } from "../object/module.f.js";
4
+ import { cmp } from "../string/module.f.js";
5
+ import { next, toArray } from "../list/module.f.js";
9
6
  import * as s from "./set/module.f.js";
10
7
  import * as f from "./find/module.f.js";
11
8
  const jsonStr = json.stringify(sort);
12
- const stringify = sequence => jsonStr(list.toArray(sequence));
9
+ const stringify = sequence => jsonStr(toArray(sequence));
13
10
  const set = node => value => s.set(cmp(value))(() => value)(node);
14
11
  const valueTest1 = () => {
15
12
  let _map = ['a'];
@@ -18,7 +15,7 @@ const valueTest1 = () => {
18
15
  _map = set(_map)('d');
19
16
  _map = set(_map)('e');
20
17
  _map = set(_map)('f');
21
- let result = stringify(values(_map));
18
+ const result = stringify(values(_map));
22
19
  if (result !== '["a","b","c","d","e","f"]') {
23
20
  throw result;
24
21
  }
@@ -27,7 +24,7 @@ const valuesTest2 = () => {
27
24
  let _map = ['1'];
28
25
  for (let i = 2; i <= 10; i++)
29
26
  _map = set(_map)((i * i).toString());
30
- let result = stringify(values(_map));
27
+ const result = stringify(values(_map));
31
28
  if (result !== '["1","100","16","25","36","4","49","64","81","9"]') {
32
29
  throw result;
33
30
  }
@@ -59,9 +56,9 @@ const test = () => {
59
56
  _map = set(_map)('f');
60
57
  //
61
58
  {
62
- let _item = list.next(values(_map));
59
+ let _item = next(values(_map));
63
60
  while (_item !== null) {
64
- _item = list.next(_item.tail);
61
+ _item = next(_item.tail);
65
62
  }
66
63
  }
67
64
  };
@@ -1,6 +1,4 @@
1
- export type Array1<T> = readonly [T];
2
- export type Array2<T> = readonly [T, T];
3
- export type Array3<T> = readonly [T, T, T];
1
+ import type { Array1, Array2 } from '../../array/module.f.ts';
4
2
  export type Leaf1<T> = Array1<T>;
5
3
  export type Leaf2<T> = Array2<T>;
6
4
  export type Branch3<T> = readonly [TNode<T>, T, TNode<T>];
@@ -1,5 +1,5 @@
1
- import type * as RangeMap from '../range_map/module.f.ts';
2
- import type * as SortedSet from '../sorted_set/module.f.ts';
1
+ import type { RangeMap } from '../range_map/module.f.ts';
2
+ import type { SortedSet } from '../sorted_set/module.f.ts';
3
3
  export type ByteSet = bigint;
4
4
  type Byte = number;
5
5
  export declare const has: (n: Byte) => (s: ByteSet) => boolean;
@@ -12,5 +12,5 @@ export declare const complement: (n: ByteSet) => ByteSet;
12
12
  export declare const set: (_: number) => (b: ByteSet) => ByteSet;
13
13
  export declare const setRange: (_: readonly [number, number]) => (b: ByteSet) => ByteSet;
14
14
  export declare const unset: (n: Byte) => (s: ByteSet) => ByteSet;
15
- export declare const toRangeMap: (n: ByteSet) => (s: string) => RangeMap.RangeMap<SortedSet.SortedSet<string>>;
15
+ export declare const toRangeMap: (n: ByteSet) => (s: string) => RangeMap<SortedSet<string>>;
16
16
  export {};
@@ -1,6 +1,5 @@
1
1
  import { compose } from "../function/module.f.js";
2
- import * as list from "../list/module.f.js";
3
- const { reverse, countdown, flat, map } = list;
2
+ import { reverse, countdown, flat, map } from "../list/module.f.js";
4
3
  export const has = n => s => ((s >> BigInt(n)) & 1n) === 1n;
5
4
  // create a set
6
5
  export const empty = 0n;
@@ -1,9 +1,7 @@
1
1
  import * as _ from "./module.f.js";
2
- import * as list from "../list/module.f.js";
3
- const { every, countdown, map, toArray } = list;
2
+ import { every, countdown, map, toArray } from "../list/module.f.js";
4
3
  import * as json from "../../json/module.f.js";
5
- import * as o from "../object/module.f.js";
6
- const { sort } = o;
4
+ import { sort } from "../object/module.f.js";
7
5
  const stringify = json.stringify(sort);
8
6
  export default {
9
7
  has: [
@@ -1,10 +1,6 @@
1
- import type * as Array from '../../array/module.f.ts';
2
- export type Index3 = Array.Index3;
3
- export type Index5 = Array.Index5;
4
- type Array2<T> = Array.Array2<T>;
1
+ import type { Index3, Index5, Array2 } from '../../array/module.f.ts';
5
2
  export type Sign = -1 | 0 | 1;
6
3
  export type Compare<T> = (_: T) => Sign;
7
4
  export declare const index3: <T>(cmp: Compare<T>) => (value: T) => Index3;
8
5
  export declare const index5: <T>(cmp: Compare<T>) => (v2: Array2<T>) => Index5;
9
6
  export declare const unsafeCmp: <T>(a: T) => (b: T) => Sign;
10
- export {};
@@ -1,12 +1,10 @@
1
- import type * as BtreeTypes from '../btree/types/module.f.ts';
2
- import type * as Compare from '../function/compare/module.f.ts';
1
+ import type { Tree } from '../btree/types/module.f.ts';
3
2
  import { type List } from '../list/module.f.ts';
4
- import type * as Operator from '../function/operator/module.f.ts';
5
- export type Sign = Compare.Sign;
3
+ import type { Reduce } from '../function/operator/module.f.ts';
6
4
  export type Entry<T> = readonly [string, T];
7
- export type Map<T> = BtreeTypes.Tree<Entry<T>>;
5
+ export type Map<T> = Tree<Entry<T>>;
8
6
  export declare const at: (name: string) => <T>(map: Map<T>) => T | null;
9
- export declare const setReduce: <T>(reduce: Operator.Reduce<T>) => (name: string) => (value: T) => (map: Map<T>) => Map<T>;
7
+ export declare const setReduce: <T>(reduce: Reduce<T>) => (name: string) => (value: T) => (map: Map<T>) => Map<T>;
10
8
  export declare const setReplace: (name: string) => <T>(value: T) => (map: Map<T>) => Map<T>;
11
9
  export declare const entries: <T>(map: Map<T>) => List<Entry<T>>;
12
10
  export declare const fromEntries: <T>(entries: List<Entry<T>>) => Map<T>;
@@ -1,5 +1,5 @@
1
1
  import { at, setReplace, setReduce, empty, entries, remove } from "./module.f.js";
2
- import * as seq from "../list/module.f.js";
2
+ import { toArray } from "../list/module.f.js";
3
3
  export default {
4
4
  main: [
5
5
  () => {
@@ -90,7 +90,7 @@ export default {
90
90
  if (at('a')(m) !== null) {
91
91
  throw 'error';
92
92
  }
93
- const e = seq.toArray(entries(m));
93
+ const e = toArray(entries(m));
94
94
  if (e.length !== 2) {
95
95
  throw 'error';
96
96
  }
@@ -1,87 +1,87 @@
1
1
  import { every, map, countdown } from "../list/module.f.js";
2
- import * as _ from "./module.f.js";
2
+ import { empty, has, set, setRange, unset, universe, complement } from "./module.f.js";
3
3
  export default {
4
4
  has: () => {
5
- if (_.has(0)(_.empty)) {
6
- throw _.empty;
5
+ if (has(0)(empty)) {
6
+ throw empty;
7
7
  }
8
- if (_.has(1)(_.empty)) {
9
- throw _.empty;
8
+ if (has(1)(empty)) {
9
+ throw empty;
10
10
  }
11
- if (_.has(15)(_.empty)) {
12
- throw _.empty;
11
+ if (has(15)(empty)) {
12
+ throw empty;
13
13
  }
14
14
  },
15
15
  set: [
16
16
  () => {
17
- const s = _.set(0)(_.empty);
17
+ const s = set(0)(empty);
18
18
  if (s !== 1) {
19
19
  throw s;
20
20
  }
21
- if (!_.has(0)(s)) {
21
+ if (!has(0)(s)) {
22
22
  throw s;
23
23
  }
24
- if (_.has(1)(s)) {
24
+ if (has(1)(s)) {
25
25
  throw s;
26
26
  }
27
- if (_.has(15)(s)) {
27
+ if (has(15)(s)) {
28
28
  throw s;
29
29
  }
30
30
  },
31
31
  () => {
32
- const s = _.set(15)(_.empty);
32
+ const s = set(15)(empty);
33
33
  if (s !== 0x8000) {
34
34
  throw s;
35
35
  }
36
- if (_.has(0)(s)) {
36
+ if (has(0)(s)) {
37
37
  throw s;
38
38
  }
39
- if (_.has(1)(s)) {
39
+ if (has(1)(s)) {
40
40
  throw s;
41
41
  }
42
- if (!_.has(15)(s)) {
42
+ if (!has(15)(s)) {
43
43
  throw s;
44
44
  }
45
45
  }
46
46
  ],
47
47
  unset: () => [
48
48
  () => {
49
- const a = _.set(0)(_.empty);
50
- const result = _.unset(0)(a);
49
+ const a = set(0)(empty);
50
+ const result = unset(0)(a);
51
51
  if (result !== 0) {
52
52
  throw result;
53
53
  }
54
54
  },
55
55
  () => {
56
- const a = _.set(15)(_.empty);
57
- const result = _.unset(15)(a);
56
+ const a = set(15)(empty);
57
+ const result = unset(15)(a);
58
58
  if (result !== 0) {
59
59
  throw result;
60
60
  }
61
61
  }
62
62
  ],
63
63
  setRange: () => {
64
- const result = _.setRange([2, 5])(_.empty);
64
+ const result = setRange([2, 5])(empty);
65
65
  if (result !== 60) {
66
66
  throw result;
67
67
  }
68
68
  },
69
69
  universe: () => {
70
- const x = every(map((v) => _.has(v)(_.universe))(countdown(16)));
70
+ const x = every(map((v) => has(v)(universe))(countdown(16)));
71
71
  if (!x) {
72
72
  throw x;
73
73
  }
74
74
  },
75
75
  compliment: {
76
76
  empty: () => {
77
- const r = _.complement(_.empty);
78
- if (r !== _.universe) {
77
+ const r = complement(empty);
78
+ if (r !== universe) {
79
79
  throw r;
80
80
  }
81
81
  },
82
82
  universe: () => {
83
- const r = _.complement(_.universe);
84
- if (r !== _.empty) {
83
+ const r = complement(universe);
84
+ if (r !== empty) {
85
85
  throw r;
86
86
  }
87
87
  },
@@ -1,6 +1,6 @@
1
- import * as _ from "./module.f.js";
1
+ import { map } from "./module.f.js";
2
2
  export default () => {
3
- const optionSq = _.map((v) => v * v);
3
+ const optionSq = map((v) => v * v);
4
4
  const sq3 = optionSq(3);
5
5
  if (sq3 !== 9) {
6
6
  throw sq3;
@@ -1,6 +1,6 @@
1
1
  import { type List } from '../list/module.f.ts';
2
- import * as compare from '../function/compare/module.f.ts';
2
+ import { type Sign } from '../function/compare/module.f.ts';
3
3
  export declare const sum: (input: List<number>) => number;
4
4
  export declare const min: (input: List<number>) => number | null;
5
5
  export declare const max: (input: List<number>) => number | null;
6
- export declare const cmp: (a: number) => (b: number) => compare.Sign;
6
+ export declare const cmp: (a: number) => (b: number) => Sign;
@@ -1,7 +1,6 @@
1
1
  import { reduce } from "../list/module.f.js";
2
2
  import { addition, min as minOp, max as maxOp } from "../function/operator/module.f.js";
3
- import * as compare from "../function/compare/module.f.js";
4
- const { unsafeCmp } = compare;
3
+ import { unsafeCmp } from "../function/compare/module.f.js";
5
4
  export const sum = reduce(addition)(0);
6
5
  export const min = reduce(minOp)(null);
7
6
  export const max = reduce(maxOp)(null);
@@ -1,15 +1,15 @@
1
- import * as _ from "./module.f.js";
1
+ import { at } from "./module.f.js";
2
2
  export default {
3
3
  ctor: () => {
4
4
  const a = {};
5
- const value = _.at('constructor')(a);
5
+ const value = at('constructor')(a);
6
6
  if (value !== null) {
7
7
  throw value;
8
8
  }
9
9
  },
10
10
  property: () => {
11
11
  const a = { constructor: 42 };
12
- const value = _.at('constructor')(a);
12
+ const value = at('constructor')(a);
13
13
  if (value !== 42) {
14
14
  throw value;
15
15
  }
@@ -1,18 +1,18 @@
1
- import * as _ from "./module.f.js";
1
+ import { contains } from "./module.f.js";
2
2
  export default () => {
3
- if (!_.contains([0, 5])(1)) {
3
+ if (!contains([0, 5])(1)) {
4
4
  throw 1;
5
5
  }
6
- if (!_.contains([0, 5])(0)) {
6
+ if (!contains([0, 5])(0)) {
7
7
  throw 0;
8
8
  }
9
- if (!_.contains([0, 5])(5)) {
9
+ if (!contains([0, 5])(5)) {
10
10
  throw 5;
11
11
  }
12
- if (_.contains([0, 5])(-1)) {
12
+ if (contains([0, 5])(-1)) {
13
13
  throw -1;
14
14
  }
15
- if (_.contains([0, 5])(6)) {
15
+ if (contains([0, 5])(6)) {
16
16
  throw 6;
17
17
  }
18
18
  };
@@ -1,14 +1,14 @@
1
1
  import { type SortedList } from '../sorted_list/module.f.ts';
2
- import type * as O from '../function/operator/module.f.ts';
3
- import type * as Range from '../range/module.f.ts';
2
+ import type { Reduce, Equal } from '../function/operator/module.f.ts';
3
+ import type { Range } from '../range/module.f.ts';
4
4
  export type Entry<T> = [T, number];
5
5
  export type RangeMap<T> = SortedList<Entry<T>>;
6
6
  export type RangeMapArray<T> = readonly Entry<T>[];
7
7
  export type Operators<T> = {
8
- readonly union: O.Reduce<T>;
9
- readonly equal: O.Equal<T>;
8
+ readonly union: Reduce<T>;
9
+ readonly equal: Equal<T>;
10
10
  };
11
- export type RangeMerge<T> = O.Reduce<RangeMap<T>>;
11
+ export type RangeMerge<T> = Reduce<RangeMap<T>>;
12
12
  export declare const merge: <T>(op: Operators<T>) => RangeMerge<T>;
13
13
  export declare const get: <T>(def: T) => (value: number) => (rm: RangeMapArray<T>) => T;
14
- export declare const fromRange: <T>(def: T) => (r: Range.Range) => (value: T) => RangeMapArray<T>;
14
+ export declare const fromRange: <T>(def: T) => (r: Range) => (value: T) => RangeMapArray<T>;
@@ -1,9 +1,7 @@
1
1
  import * as _ from "./module.f.js";
2
- import * as compare from "../function/compare/module.f.js";
3
- const { unsafeCmp } = compare;
2
+ import { unsafeCmp } from "../function/compare/module.f.js";
4
3
  import * as json from "../../json/module.f.js";
5
- import * as object from "../object/module.f.js";
6
- const { sort } = object;
4
+ import { sort } from "../object/module.f.js";
7
5
  import * as sortedSet from "../sorted_set/module.f.js";
8
6
  import * as list from "../list/module.f.js";
9
7
  import * as operator from "../function/operator/module.f.js";
@@ -1,10 +1,10 @@
1
- import type * as compare from '../function/compare/module.f.ts';
1
+ import type { Sign } from '../function/compare/module.f.ts';
2
2
  import { type List } from '../list/module.f.ts';
3
- import type * as option from '../nullable/module.f.ts';
3
+ import type { Nullable } from '../nullable/module.f.ts';
4
4
  export type SortedList<T> = List<T>;
5
5
  type SortedArray<T> = readonly T[];
6
- type Cmp<T> = (a: T) => (b: T) => compare.Sign;
7
- export type ReduceOp<T, S> = (state: S) => (a: T) => (b: T) => readonly [option.Nullable<T>, compare.Sign, S];
6
+ type Cmp<T> = (a: T) => (b: T) => Sign;
7
+ export type ReduceOp<T, S> = (state: S) => (a: T) => (b: T) => readonly [Nullable<T>, Sign, S];
8
8
  export type TailReduce<T, S> = (state: S) => (tail: List<T>) => List<T>;
9
9
  type MergeReduce<T, S> = {
10
10
  readonly reduceOp: ReduceOp<T, S>;
@@ -1,4 +1,4 @@
1
- import * as _ from "./module.f.js";
1
+ import { find, merge } from "./module.f.js";
2
2
  import { unsafeCmp } from "../function/compare/module.f.js";
3
3
  import * as json from "../../json/module.f.js";
4
4
  import { sort } from "../object/module.f.js";
@@ -9,13 +9,13 @@ const reverseCmp = flip(unsafeCmp);
9
9
  export default {
10
10
  sortedMergre: [
11
11
  () => {
12
- const result = stringify(toArray(_.merge(unsafeCmp)([2, 3, 4])([1, 3, 5])));
12
+ const result = stringify(toArray(merge(unsafeCmp)([2, 3, 4])([1, 3, 5])));
13
13
  if (result !== '[1,2,3,4,5]') {
14
14
  throw result;
15
15
  }
16
16
  },
17
17
  () => {
18
- const result = stringify(toArray(_.merge(unsafeCmp)([1, 2, 3])([])));
18
+ const result = stringify(toArray(merge(unsafeCmp)([1, 2, 3])([])));
19
19
  if (result !== '[1,2,3]') {
20
20
  throw result;
21
21
  }
@@ -23,7 +23,7 @@ export default {
23
23
  () => {
24
24
  const n = 10_000;
25
25
  const list = countdown(n);
26
- const result = _.merge(reverseCmp)(list)(list);
26
+ const result = merge(reverseCmp)(list)(list);
27
27
  const len = length(result);
28
28
  if (len != n) {
29
29
  throw result;
@@ -32,25 +32,25 @@ export default {
32
32
  ],
33
33
  find: [
34
34
  () => {
35
- const result = _.find(unsafeCmp)(0)([0, 10, 20, 30, 40, 50, 60, 70, 80, 90]);
35
+ const result = find(unsafeCmp)(0)([0, 10, 20, 30, 40, 50, 60, 70, 80, 90]);
36
36
  if (result !== 0) {
37
37
  throw result;
38
38
  }
39
39
  },
40
40
  () => {
41
- const result = _.find(unsafeCmp)(3)([0, 10, 20, 30, 40, 50, 60, 70, 80, 90]);
41
+ const result = find(unsafeCmp)(3)([0, 10, 20, 30, 40, 50, 60, 70, 80, 90]);
42
42
  if (result !== null) {
43
43
  throw result;
44
44
  }
45
45
  },
46
46
  () => {
47
- const result = _.find(unsafeCmp)(77)([0, 10, 20, 30, 40, 50, 60, 70, 80, 90]);
47
+ const result = find(unsafeCmp)(77)([0, 10, 20, 30, 40, 50, 60, 70, 80, 90]);
48
48
  if (result !== null) {
49
49
  throw result;
50
50
  }
51
51
  },
52
52
  () => {
53
- const result = _.find(unsafeCmp)(80)([0, 10, 20, 30, 40, 50, 60, 70, 80, 90]);
53
+ const result = find(unsafeCmp)(80)([0, 10, 20, 30, 40, 50, 60, 70, 80, 90]);
54
54
  if (result !== 80) {
55
55
  throw result;
56
56
  }
@@ -1,6 +1,6 @@
1
- import type * as Compare from '../function/compare/module.f.ts';
1
+ import type { Sign } from '../function/compare/module.f.ts';
2
2
  export type SortedSet<T> = readonly T[];
3
- type Cmp<T> = (a: T) => (b: T) => Compare.Sign;
3
+ type Cmp<T> = (a: T) => (b: T) => Sign;
4
4
  export declare const union: <T>(cmp: Cmp<T>) => (a: SortedSet<T>) => (b: SortedSet<T>) => SortedSet<T>;
5
5
  export declare const intersect: <T>(cmp: Cmp<T>) => (a: SortedSet<T>) => (b: SortedSet<T>) => SortedSet<T>;
6
6
  export declare const has: <T>(cmp: Cmp<T>) => (value: T) => (set: SortedSet<T>) => boolean;
@@ -1,4 +1,4 @@
1
- import * as _ from "./module.f.js";
1
+ import { has, intersect, union } from "./module.f.js";
2
2
  import { unsafeCmp } from "../function/compare/module.f.js";
3
3
  import * as json from "../../json/module.f.js";
4
4
  import { sort } from "../object/module.f.js";
@@ -9,13 +9,13 @@ const reverseCmp = flip(unsafeCmp);
9
9
  export default {
10
10
  union: [
11
11
  () => {
12
- const result = stringify(toArray(_.union(unsafeCmp)([2, 3, 4])([1, 3, 5])));
12
+ const result = stringify(toArray(union(unsafeCmp)([2, 3, 4])([1, 3, 5])));
13
13
  if (result !== '[1,2,3,4,5]') {
14
14
  throw result;
15
15
  }
16
16
  },
17
17
  () => {
18
- const result = stringify(toArray(_.union(unsafeCmp)([1, 2, 3])([])));
18
+ const result = stringify(toArray(union(unsafeCmp)([1, 2, 3])([])));
19
19
  if (result !== '[1,2,3]') {
20
20
  throw result;
21
21
  }
@@ -23,7 +23,7 @@ export default {
23
23
  () => {
24
24
  const n = 10_000;
25
25
  const sortedSet = toArray(countdown(n));
26
- const result = _.union(reverseCmp)(sortedSet)(sortedSet);
26
+ const result = union(reverseCmp)(sortedSet)(sortedSet);
27
27
  const len = length(result);
28
28
  if (len != n) {
29
29
  throw result;
@@ -32,13 +32,13 @@ export default {
32
32
  ],
33
33
  intersect: [
34
34
  () => {
35
- const result = stringify(toArray(_.intersect(unsafeCmp)([2, 3, 4])([1, 3, 5])));
35
+ const result = stringify(toArray(intersect(unsafeCmp)([2, 3, 4])([1, 3, 5])));
36
36
  if (result !== '[3]') {
37
37
  throw result;
38
38
  }
39
39
  },
40
40
  () => {
41
- const result = stringify(toArray(_.intersect(unsafeCmp)([1, 2, 3])([])));
41
+ const result = stringify(toArray(intersect(unsafeCmp)([1, 2, 3])([])));
42
42
  if (result !== '[]') {
43
43
  throw result;
44
44
  }
@@ -46,25 +46,25 @@ export default {
46
46
  ],
47
47
  has: [
48
48
  () => {
49
- const result = _.has(unsafeCmp)(0)([0, 10, 20, 30, 40, 50, 60, 70, 80, 90]);
49
+ const result = has(unsafeCmp)(0)([0, 10, 20, 30, 40, 50, 60, 70, 80, 90]);
50
50
  if (!result) {
51
51
  throw result;
52
52
  }
53
53
  },
54
54
  () => {
55
- const result = _.has(unsafeCmp)(3)([0, 10, 20, 30, 40, 50, 60, 70, 80, 90]);
55
+ const result = has(unsafeCmp)(3)([0, 10, 20, 30, 40, 50, 60, 70, 80, 90]);
56
56
  if (result) {
57
57
  throw result;
58
58
  }
59
59
  },
60
60
  () => {
61
- const result = _.has(unsafeCmp)(77)([0, 10, 20, 30, 40, 50, 60, 70, 80, 90]);
61
+ const result = has(unsafeCmp)(77)([0, 10, 20, 30, 40, 50, 60, 70, 80, 90]);
62
62
  if (result) {
63
63
  throw result;
64
64
  }
65
65
  },
66
66
  () => {
67
- const result = _.has(unsafeCmp)(80)([0, 10, 20, 30, 40, 50, 60, 70, 80, 90]);
67
+ const result = has(unsafeCmp)(80)([0, 10, 20, 30, 40, 50, 60, 70, 80, 90]);
68
68
  if (!result) {
69
69
  throw result;
70
70
  }
@@ -1,6 +1,6 @@
1
1
  import { type List } from '../list/module.f.ts';
2
- import * as compare from '../function/compare/module.f.ts';
2
+ import { type Sign } from '../function/compare/module.f.ts';
3
3
  export declare const join: (_: string) => (input: List<string>) => string;
4
4
  export declare const concat: (input: List<string>) => string;
5
5
  export declare const repeat: (n: string) => (v: number) => string;
6
- export declare const cmp: (a: string) => (b: string) => compare.Sign;
6
+ export declare const cmp: (a: string) => (b: string) => Sign;
@@ -1,7 +1,6 @@
1
1
  import { reduce as listReduce, repeat as listRepeat } from "../list/module.f.js";
2
2
  import { compose } from "../function/module.f.js";
3
- import * as compare from "../function/compare/module.f.js";
4
- const { unsafeCmp } = compare;
3
+ import { unsafeCmp } from "../function/compare/module.f.js";
5
4
  import { join as joinOp, concat as concatOp } from "../function/operator/module.f.js";
6
5
  const reduce = o => listReduce(o)('');
7
6
  export const join = compose(joinOp)(reduce);
@@ -1,8 +1,8 @@
1
- import type * as BtreeTypes from '../btree/types/module.f.ts';
1
+ import type { Tree } from '../btree/types/module.f.ts';
2
2
  import { type List } from '../list/module.f.ts';
3
3
  export declare const values: (s: StringSet) => List<string>;
4
4
  export declare const empty: null;
5
- export type StringSet = BtreeTypes.Tree<string>;
5
+ export type StringSet = Tree<string>;
6
6
  export declare const contains: (value: string) => (set: StringSet) => boolean;
7
7
  export declare const set: (value: string) => (s: StringSet) => StringSet;
8
8
  export declare const fromValues: (input: List<string>) => StringSet;
@@ -1,63 +1,63 @@
1
- import * as _ from "./module.f.js";
1
+ import { contains, remove, set } from "./module.f.js";
2
2
  export default {
3
3
  contains: () => {
4
- const r = _.set('hello')(null);
5
- if (!_.contains('hello')(r)) {
4
+ const r = set('hello')(null);
5
+ if (!contains('hello')(r)) {
6
6
  throw r;
7
7
  }
8
- if (_.contains('hello1')(r)) {
8
+ if (contains('hello1')(r)) {
9
9
  throw r;
10
10
  }
11
11
  },
12
12
  remove: () => {
13
- let r = _.set('hello')(null);
14
- r = _.set('world')(r);
15
- r = _.set('HELLO')(r);
16
- r = _.set('WORLD!')(r);
17
- if (!_.contains('hello')(r)) {
13
+ let r = set('hello')(null);
14
+ r = set('world')(r);
15
+ r = set('HELLO')(r);
16
+ r = set('WORLD!')(r);
17
+ if (!contains('hello')(r)) {
18
18
  throw r;
19
19
  }
20
- if (_.contains('hello1')(r)) {
20
+ if (contains('hello1')(r)) {
21
21
  throw r;
22
22
  }
23
- if (!_.contains('HELLO')(r)) {
23
+ if (!contains('HELLO')(r)) {
24
24
  throw r;
25
25
  }
26
- if (_.contains('WORLD')(r)) {
26
+ if (contains('WORLD')(r)) {
27
27
  throw r;
28
28
  }
29
- if (!_.contains('world')(r)) {
29
+ if (!contains('world')(r)) {
30
30
  throw r;
31
31
  }
32
- if (_.contains('world!')(r)) {
32
+ if (contains('world!')(r)) {
33
33
  throw r;
34
34
  }
35
- if (!_.contains('WORLD!')(r)) {
35
+ if (!contains('WORLD!')(r)) {
36
36
  throw r;
37
37
  }
38
38
  //
39
- r = _.remove('hello')(r);
40
- if (_.contains('hello')(r)) {
39
+ r = remove('hello')(r);
40
+ if (contains('hello')(r)) {
41
41
  throw r;
42
42
  }
43
- if (!_.contains('world')(r)) {
43
+ if (!contains('world')(r)) {
44
44
  throw r;
45
45
  }
46
- r = _.remove('world')(r);
47
- if (_.contains('world')(r)) {
46
+ r = remove('world')(r);
47
+ if (contains('world')(r)) {
48
48
  throw r;
49
49
  }
50
- if (!_.contains('HELLO')(r)) {
50
+ if (!contains('HELLO')(r)) {
51
51
  throw r;
52
52
  }
53
- r = _.remove('HELLO')(r);
54
- if (_.contains('HELLO')(r)) {
53
+ r = remove('HELLO')(r);
54
+ if (contains('HELLO')(r)) {
55
55
  throw r;
56
56
  }
57
- if (!_.contains('WORLD!')(r)) {
57
+ if (!contains('WORLD!')(r)) {
58
58
  throw r;
59
59
  }
60
- r = _.remove('WORLD!')(r);
60
+ r = remove('WORLD!')(r);
61
61
  if (r !== null) {
62
62
  throw r;
63
63
  }