functionalscript 0.0.433 → 0.0.435
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/Cargo.lock +1 -1
- package/Cargo.toml +1 -1
- package/com/{cpp/test → test/cpp}/build.cjs +1 -1
- package/com/{cpp/test → test/cpp}/main.cpp +0 -0
- package/com/{cs/test → test/cs}/Program.cs +0 -0
- package/com/{cs/test → test/cs}/build.cjs +1 -1
- package/com/{cs/test/test.csproj → test/cs/testcs.csproj} +0 -0
- package/fsm/module.f.cjs +1 -1
- package/fsm/test.f.cjs +14 -0
- package/package.json +1 -1
- package/types/sorted_list/module.f.cjs +38 -0
- package/types/sorted_list/test.f.cjs +33 -0
package/Cargo.lock
CHANGED
package/Cargo.toml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const fs = require('node:fs')
|
|
2
2
|
const cp = require('node:child_process')
|
|
3
3
|
const os = require('node:os');
|
|
4
|
-
const cpp = require('
|
|
4
|
+
const cpp = require('../../cpp/test.f.cjs').result
|
|
5
5
|
const { string: { join }, list: { flat } } = require('../../../types/module.f.cjs')
|
|
6
6
|
|
|
7
7
|
fs.writeFileSync('_result.hpp', cpp)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/fsm/module.f.cjs
CHANGED
|
@@ -15,7 +15,7 @@ const byteSet = require('../types/byte_set/module.f.cjs')
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
/** @type {(faId: string) => string} */
|
|
18
|
-
const escape = faId =>
|
|
18
|
+
const escape = faId => faId.replaceAll('\\', '\\\\').replaceAll('|', '\\|')
|
|
19
19
|
|
|
20
20
|
/** @type {(grammar: Grammar) => Dfa} */
|
|
21
21
|
const dfa = grammar => todo()
|
package/fsm/test.f.cjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const _ = require('./module.f.cjs')
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
escape: [
|
|
5
|
+
() => {
|
|
6
|
+
const result = _.escape('abc')
|
|
7
|
+
if (result !== 'abc') { throw result }
|
|
8
|
+
},
|
|
9
|
+
() => {
|
|
10
|
+
const result = _.escape('\\a|b|c\\')
|
|
11
|
+
if (result !== '\\\\a\\|b\\|c\\\\') { throw result }
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const compare = require("../function/compare/module.f.cjs")
|
|
2
|
+
const list = require("../list/module.f.cjs")
|
|
3
|
+
const { next, toArray } = list
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @template T
|
|
7
|
+
* @typedef {list.List<T>} SortedList
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @template T
|
|
12
|
+
* @typedef {(a: T) => (b: T) => compare.Sign} Cmp
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** @typedef {number} Byte */
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @template T
|
|
19
|
+
* @typedef {SortedList<[Byte, readonly string[]]>} RangeMap
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/** @type {<T>(cmp: Cmp<T>) => (a: SortedList<T>) => (b: SortedList<T>) => SortedList<T>} */
|
|
23
|
+
const merge = cmp => a => b => () => {
|
|
24
|
+
const aResult = next(a)
|
|
25
|
+
if (aResult === undefined) { return b }
|
|
26
|
+
const bResult = next(b)
|
|
27
|
+
if (bResult === undefined) { return a }
|
|
28
|
+
switch (cmp(aResult.first)(bResult.first)) {
|
|
29
|
+
case -1: return { first: aResult.first, tail: merge(cmp)(aResult.tail)(b) }
|
|
30
|
+
case 0: return { first: aResult.first, tail: merge(cmp)(aResult.tail)(bResult.tail) }
|
|
31
|
+
case 1: return { first: bResult.first, tail: merge(cmp)(a)(bResult.tail) }
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports = {
|
|
36
|
+
/** @readonly */
|
|
37
|
+
merge
|
|
38
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const _ = require('./module.f.cjs')
|
|
2
|
+
const { unsafeCmp } = require('../function/compare/module.f.cjs')
|
|
3
|
+
const json = require('../../json/module.f.cjs')
|
|
4
|
+
const { sort } = require('../../types/object/module.f.cjs')
|
|
5
|
+
const { toArray, countdown, length } = require('../list/module.f.cjs')
|
|
6
|
+
const map = require('../map/module.f.cjs')
|
|
7
|
+
const { flip } = require('../function/module.f.cjs')
|
|
8
|
+
|
|
9
|
+
/** @type {(a: readonly json.Unknown[]) => string} */
|
|
10
|
+
const stringify = a => json.stringify(sort)(a)
|
|
11
|
+
|
|
12
|
+
/** @type {<T>(a: T) => (b: T) => map.Sign} */
|
|
13
|
+
const reverseCmp = flip(unsafeCmp)
|
|
14
|
+
|
|
15
|
+
module.exports = {
|
|
16
|
+
sortedMergre: [
|
|
17
|
+
() => {
|
|
18
|
+
const result = stringify(toArray(_.merge(unsafeCmp)([2, 3, 4])([1, 3, 5])))
|
|
19
|
+
if (result !== '[1,2,3,4,5]') { throw result }
|
|
20
|
+
},
|
|
21
|
+
() => {
|
|
22
|
+
const result = stringify(toArray(_.merge(unsafeCmp)([1, 2, 3])([])))
|
|
23
|
+
if (result !== '[1,2,3]') { throw result }
|
|
24
|
+
},
|
|
25
|
+
() => {
|
|
26
|
+
const n = 10_000
|
|
27
|
+
const list = countdown(n)
|
|
28
|
+
const result = _.merge(reverseCmp)(list)(list)
|
|
29
|
+
const len = length(result)
|
|
30
|
+
if (len != n) { throw result }
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|