From 8a4b47df02a5cebd4b39015e450c4d793e3962fe Mon Sep 17 00:00:00 2001 From: Joeri Exelmans Date: Thu, 8 May 2025 22:59:50 +0200 Subject: [PATCH] create dictionary of {Type => {set of instances}} --- examples/environment.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 examples/environment.js diff --git a/examples/environment.js b/examples/environment.js new file mode 100644 index 0000000..d79748e --- /dev/null +++ b/examples/environment.js @@ -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); \ No newline at end of file