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

14
LINES

< > BotCompany Repo | #1034575 // AverageAndMinMax - collect average, sum, number of values, minimum, maximum

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

Libraryless. Click here for Pure Java version (13132L/75K).

sclass AverageAndMinMax > Average {
  gettable double min = infinity();
  gettable double max = negativeInfinity();
  
  void add(double d) {
    super.add(d);
    if (d < min) min = d;
    if (d > max) max = d;
  }
  
  toString {
    ret "avg=" + super.toString() + (isEmpty() ? "" : ", min/max=" + min + "/" + max);
  }
}

Author comment

Began life as a copy of #1029191

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034575
Snippet name: AverageAndMinMax - collect average, sum, number of values, minimum, maximum
Eternal ID of this version: #1034575/5
Text MD5: f5cc3807858bb61f058642645f5c7b56
Transpilation MD5: 2e18a81962a7f3e9f9d328bc4f528412
Author: stefan
Category: javax / maths
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-02-19 05:46:25
Source code size: 337 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 80 / 193
Version history: 4 change(s)
Referenced in: [show references]