1 | // f : Concept -> Concept |
2 | static Concept conceptGraphMap_aggressive(Concept c, O f) { |
3 | ret conceptGraphMap_aggressive_impl(c, f, new IdentityHashMap); |
4 | } |
5 | |
6 | static Concept conceptGraphMap_aggressive_impl(Concept c, O f, IdentityHashMap<Concept, Concept> seen) { |
7 | if (seen.containsKey(c)) |
8 | ret seen.get(c); |
9 | Concept d = cast callF(f, c); |
10 | if (d != c) { |
11 | Concept last = c; |
12 | while (d != last && d != null) { |
13 | last = d; |
14 | d = (Concept) callF(f, d); |
15 | } |
16 | } |
17 | |
18 | if (d == null) { |
19 | seen.put(c, null); |
20 | null; |
21 | } |
22 | |
23 | Concept e = cnew(d.getClass()); |
24 | seen.put(c, e); |
25 | |
26 | for (S field : conceptFields(d)) { |
27 | O val = cget(d, field); |
28 | if (!val instanceof Concept) |
29 | cset(e, field, val); |
30 | else |
31 | cset(e, field, conceptGraphMap_aggressive_impl(val/Concept, f, seen)); |
32 | } |
33 | ret e; |
34 | } |
Began life as a copy of #1005477
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1005480 |
Snippet name: | conceptGraphMap_aggressive - apply function to every concept in a concept graph, repeatedly calling the function |
Eternal ID of this version: | #1005480/1 |
Text MD5: | 1fa240fcf5d246b5b6a0d439a14975df |
Author: | stefan |
Category: | javax / concepts |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-11-20 20:34:39 |
Source code size: | 849 bytes / 34 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 583 / 575 |
Referenced in: | [show references] |