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

21
LINES

< > BotCompany Repo | #1022653 // ai_findSpreadOutWords (ignoring case)

JavaX fragment (include)

1  
static L<Int> ai_findSpreadOutWords(LS tok, S... words) {
2  
  ret ai_findSpreadOutWords(tok, wrapAsList(words));
3  
}
4  
5  
static L<Int> ai_findSpreadOutWords(LS tok, LS words) {
6  
  int i = 1, iWord = 0, nWords = l(words), nTok = l(tok);
7  
  new L<Int> indices;
8  
  while (iWord < nWords) {
9  
    if (i >= nTok) null; // fail
10  
    if (eqic(tok.get(i), words.get(iWord))) {
11  
      indices.add(i);
12  
      ++iWord;
13  
    }
14  
    i += 2;
15  
  }
16  
  ret indices;
17  
}
18  
19  
static L<Int> ai_findSpreadOutWords(S s, S... words) {
20  
  ret ai_findSpreadOutWords(javaTok(s), words);
21  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1022653
Snippet name: ai_findSpreadOutWords (ignoring case)
Eternal ID of this version: #1022653/5
Text MD5: 3a5f98b8116040c4c937298fdb712421
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-27 15:20:55
Source code size: 557 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 280 / 328
Version history: 4 change(s)
Referenced in: [show references]