travitch/persistent-vector

Think through folds

Closed this issue · 0 comments

The array-based part of the structure is really direction-neutral. It's happy with all the folds. The list tail is another story. Thanks to that list, the "natural" folds for Vector are foldl and foldr'—the opposite of plain lists. Unfortunately, we need foldl' to implement things like filter. My experiments so far produced wretched and complicated Core. I need something better. Next attempt: use List.reverse clunkily on the tail, then dance along the result with foldr or foldl'.