Libraryless. Click here for Pure Java version (2705L/16K).
ifndef NoGenericFunctions static O first(O list) { ret first((Iterable) list); } endifndef static <A> A first(L<A> list) { return empty(list) ? null : list.get(0); } static <A> A first(A[] bla) { ret bla == null || bla.length == 0 ? null : bla[0]; } ifclass IterableIterator static <A> A first(IterableIterator<A> i) { ret first((Iterator<A>) i); } endif static <A> A first(Iterator<A> i) { ret i == null || !i.hasNext() ? null : i.next(); } static <A> A first(Iterable<A> i) { if (i == null) ret null; Iterator<A> it = i.iterator(); ret it.hasNext() ? it.next() : null; } static Char first(S s) { ret empty(s) ? null : s.charAt(0); } static Char first(CharSequence s) { ret empty(s) ? null : s.charAt(0); } ifclass Pair static <A, B> A first(Pair<A, B> p) { ret p == null ? null : p.a; } endif ifclass T3 static <A, B, C> A first(T3<A, B, C> t) { ret t == null ? null : t.a; } endif static Byte first(byte[] l) { ret empty(l) ? null : l[0]; } ifclass IntBuffer static int first(IntBuffer buf) { ret buf.get(0); } endif ifclass ByteBuffer static byte first(ByteBuffer buf) { ret buf.get(0); } endif
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, podlckwnjdmb, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, whxojlpjdney, xrpafgyirdlv
ID | Author/Program | Comment | Date | |
---|---|---|---|---|
874 | #1000610 | Edit suggestion: !636 !629 main { static Object androidContext; static String programID; public static void main(String[] args) throws Exception { static Object first(Object list) { return ((List) list).isEmpty() ? null : ((List) list).get(0); } }} | 2015-08-19 22:48:33 | delete |
755 | #1000604 (pitcher) | 2015-08-19 17:00:56 |
Snippet ID: | #1000628 |
Snippet name: | first function |
Eternal ID of this version: | #1000628/14 |
Text MD5: | 2c824650db53f105d4d2f370df2a7878 |
Transpilation MD5: | faedec2fcf13c67df1c569c0df0c5724 |
Author: | stefan |
Category: | |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-03-08 12:12:43 |
Source code size: | 1195 bytes / 60 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 873 / 2442 |
Version history: | 13 change(s) |
Referenced in: | [show references] |
Formerly at http://tinybrain.de/1000628 & http://1000628.tinybrain.de