sclass WebNode { new L<S> labels; void addLabel(S label) { setAdd(labels, label); } bool hasLabel(S label) { ret labels.contains(label); } } sclass Web { new L<WebNode> nodes; Map<Pair<WebNode>, WebNode> relations = new HashMap; void relation(Lisp l) { if (l(l) != 2) ret; getRelation(l.s(0), l.s(1)).addLabel(l.head); } WebNode getRelation(S a, S b) { Pair<WebNode> p = pair(findNode(a), findNode(b)); WebNode r = relations.get(p); if (r == null) relations.put(p, r = new WebNode); ret r; } WebNode findNode(S s) { for (WebNode n : nodes) if (n.labels.contains(s)) ret n; ret newNode(s); } WebNode newNode(S... labels) { new WebNode n; for (S label : labels) n.addLabel(label); nodes.add(n); ret n; } }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1007660 |
Snippet name: | Web + WebNode |
Eternal ID of this version: | #1007660/1 |
Text MD5: | c961e37bbe4884de6d2fcafdaaf7af93 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-03-30 21:57:10 |
Source code size: | 855 bytes / 40 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 614 / 859 |
Referenced in: | [show references] |