functionalscript 0.3.8 → 0.3.9
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.
- package/package.json +1 -1
- package/types/bigint/module.f.d.ts +19 -2
- package/types/bigint/module.f.js +23 -9
- package/types/bigint/test.f.d.ts +7 -0
- package/types/bigint/test.f.js +74 -0
- package/types/btree/find/module.f.d.ts +11 -10
- package/types/btree/find/module.f.js +1 -5
- package/types/btree/find/test.f.js +1 -2
- package/types/btree/module.f.d.ts +2 -2
- package/types/btree/remove/module.f.d.ts +2 -2
- package/types/btree/remove/module.f.js +0 -3
- package/types/btree/remove/test.f.js +2 -4
- package/types/btree/set/module.f.d.ts +2 -2
- package/types/btree/set/module.f.js +2 -6
- package/types/btree/test.f.js +9 -12
- package/types/btree/types/module.f.d.ts +1 -3
- package/types/byte_set/module.f.d.ts +3 -3
- package/types/byte_set/module.f.js +1 -2
- package/types/byte_set/test.f.js +2 -4
- package/types/function/compare/module.f.d.ts +1 -5
- package/types/map/module.f.d.ts +4 -6
- package/types/map/test.f.js +2 -2
- package/types/nibble_set/test.f.js +25 -25
- package/types/nullable/test.f.js +2 -2
- package/types/number/module.f.d.ts +2 -2
- package/types/number/module.f.js +1 -2
- package/types/object/test.f.js +3 -3
- package/types/range/test.f.js +6 -6
- package/types/range_map/module.f.d.ts +6 -6
- package/types/range_map/test.f.js +2 -4
- package/types/sorted_list/module.f.d.ts +4 -4
- package/types/sorted_list/test.f.js +8 -8
- package/types/sorted_set/module.f.d.ts +2 -2
- package/types/sorted_set/test.f.js +10 -10
- package/types/string/module.f.d.ts +2 -2
- package/types/string/module.f.js +1 -2
- package/types/string_set/module.f.d.ts +2 -2
- package/types/string_set/test.f.js +25 -25
package/package.json
CHANGED
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @module
|
|
3
|
+
*
|
|
4
|
+
* This module provides a collection of utility functions for working with `bigint` values.
|
|
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) =>
|
|
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).
|
package/types/bigint/module.f.js
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @module
|
|
3
|
+
*
|
|
4
|
+
* This module provides a collection of utility functions for working with `bigint` values.
|
|
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 =
|
|
34
|
-
let i =
|
|
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
|
|
47
|
-
while (i !==
|
|
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.
|
package/types/bigint/test.f.d.ts
CHANGED
package/types/bigint/test.f.js
CHANGED
|
@@ -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
|
|
2
|
-
import * as List from '../../list/module.f.ts';
|
|
3
|
-
import
|
|
4
|
-
type
|
|
5
|
-
type
|
|
6
|
-
type
|
|
7
|
-
type
|
|
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,
|
|
10
|
-
type PathItem5<T> = readonly [0 | 2 | 4,
|
|
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:
|
|
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
|
|
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
|
|
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
|
|
2
|
+
import type { Tree } from './types/module.f.ts';
|
|
3
3
|
export declare const empty: null;
|
|
4
|
-
export declare const values: <T>(tree:
|
|
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
|
|
4
|
-
const { cmp } = str;
|
|
3
|
+
import { cmp } from "../../string/module.f.js";
|
|
5
4
|
import * as json from "../../../json/module.f.js";
|
|
6
|
-
import
|
|
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
|
|
2
|
-
import
|
|
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) {
|
package/types/btree/test.f.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
const { values } = _;
|
|
1
|
+
import { values } from "./module.f.js";
|
|
3
2
|
import * as json from "../../json/module.f.js";
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
import
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
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 =
|
|
59
|
+
let _item = next(values(_map));
|
|
63
60
|
while (_item !== null) {
|
|
64
|
-
_item =
|
|
61
|
+
_item = next(_item.tail);
|
|
65
62
|
}
|
|
66
63
|
}
|
|
67
64
|
};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
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
|
|
2
|
-
import type
|
|
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
|
|
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
|
|
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;
|
package/types/byte_set/test.f.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import * as _ from "./module.f.js";
|
|
2
|
-
import
|
|
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
|
|
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
|
|
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 {};
|
package/types/map/module.f.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import type
|
|
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
|
|
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> =
|
|
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:
|
|
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>;
|
package/types/map/test.f.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { at, setReplace, setReduce, empty, entries, remove } from "./module.f.js";
|
|
2
|
-
import
|
|
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 =
|
|
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
|
|
2
|
+
import { empty, has, set, setRange, unset, universe, complement } from "./module.f.js";
|
|
3
3
|
export default {
|
|
4
4
|
has: () => {
|
|
5
|
-
if (
|
|
6
|
-
throw
|
|
5
|
+
if (has(0)(empty)) {
|
|
6
|
+
throw empty;
|
|
7
7
|
}
|
|
8
|
-
if (
|
|
9
|
-
throw
|
|
8
|
+
if (has(1)(empty)) {
|
|
9
|
+
throw empty;
|
|
10
10
|
}
|
|
11
|
-
if (
|
|
12
|
-
throw
|
|
11
|
+
if (has(15)(empty)) {
|
|
12
|
+
throw empty;
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
set: [
|
|
16
16
|
() => {
|
|
17
|
-
const s =
|
|
17
|
+
const s = set(0)(empty);
|
|
18
18
|
if (s !== 1) {
|
|
19
19
|
throw s;
|
|
20
20
|
}
|
|
21
|
-
if (!
|
|
21
|
+
if (!has(0)(s)) {
|
|
22
22
|
throw s;
|
|
23
23
|
}
|
|
24
|
-
if (
|
|
24
|
+
if (has(1)(s)) {
|
|
25
25
|
throw s;
|
|
26
26
|
}
|
|
27
|
-
if (
|
|
27
|
+
if (has(15)(s)) {
|
|
28
28
|
throw s;
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
() => {
|
|
32
|
-
const s =
|
|
32
|
+
const s = set(15)(empty);
|
|
33
33
|
if (s !== 0x8000) {
|
|
34
34
|
throw s;
|
|
35
35
|
}
|
|
36
|
-
if (
|
|
36
|
+
if (has(0)(s)) {
|
|
37
37
|
throw s;
|
|
38
38
|
}
|
|
39
|
-
if (
|
|
39
|
+
if (has(1)(s)) {
|
|
40
40
|
throw s;
|
|
41
41
|
}
|
|
42
|
-
if (!
|
|
42
|
+
if (!has(15)(s)) {
|
|
43
43
|
throw s;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
],
|
|
47
47
|
unset: () => [
|
|
48
48
|
() => {
|
|
49
|
-
const a =
|
|
50
|
-
const result =
|
|
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 =
|
|
57
|
-
const result =
|
|
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 =
|
|
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) =>
|
|
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 =
|
|
78
|
-
if (r !==
|
|
77
|
+
const r = complement(empty);
|
|
78
|
+
if (r !== universe) {
|
|
79
79
|
throw r;
|
|
80
80
|
}
|
|
81
81
|
},
|
|
82
82
|
universe: () => {
|
|
83
|
-
const r =
|
|
84
|
-
if (r !==
|
|
83
|
+
const r = complement(universe);
|
|
84
|
+
if (r !== empty) {
|
|
85
85
|
throw r;
|
|
86
86
|
}
|
|
87
87
|
},
|
package/types/nullable/test.f.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type List } from '../list/module.f.ts';
|
|
2
|
-
import
|
|
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) =>
|
|
6
|
+
export declare const cmp: (a: number) => (b: number) => Sign;
|
package/types/number/module.f.js
CHANGED
|
@@ -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
|
|
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);
|
package/types/object/test.f.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { at } from "./module.f.js";
|
|
2
2
|
export default {
|
|
3
3
|
ctor: () => {
|
|
4
4
|
const a = {};
|
|
5
|
-
const value =
|
|
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 =
|
|
12
|
+
const value = at('constructor')(a);
|
|
13
13
|
if (value !== 42) {
|
|
14
14
|
throw value;
|
|
15
15
|
}
|
package/types/range/test.f.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { contains } from "./module.f.js";
|
|
2
2
|
export default () => {
|
|
3
|
-
if (!
|
|
3
|
+
if (!contains([0, 5])(1)) {
|
|
4
4
|
throw 1;
|
|
5
5
|
}
|
|
6
|
-
if (!
|
|
6
|
+
if (!contains([0, 5])(0)) {
|
|
7
7
|
throw 0;
|
|
8
8
|
}
|
|
9
|
-
if (!
|
|
9
|
+
if (!contains([0, 5])(5)) {
|
|
10
10
|
throw 5;
|
|
11
11
|
}
|
|
12
|
-
if (
|
|
12
|
+
if (contains([0, 5])(-1)) {
|
|
13
13
|
throw -1;
|
|
14
14
|
}
|
|
15
|
-
if (
|
|
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
|
|
3
|
-
import type
|
|
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:
|
|
9
|
-
readonly equal:
|
|
8
|
+
readonly union: Reduce<T>;
|
|
9
|
+
readonly equal: Equal<T>;
|
|
10
10
|
};
|
|
11
|
-
export type RangeMerge<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
|
|
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
|
|
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
|
|
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
|
|
1
|
+
import type { Sign } from '../function/compare/module.f.ts';
|
|
2
2
|
import { type List } from '../list/module.f.ts';
|
|
3
|
-
import type
|
|
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) =>
|
|
7
|
-
export type ReduceOp<T, S> = (state: S) => (a: T) => (b: T) => readonly [
|
|
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
|
|
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(
|
|
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(
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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
|
|
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) =>
|
|
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
|
|
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(
|
|
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(
|
|
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 =
|
|
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(
|
|
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(
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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
|
|
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) =>
|
|
6
|
+
export declare const cmp: (a: string) => (b: string) => Sign;
|
package/types/string/module.f.js
CHANGED
|
@@ -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
|
|
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
|
|
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 =
|
|
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
|
|
1
|
+
import { contains, remove, set } from "./module.f.js";
|
|
2
2
|
export default {
|
|
3
3
|
contains: () => {
|
|
4
|
-
const r =
|
|
5
|
-
if (!
|
|
4
|
+
const r = set('hello')(null);
|
|
5
|
+
if (!contains('hello')(r)) {
|
|
6
6
|
throw r;
|
|
7
7
|
}
|
|
8
|
-
if (
|
|
8
|
+
if (contains('hello1')(r)) {
|
|
9
9
|
throw r;
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
12
|
remove: () => {
|
|
13
|
-
let r =
|
|
14
|
-
r =
|
|
15
|
-
r =
|
|
16
|
-
r =
|
|
17
|
-
if (!
|
|
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 (
|
|
20
|
+
if (contains('hello1')(r)) {
|
|
21
21
|
throw r;
|
|
22
22
|
}
|
|
23
|
-
if (!
|
|
23
|
+
if (!contains('HELLO')(r)) {
|
|
24
24
|
throw r;
|
|
25
25
|
}
|
|
26
|
-
if (
|
|
26
|
+
if (contains('WORLD')(r)) {
|
|
27
27
|
throw r;
|
|
28
28
|
}
|
|
29
|
-
if (!
|
|
29
|
+
if (!contains('world')(r)) {
|
|
30
30
|
throw r;
|
|
31
31
|
}
|
|
32
|
-
if (
|
|
32
|
+
if (contains('world!')(r)) {
|
|
33
33
|
throw r;
|
|
34
34
|
}
|
|
35
|
-
if (!
|
|
35
|
+
if (!contains('WORLD!')(r)) {
|
|
36
36
|
throw r;
|
|
37
37
|
}
|
|
38
38
|
//
|
|
39
|
-
r =
|
|
40
|
-
if (
|
|
39
|
+
r = remove('hello')(r);
|
|
40
|
+
if (contains('hello')(r)) {
|
|
41
41
|
throw r;
|
|
42
42
|
}
|
|
43
|
-
if (!
|
|
43
|
+
if (!contains('world')(r)) {
|
|
44
44
|
throw r;
|
|
45
45
|
}
|
|
46
|
-
r =
|
|
47
|
-
if (
|
|
46
|
+
r = remove('world')(r);
|
|
47
|
+
if (contains('world')(r)) {
|
|
48
48
|
throw r;
|
|
49
49
|
}
|
|
50
|
-
if (!
|
|
50
|
+
if (!contains('HELLO')(r)) {
|
|
51
51
|
throw r;
|
|
52
52
|
}
|
|
53
|
-
r =
|
|
54
|
-
if (
|
|
53
|
+
r = remove('HELLO')(r);
|
|
54
|
+
if (contains('HELLO')(r)) {
|
|
55
55
|
throw r;
|
|
56
56
|
}
|
|
57
|
-
if (!
|
|
57
|
+
if (!contains('WORLD!')(r)) {
|
|
58
58
|
throw r;
|
|
59
59
|
}
|
|
60
|
-
r =
|
|
60
|
+
r = remove('WORLD!')(r);
|
|
61
61
|
if (r !== null) {
|
|
62
62
|
throw r;
|
|
63
63
|
}
|