LeanColls icon indicating copy to clipboard operation
LeanColls copied to clipboard

`reduce` and family

Open JamesGallicchio opened this issue 1 year ago • 2 comments

Add reduce? : C -> (t -> t) -> Option t with default implementation for any Foldable collection

JamesGallicchio avatar Jan 18 '24 22:01 JamesGallicchio

Can also then implement generic sum, prod, max, min based on it

JamesGallicchio avatar Jan 18 '24 22:01 JamesGallicchio

If we generalize #5 to cover nonempty collections, then we may also want reduce : C -> (t -> t) -> t. I'm imagining it could also be implemented generically for any Fold and NonemptyColl by doing reduce? followed by getD with the default value from the collection.

JamesGallicchio avatar Jan 19 '24 18:01 JamesGallicchio