Closed tjarker closed 2 years ago
OK, nice! Also nice that you did the implicit thing, which I had planned as well. However, I assume your solution suffers the same issue as mine, a node might be promoted more than once. Try it with 5 and you will see.
This tree reduction implementation uses
grouped(2)
to extract pairs from the main sequence. If the number of elements is uneven,grouped
will include one sequence with a single item. This removes the need to handle that case explicitly.Using the implicit class
SeqToTreeReducible
, we can now call thetreeReduce
function on all sequences.The names should probably be different to avoid confusion with chisels
reduceTree
function :)