Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add spread/3 to portion out a given amount without a remainder #175

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jdewar
Copy link

@jdewar jdewar commented Nov 15, 2024

From the discussion in #173, and for my own project, I've been working on a 'spread' function that will distribute money evenly across a given list of portions. After several code iterations, this may be clean enough to be part of :ex_money proper.

The portions can be Money.t(), or numbers as used by @coladarci, or a single integer to split it evenly. It takes inspiration from @Wigny's recursive solution as well.

The tests are split across 3 files because they are property tests and being in separate modules lets them make use of async: true. Even so, the tests now take ~4s to run instead of ~1s.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant