[PRL] Accumulator for container capacity

William D Clinger will at ccs.neu.edu
Thu Sep 22 13:41:10 EDT 2005


> Ethan showed me how to remove that double traversal of the intermediate
> structure (which is as long as the container contents).
>
> So which of the two solutions is preferred: Mitch's without the double
> fold or Matthias' solution with !.
>
> I vote for Matthias solution although I conjecture I will be overruled.
> -- Karl

I prefer the purely functional visitor pattern, which is
a generalization of fold (from lists to linearizable ADTs).

(As Felix said, the visitor pattern is more obviously correct,
is easier to parallelize, and achieves excellent separation of
concerns because the parallelization is achieved entirely within
the apply-to-all code.)

If Ethan used that pattern to remove the double traversal
of the intermediate structures, or if Ethan eliminated the
intermediate structures by listlessness (is better than
laziness), then I prefer Ethan's solution to Matthias's.

Otherwise I would probably prefer Matthias's to Ethan's.

Will



More information about the PRL mailing list