Morphix v0.1.1 released, now with partiphification!
Morphix is a small library of convenience methods for manipulating Enums, including flattening lists and tuples, converting strings to atoms, and odder things.
The new partiphify
method divides a list into k balanced sublists, such that:
> Morphix.partiphify!([:a,:b,:c,:d,:e,:f,:g,:h,:i,:j], 4)
[[:e, :f], [:g, :h], [:i, :a, :b], [:j, :c, :d]]
The difference between Morphix.partiphify
and Enum.chunk
is twofold: first, you always get k sublists, even if one or more are empty, and second, the output list sizes are balanced. The use case it was designed for was dividing a list of inputs across a fixed number of workers.
code and documentation