Libraryless. Click here for Pure Java version (10694L/59K).
1 | static <A> A lastThat(L<A> l, O pred) { |
2 | for (int i = l(l)-1; i >= 0; i--) { |
3 | A a = l.get(i); |
4 | if (checkCondition(pred, a)) |
5 | ret a; |
6 | } |
7 | null; |
8 | } |
9 | |
10 | static <A> A lambdaMapLike lastThat(O pred, L<A> l) { |
11 | ret lastThat(l, pred); |
12 | } |
13 | |
14 | static <A> A lastThat(IPred<A> pred, L<A> l) { |
15 | ret lastThat((O) pred, l); |
16 | } |
17 | |
18 | static <A> A lastThat(L<A> l, IPred<A> pred) { |
19 | ret lastThat(pred, l); |
20 | } |
21 | |
22 | static <A> A lastThat(Iterable<A> l, IPred<A> pred) { |
23 | A x = null; |
24 | if (l != null) for (a : l) |
25 | if (pred.get(a)) |
26 | x = a; |
27 | ret x; |
28 | } |
Began life as a copy of #1006407
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1021565 |
Snippet name: | lastThat - find last element in list that matches a predicate |
Eternal ID of this version: | #1021565/5 |
Text MD5: | 0d3062616642776294c0ec66276e8dd1 |
Transpilation MD5: | a9cf29ad313083f930cab877d892a04b |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2023-08-07 16:53:12 |
Source code size: | 563 bytes / 28 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 422 / 506 |
Version history: | 4 change(s) |
Referenced in: | [show references] |