@cddr has joined the channel
How might you go about writing a generator of sequences of numbers which add up to n?
@cddr depends what kind of distribution you want
the easy dumb way to do it is to generate a sequence of numbers and then append (- n sum) to them
also depends on what kind of numbers you mean
This is related to my question over in #clojure-spec about a having relations between a top-level amount, and children that should add up to that amount https://clojurians.slack.com/archives/C1B1BB2Q3/p1501686285791508
would it be weird to not generate the top-level amount?
generate just the children, then set the top-level to the sum?
Yeah that was my first thought too. But then I thought I needed to solve this type of problem anyway but looking back at my code I can't remember why now 🙂
In the actual example there are a few more relationships between the top-level and the children
a very useful tactic as generating something related to what you want, and using gen/fmap to transform it
i.e., generate the information, then use fmap to get it into the right format