Libraryless. Click here for Pure Java version (665L/4K).
static <A> L<A> takeFirst(L<A> l, int n) { ret l(l) <= n ? l : newSubListOrSame(l, 0, n); } static <A> L<A> takeFirst(int n, L<A> l) { ret takeFirst(l, n); } static S takeFirst(int n, S s) { ret substring(s, 0, n); } static S takeFirst(S s, int n) { ret substring(s, 0, n); } static CharSequence takeFirst(int n, CharSequence s) { ret subCharSequence(s, 0, n); } static <A> L<A> takeFirst(int n, Iterator<A> it) { if (it == null) null; new L l; repeat n { if (it.hasNext()) l.add(it.next()); else break; } ret l; } static <A> L<A> takeFirst(int n, Iterable<A> i) { if (i == null) null; ret i == null ?: takeFirst(n, i.iterator()); } static <A> L<A> takeFirst(int n, ItIt<A> i) { ret takeFirst(n, (Iterator<A>) i); } static int[] takeFirst(int n, int[] a) { ret takeFirstOfIntArray(n, a); } static short[] takeFirst(int n, short[] a) { ret takeFirstOfShortArray(n, a); } static byte[] takeFirst(int n, byte[] a) { ret takeFirstOfByteArray(n, a); } static byte[] takeFirst(byte[] a, int n) { ret takeFirstOfByteArray(n, a); } static double[] takeFirst(int n, double[] a) { ret takeFirstOfDoubleArray(n, a); } static double[] takeFirst(double[] a, int n) { ret takeFirstOfDoubleArray(n, a); } static <A, B> Map<A, B> takeFirst(int n, Map<A, B> map) { ret takeFirstFromMap(n, map); }
Began life as a copy of #1003099
download show line numbers debug dex old transpilations
Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, whxojlpjdney, xrpafgyirdlv
No comments. add comment