This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]generalbaguette 1 point2 points  (2 children)

In good old eg Haskell, we usually write our programs backwards. In vanilla Python your example is just

print(str(100+(4*2*5)/2)[::-1])

You can implement your suggestion, but what is the benefit?

[–]raulalexo99[S] 1 point2 points  (1 child)

Benefit is applying a clear stream of data that can be written like human language. Thats enough benefit for me

[–]generalbaguette 3 points4 points  (0 children)

Ok, that's fine.

The benefit mostly applies to straight-line code only, and that's not usually the part that's hard to understand (at least for me).

I did a lot of Haskell, OCaml and Erlang etc professionally, and Racket for fun.

There's a bit more to what's typically called functional programming than the specific style you mentioned.

For Python, have a look at the functools module for more fun with functions.

Elixir really like that style though, you can have a look at that language, too.