Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

7
LINES

< > BotCompany Repo | #1011007 // ai_first - get first element of list, note if list has multiple elements

JavaX fragment (include)

1  
static <A> A ai_first(Collection<A> l) {
2  
  if (empty(l)) null;
3  
  Iterator<A> it = l.iterator();
4  
  A a = it.next();
5  
  if (it.hasNext()) warn("Choosing first element of multiple");
6  
  ret a;
7  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1011007
Snippet name: ai_first - get first element of list, note if list has multiple elements
Eternal ID of this version: #1011007/1
Text MD5: 76c43fc6f64091850b23106d6a23cbab
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-10-11 17:06:56
Source code size: 195 bytes / 7 lines
Pitched / IR pitched: No / No
Views / Downloads: 434 / 474
Referenced in: [show references]