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

17
LINES

< > BotCompany Repo | #1025885 // levenClosestIC_iteratorWithNulls_plusMultiples - return word when it has same distance as best

JavaX fragment (include)

// returns pair(word, distance)
// or null when search step was not successful
static ItIt<Pair<S, Int>> levenClosestIC_iteratorWithNulls_plusMultiples(LS list, S word, O... _) {
  if (empty(list)) ret emptyItIt();
  ret iff(new F0 {
    int limit = optPar maxDistance(_, Integer.MAX_VALUE-2);
    int idx;
    
    O get() {
      if (limit == 0 || idx >= l(list)) ret endMarker();
      S s = list.get(idx++);
      int dist = leven_limitedIC(word, s, limit+1);
      if (dist <= limit) { limit = dist; ret pair(s, dist); }
      null;
    }
  });
}

Author comment

Began life as a copy of #1025881

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1025885
Snippet name: levenClosestIC_iteratorWithNulls_plusMultiples - return word when it has same distance as best
Eternal ID of this version: #1025885/7
Text MD5: bd12f5246fe9e0c03dba9755d854332b
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-10-28 11:57:24
Source code size: 567 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 180 / 229
Version history: 6 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)