Libraryless. Click here for Pure Java version (7877L/44K).
static <A> A oneOf(L<A> l) { if (empty(l)) null; int n = l.size(); ret n == 1 ? first(l) : l.get(defaultRandomizer().nextInt(n)); } static char oneOf(S s) { ret empty(s) ? '?' : s.charAt(random(l(s))); } static <A> A oneOf(A... l) { ret oneOf(asList(l)); }
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1001295 |
Snippet name: | oneOf function |
Eternal ID of this version: | #1001295/6 |
Text MD5: | 7ba2a1b46b685dd49395c04c5a60702b |
Transpilation MD5: | c2aa05f8043098f8aa0aa90246dfce19 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-05-02 20:33:45 |
Source code size: | 280 bytes / 13 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 758 / 1200 |
Version history: | 5 change(s) |
Referenced in: | [show references] |