It would be nice to have a variant of span and a variant of takeWhile that do not just apply a predicate, but also fold over a value.
The practical application I have in mind is to span or takeWhile but only up to a maximum number of characters. This of course could be implemented if there was a spanMax and takeWhileMax but a generalized spanWith and takeWhileWith that also do a fold (in this case over the number of characters already selected by the predicate) seems to be the better choice to me.
It would be nice to have a variant of
spanand a variant oftakeWhilethat do not just apply a predicate, but also fold over a value.The practical application I have in mind is to
spanortakeWhilebut only up to a maximum number of characters. This of course could be implemented if there was aspanMaxandtakeWhileMaxbut a generalizedspanWithandtakeWhileWiththat also do a fold (in this case over the number of characters already selected by the predicate) seems to be the better choice to me.