1 | // accepts a string as predicate (then compares with "eq") |
2 | static int gSearchIdx(O predicate) { |
3 | ret gSearchIdx(predicate, 0); |
4 | } |
5 | |
6 | static int gSearchIdx(O predicate, int startIdx) { |
7 | ret gSearchIdx(gLog(), predicate, startIdx); |
8 | } |
9 | |
10 | static int gSearchIdx(L<S> log, O predicate, int startIdx) { |
11 | if (predicate == null) ret -1; |
12 | if (predicate instanceof S) { |
13 | final S _s = (S) predicate; |
14 | predicate = func(S s) { eq(s, _s) }; |
15 | } |
16 | |
17 | for (int i = l(log)-startIdx-1; i >= 0; i--) |
18 | if (isTrue(callF(predicate, log.get(i)))) |
19 | ret i; |
20 | ret -1; |
21 | } |
Began life as a copy of #1003824
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1003832 |
Snippet name: | gSearchIdx - return line index |
Eternal ID of this version: | #1003832/1 |
Text MD5: | a54a09316d8c898c98a1eda958c9a5f9 |
Author: | stefan |
Category: | javax / talking robots |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-08-10 18:41:42 |
Source code size: | 575 bytes / 21 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 643 / 643 |
Referenced in: | [show references] |