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

8
LINES

< > BotCompany Repo | #1030108 // multiSetToHistogramWithSum1

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

Libraryless. Click here for Pure Java version (3023L/19K).

static <A> Map<A, Double> multiSetToHistogramWithSum1(MultiSet<A> ms) {
  if (empty(ms)) null;
  double total = ms.size();
  new Map<A, Double> map;
  for (Pair<A, Int> p : multiSetToPairs(ms))
    map.put(p.a, p.b/total);
  ret map;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030108
Snippet name: multiSetToHistogramWithSum1
Eternal ID of this version: #1030108/1
Text MD5: 762859bec911736b12151c5440b78983
Transpilation MD5: 04b93265dbaf91c418b11b6bdc914869
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-11-09 12:49:34
Source code size: 242 bytes / 8 lines
Pitched / IR pitched: No / No
Views / Downloads: 180 / 261
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)