Real life examples of functional software spirits used in imperative languages?

Most people say that even functional programming is less likely to land you at work, you can become a better OO imperative / programmer by learning it.

For me, this mainly involves writing "non member non friend" functions that have no side effects. But I could not come up with more examples when functional programming can be effectively applied in imperative languages, since working with the lack of language functions is often too cumbersome.

So, what are some (specific) examples / methods that you actually applied in non-functional languages ​​that were inspired by functional programming?

Another one of my own experiences

This is pretty abstract, but due to the lack of β€œobjects” in most FP languages, the culture there tends to maintain a rigorous data structure design. As a rule, in OOP languages, since the load of an additional variable in a class is too complex, it is too complex, everything happens pretty quickly. Although the same could be done using OCaml and Haskell syntax, this approach somehow feels out of place in FP.

+4
source share
4 answers

Data conversion

In my experience, thinking about how to solve the problem functionally makes you think more about what data the transformed receives, what - and not that the state needs to be changed so that the damned thing runs ...

Thinking about problems as a transformation makes them seem different on their own, which leads to different and most likely more elegant solutions.

Update . In C ++, there is a <functional> header and std :: transform in <algorithm>.

+2
source

Most Ruby Enumerable methods are inspired by higher order functions from functional programming.

0
source

New-ish array functions JavaScript, filter, map, each, some, decrease and decrease correctness, functionally inspired.

0
source

Functional Java has already been mentioned in the comments, but there are some functional things in Aparth Commons Collections . See org.apache.commons.collections.functors package.

0
source

All Articles