// accepts a string as predicate (then compares with "eq")
static int gSearchIdx(O predicate) {
ret gSearchIdx(predicate, 0);
}
static int gSearchIdx(O predicate, int startIdx) {
ret gSearchIdx(gLog(), predicate, startIdx);
}
static int gSearchIdx(L<S> log, O predicate, int startIdx) {
if (predicate == null) ret -1;
if (predicate instanceof S) {
final S _s = (S) predicate;
predicate = func(S s) { eq(s, _s) };
}
for (int i = l(log)-startIdx-1; i >= 0; i--)
if (isTrue(callF(predicate, log.get(i))))
ret i;
ret -1;
}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: | 1169 / 1139 |
| Referenced in: | #1003879 - gSearchNeqIdx - return line index #1006654 - Standard functions list 2 (LIVE, continuation of #761) |