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

18
LINES

< > BotCompany Repo | #1010188 // doubleAverage

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

Libraryless. Click here for Pure Java version (2550L/16K).

1  
static double doubleAverage(int... a) {
2  
  double sum = 0;
3  
  for i over a:
4  
    sum += a[i];
5  
  ret doubleRatio(sum, l(a));
6  
}
7  
8  
static double doubleAverage(double... l) {
9  
  ret doubleRatio(doubleSum(l), l(l));
10  
}
11  
12  
static double doubleAverage(Iterable<Double> l) {
13  
  double sum = 0;
14  
  long n = 0;
15  
  fOr (Double i : l)
16  
    if (i != null) { sum += i; ++n; }
17  
  ret doubleRatio(sum, n);
18  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1010188
Snippet name: doubleAverage
Eternal ID of this version: #1010188/6
Text MD5: 92f756dac2e5574364b49a8568a0dc5c
Transpilation MD5: 51cdc266bfbeef87cf2dd8bbb994eb81
Author: stefan
Category: javax / maths
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-06-03 13:09:33
Source code size: 395 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 399 / 504
Version history: 5 change(s)
Referenced in: [show references]