r/functionalprogramming • • 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

22 comments sorted by

View all comments

Show parent comment

2

u/jpgoldberg Jul 18 '25

Thank you. Could you illustrate how to implement what I was trying to do in functional JS? I am less interested in how to do this in Python than I am in how to do this functionally.

2

u/[deleted] Jul 18 '25

[removed] — view removed comment

2

u/jpgoldberg Jul 18 '25

Sorry, I thought it would be clear from the code comments/docstrings even if one doesn’t read Python.

I want to get years, days, hours, minutes, and seconds from a total number of seconds. (Years are defined as exactly 365 days.)

2

u/[deleted] Jul 19 '25

[removed] — view removed comment

2

u/jpgoldberg Jul 19 '25

There is no complexity here in terms of functional programming.

That was my first thought. But then I couldn't figure out how to do it. It definitely feels like something that should have a fairly straightforward functional solution.

So I asked for help in seeing that solution.

3

u/[deleted] Jul 22 '25

[removed] — view removed comment

1

u/jpgoldberg Jul 22 '25

Thank you. There is a third-party library, expression for Python that provides a similar pipe method, and useful in other ways for functional programming in Python.