Libraryless. Click here for Pure Java version (3023L/19K).
1 | static <A> Map<A, Double> multiSetToHistogramWithSum1(MultiSet<A> ms) {
|
2 | if (empty(ms)) null; |
3 | double total = ms.size(); |
4 | new Map<A, Double> map; |
5 | for (Pair<A, Int> p : multiSetToPairs(ms)) |
6 | map.put(p.a, p.b/total); |
7 | ret map; |
8 | } |
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: | 399 / 522 |
| Referenced in: | [show references] |