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

10
LINES

< > BotCompany Repo | #1006791 // lowestAccordingTo - get lowest element of list according to a score function

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3027L/18K).

1  
static <A> A lowestAccordingTo(Collection<A> l, IF1<A, Double> scoreFunction) {
2  
  ret lowestAccordingTo(l, (O) scoreFunction);
3  
}
4  
5  
static <A> A lowestAccordingTo(Collection<A> l, O scoreFunction) {
6  
  new Lowest<A> lowest;
7  
  for (A a : l)
8  
    lowest.put(a, toDouble(callF(scoreFunction, a)));
9  
  ret lowest.get();
10  
}

Author comment

Began life as a copy of #1006218

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: #1006791
Snippet name: lowestAccordingTo - get lowest element of list according to a score function
Eternal ID of this version: #1006791/2
Text MD5: 5c6cde98482efbd8c56b66d6c35fdf0c
Transpilation MD5: 745255723a1d6bfc0c93e6f93fcf6839
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-07 15:15:55
Source code size: 321 bytes / 10 lines
Pitched / IR pitched: No / No
Views / Downloads: 445 / 522
Version history: 1 change(s)
Referenced in: [show references]