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/
7
Upvotes
3
u/Voxelman Jul 18 '25
Try F#. It feels a bit like Python, but is functional first.
2
u/_lazyLambda Jul 18 '25
Is it vital that it has to be in python?
2
u/AustinVelonaut Jul 18 '25
The way I would approach this in Haskell or Miranda would be to use either
mapAccumLormapMin aStatemonad, mapping the divMod function with the accumulator / state variable being the quotient result and the mapping being the remainder result, e.g.:3
u/Famous_Confidence582 Jul 18 '25 edited Jul 18 '25
I would not use a regular class but a dataclass to store the result (going away from OOP and more towards a "type" like in FP), and apply functions (reusable ones if possible) to fill that dataclass or represent it.
2
u/[deleted] Jul 18 '25
[removed] — view removed comment