We're a place where coders share, stay up-to-date and grow their careers.
You don't have to ignore language constructs to "follow functional programming methods". In Haskell, for example, you can use the combinators:
Prelude> sum (map (\x -> x * x) (filter (\x -> x `mod` 2 == 0) [0..9])) 120
Or you can use list comprehension(like in Python):
Prelude> sum [x * x | x <- [0..9], x `mod` 2 == 0] 120
The second approach is also functional programming.
You don't have to ignore language constructs to "follow functional programming methods". In Haskell, for example, you can use the combinators:
Or you can use list comprehension(like in Python):
The second approach is also functional programming.