Hi, is it possible in a FP way to somehow combine...
# arrow
t
Hi, is it possible in a FP way to somehow combine multiple .fold() calls on a list so that it would not re-traverse the list for each fold() call, but process each fold on the current item as it goes? I.e. I want to reduce a list to a few aggregate values. Each value has its own fold-like logic on how it's reduced-to. How to run that reduction logic for each item of the list so as to not go over the list again for each? I.e. it would go like this through the list:
Copy code
list item1 : fold1, fold2, fold3
list item2 : fold1, fold2, fold3
instead of:
Copy code
list item1: fold1
list item2: fold1

list item1: fold2
list item2: fold2

list item1: fold3
list item2: fold3
Is the only way this can be is by merging the logic for each fold into one big fold by hand and using a dataclass/tuple for an accumulator?