Libraryless. Click here for Pure Java version (2746L/16K).
1 | static <A> L<A> moveItemFirst(A item, Cl<A> l) { |
2 | if (!contains(l, item)) ret asList(l); |
3 | L<A> out = emptyList(l(l)); |
4 | out.add(item); |
5 | for (A a : l) |
6 | if (!eq(a, item)) |
7 | out.add(a); |
8 | ret out; |
9 | } |
Began life as a copy of #1026013
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1030795 |
Snippet name: | moveItemFirst - move element to beginning of (cloned) list |
Eternal ID of this version: | #1030795/3 |
Text MD5: | 63b630a85fbf2e8288217bc6c5d083cf |
Transpilation MD5: | 3e78e4c4a026b9ce9803831257b4b6d9 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-03-26 15:17:48 |
Source code size: | 213 bytes / 9 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 178 / 276 |
Version history: | 2 change(s) |
Referenced in: | [show references] |