Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

23
LINES

< > BotCompany Repo | #1027188 // philosophyBot1_visitTrailsTree_gen

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2235L/14K).

// returns visited objects
// visitor may be null, then it's just about returning the set
static Set philosophyBot1_visitTrailsTree_gen(virtual PhilosophyBot1 engine, IVF1<O> visitor, O startingPoint) {
  new Set seen;
  philosophyBot1_visitTrailsTree_gen(engine, seen, visitor, startingPoint);
  ret seen;
}

svoid philosophyBot1_visitTrailsTree_gen(virtual PhilosophyBot1 engine, Set seen, IVF1<O> visitor, O startingPoint) {
  if (startingPoint == null) ret;

  if (!seen.add(startingPoint)) ret;
  visitor?.get(startingPoint);
  
  if (startingPoint cast Iterable)
    for (O o : startingPoint)
      philosophyBot1_visitTrailsTree_gen(engine, seen, visitor, o);
  else if (startingPoint cast Map)
    for (O o : values(startingPoint))
      philosophyBot1_visitTrailsTree_gen(engine, seen, visitor, o);
  else
    philosophyBot1_visitTrailsTree_gen(engine, seen, visitor, rcall getTrail(engine, startingPoint));
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1027188
Snippet name: philosophyBot1_visitTrailsTree_gen
Eternal ID of this version: #1027188/6
Text MD5: 77faac35e6042bfb4ebd8e10b9305d4b
Transpilation MD5: 636b3c4e0c769759f6f5c9a923751a4e
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-24 20:38:32
Source code size: 940 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 222 / 338
Version history: 5 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)