Assuming that the sequence elements are of type A, folds from left to right starting with the seed value given by zero_value (of type A) using a function of type func(current: B, next: A) => B. current represents the folded value so far and next is the next element f
(self, zero_value, func)
| 1080 | return result_lambda(self.fold_left(seed, func)) |
| 1081 | |
| 1082 | def fold_left(self, zero_value, func): |
| 1083 | """ |
| 1084 | Assuming that the sequence elements are of type A, folds from left to right starting with |
| 1085 | the seed value given by zero_value (of type A) using a function of type |
| 1086 | func(current: B, next: A) => B. current represents the folded value so far and next is the |
| 1087 | next element from the sequence to fold into current. |
| 1088 | |
| 1089 | >>> seq('a', 'b', 'c').fold_left(['start'], lambda current, next: current + [next])) |
| 1090 | ['start', 'a', 'b', 'c'] |
| 1091 | |
| 1092 | :param zero_value: zero value to reduce into |
| 1093 | :param func: Two parameter function as described by function docs |
| 1094 | :return: value from folding values with func into zero_value from left to right. |
| 1095 | """ |
| 1096 | result = zero_value |
| 1097 | for element in self: |
| 1098 | result = func(result, element) |
| 1099 | return _wrap(result) |
| 1100 | |
| 1101 | def fold_right(self, zero_value, func): |
| 1102 | """ |