Suggestion: partition functions
See original GitHub issueExamples
partition
Takes a function and an iterable, returns a pair of 2 iterables.
// usage
const [evens, odds] = partition(
n => n % 2 === 0, // func: (x: T) => boolean
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] // iterable: Iterable<T>
)
// result
expect(Array.from(evens)).toEqual([0, 2, 4, 6, 8])
expect(Array.from(odds)).toEqual([1, 3, 5, 7, 9])
multiPartition
Takes a function and an iterable, returns an array of iterables.
// usage
const [a, b, c] = multiPartition(
x => x % 3, // func: (x: T) => number
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] // iterable: Iterable<T>
)
// result
expect(Array.from(a)).toEqual([0, 3, 6, 9])
expect(Array.from(b)).toEqual([1, 4, 7])
expect(Array.from(c)).toEqual([2, 5, 8])
Issue Analytics
- State:
- Created 5 years ago
- Comments:53 (1 by maintainers)
Top Results From Across the Web
I. Improved partition functions and thermodynamic quantities ...
New partition functions for equilibrium, normal, and ortho and para hydrogen are calculated and thermodynamic quantities are reported for the temperature ...
Read more >Approximating Partition Functions - Windows On Theory
Another method of calculating the partition function involves Taylor expanding its logarithm around a cleverly selected point. This approach was ...
Read more >Quantum Statistics 37 : Partition Function and Free Energy
In this video I continue with my series of tutorial videos on Quantum Statistics. This is intended to be part of both my...
Read more >Partition Functions with spin in AdS_2 via Quasinormal Mode ...
Abstract: We extend the results of arXiv:1401.7016, computing one loop partition functions for massive fields with spin half in AdS_2 using ...
Read more >On the Uncomputability of Partition Functions in Energy-Based ...
In this paper, we argue that energy-based sequence models backed by expressive parametric families can result in uncomputable and inapproximable partition ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Given that we see a valid use case consuming iterables one by one. I am going to adjust the code accordingly and publish a PR (I am probably going to steal your unit tests @KSXGitHub )
@sithmel I’ll wait. But I think you should make a pull request so we may discuss.