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).

static double doubleSum(Iterable<Double> l) {
  double sum = 0;
  for (Double i : unnull(l))
    if (i != null) sum += i;
  ret sum;
}

static double doubleSum(double... l) {
  double sum = 0;
  if (l != null) for (double i : l)
    sum += i;
  ret sum;
}

static <A> double doubleSum(Iterable<A> l, IF1_ObjectToDouble<A> f) {
  double sum = 0;
  for (a : l) sum += f.get(a);
  ret sum;
}

static <A> double doubleSum(Iterable<A> l, S field) {
  double sum = 0;
  for (a : l) sum += toDouble(getOpt(a, field));
  ret sum;
}

static <A> double doubleSum(S field, Iterable<A> l) {
  ret doubleSum(l, field);
}

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: 505 / 657
Version history: 6 change(s)
Referenced in: [show references]