r/functionalprogramming • u/jpgoldberg • Jul 17 '25
Question My disFunctional brain can't make this functional
/r/PythonLearning/comments/1m0rldb/my_disfunctional_brain_cant_make_this_functional/
8
Upvotes
View all comments
Show parent comment
3
u/AustinVelonaut Jul 18 '25
There's also the right-to-left variant,
mapAccumR, which might be slightly better here, as it could return the list in the same order as the elements in the Time data structure, rather than reversed.In other cases, a similar operation can be done in the
Statemonad usingrunStateandmapMto map over a list, while chaining a state through the computation.