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)

1  
// returns pair(word, distance)
2  
// or null when search step was not successful
3  
static ItIt<Pair<S, Int>> levenClosestIC_iteratorWithNulls_plusMultiples(LS list, S word, O... _) {
4  
  if (empty(list)) ret emptyItIt();
5  
  ret iff(new F0 {
6  
    int limit = optPar maxDistance(_, Integer.MAX_VALUE-2);
7  
    int idx;
8  
    
9  
    O get() {
10  
      if (limit == 0 || idx >= l(list)) ret endMarker();
11  
      S s = list.get(idx++);
12  
      int dist = leven_limitedIC(word, s, limit+1);
13  
      if (dist <= limit) { limit = dist; ret pair(s, dist); }
14  
      null;
15  
    }
16  
  });
17  
}

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: 181 / 230
Version history: 6 change(s)
Referenced in: [show references]