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

29
LINES

< > BotCompany Repo | #1019131 // doubleSum

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

Libraryless. Click here for Pure Java version (10691L/59K).

1  
static double doubleSum(Iterable<Double> l) {
2  
  double sum = 0;
3  
  for (Double i : unnull(l))
4  
    if (i != null) sum += i;
5  
  ret sum;
6  
}
7  
8  
static double doubleSum(double... l) {
9  
  double sum = 0;
10  
  if (l != null) for (double i : l)
11  
    sum += i;
12  
  ret sum;
13  
}
14  
15  
static <A> double doubleSum(Iterable<A> l, IF1_ObjectToDouble<A> f) {
16  
  double sum = 0;
17  
  for (a : l) sum += f.get(a);
18  
  ret sum;
19  
}
20  
21  
static <A> double doubleSum(Iterable<A> l, S field) {
22  
  double sum = 0;
23  
  for (a : l) sum += toDouble(getOpt(a, field));
24  
  ret sum;
25  
}
26  
27  
static <A> double doubleSum(S field, Iterable<A> l) {
28  
  ret doubleSum(l, field);
29  
}

Author comment

Began life as a copy of #1006064

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1019131
Snippet name: doubleSum
Eternal ID of this version: #1019131/7
Text MD5: 03c868e7ec39b709784f5a2c77a9d7de
Transpilation MD5: b28b40143a08c51ae225b8452acb4c5d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2024-10-19 15:25:02
Source code size: 635 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 506 / 660
Version history: 6 change(s)
Referenced in: [show references]