create dictionary of {Type => {set of instances}}
This commit is contained in:
parent
9e1f679dba
commit
8a4b47df02
1 changed files with 19 additions and 0 deletions
19
examples/environment.js
Normal file
19
examples/environment.js
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
import { compareTypes } from "../lib/compare/type.js";
|
||||||
|
import { ModuleStd } from "../lib/stdlib.js";
|
||||||
|
import { emptyDict, get, set } from "../lib/structures/dict.js";
|
||||||
|
import { emptySet, add } from "../lib/structures/set.js";
|
||||||
|
import { makeCompareFn } from "../lib/compare/dynamic.js"
|
||||||
|
|
||||||
|
// console.log(ModuleStd);
|
||||||
|
|
||||||
|
const typeDict = ModuleStd.reduce((typeDict, {i, t}) => {
|
||||||
|
try {
|
||||||
|
const instances = get(typeDict)(t) || emptySet(makeCompareFn(t));
|
||||||
|
return set(typeDict)(t)(add(instances)(i));
|
||||||
|
} catch (e) {
|
||||||
|
console.log('warning:',e.message);
|
||||||
|
return typeDict;
|
||||||
|
}
|
||||||
|
}, emptyDict(compareTypes));
|
||||||
|
|
||||||
|
console.log(typeDict);
|
||||||
Loading…
Add table
Add a link
Reference in a new issue