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

22
LINES

< > BotCompany Repo | #1012649 // ai_triplesToTripleRefs_lazyList

JavaX fragment (include)

sbool ai_triplesToTripleRefs_lazyList_debug;

static L<TripleRef<Symbol>> ai_triplesToTripleRefs_lazyList(final Symbol searchTerm, final L<TripleWeb> l) {
  if (l == null) null;
  class TTTRList extends LazyList<TripleRef<Symbol>> {
    final int n = l(l);
    public int size() { ret n; }
    public TripleRef<Symbol> get(int i) {
      if (ai_triplesToTripleRefs_lazyList_debug) print("tttrlist.get " + i + "/" + l(l));
      TripleWeb w = syncGet(l, i);
      if (w == null) null;
      
      // run-length magic - TODO: concatenated lists
      int runLength = 0;
      while (i-runLength > 0 && l.get(i-runLength-1) == w)
        ++runLength;
        
      ret ai_tripleToTripleRef(l.get(i), searchTerm, runLength); // may be null
    }
  }
  ret new TTTRList;
}

Author comment

Began life as a copy of #1012352

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: #1012649
Snippet name: ai_triplesToTripleRefs_lazyList
Eternal ID of this version: #1012649/10
Text MD5: 775358af757e47d05eab2e65740a6df3
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-12-10 19:53:51
Source code size: 790 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 496 / 495
Version history: 9 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1013013 - ai_triplesToACPairs
#1013649 - ai_triplesToCRefs