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

20
LINES

< > BotCompany Repo | #1036342 // BestWorstAndAverage - collect average score, worst element, best element

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

Libraryless. Click here for Pure Java version (10049L/55K).

1  
sclass BestWorstAndAverage<A> {
2  
  IBest<A> best = new Best;
3  
  IBest<A> worst = new Lowest;
4  
  new Average average;
5  
  
6  
  selfType lowerIsBetter() {
7  
    best = new Lowest;
8  
    worst = new Best;
9  
    this;
10  
  }
11  
12  
  bool put(A a, double score) {
13  
    average.add(score);
14  
    ret best.put(a, score) | worst.put(a, score);
15  
  }
16  
  
17  
  toString {
18  
    ret renderVars(avg := average, +best, +worst);
19  
  }
20  
}

Author comment

Began life as a copy of #1034575

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1036342
Snippet name: BestWorstAndAverage - collect average score, worst element, best element
Eternal ID of this version: #1036342/5
Text MD5: aa72e44b6ad93a5dbd5c16308a3a8bda
Transpilation MD5: 69a5af253d29ce4d8044524fd6fba9fd
Author: stefan
Category: javax / maths
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-11-21 11:30:43
Source code size: 407 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 128 / 197
Version history: 4 change(s)
Referenced in: [show references]