DEV Community

Discussion on: Why I love learning functional programming

Collapse
 
cappe987 profile image
Casper
square :: Int -> Int
square = foldl (*) 1 . replicate 2

isEven :: Int -> Bool
isEven = (== 0) . (`mod` 2)

It's not so elegant if you make it all point-free though. Point-free notation can make some code easier to read. But if you take it too far it just becomes worse. In the case of your double function, the parameter was last in the chain and nowhere else so it makes sense to remove it.

Collapse
 
ksaaskil profile image
Kimmo Sääskilahti

Thanks for the comment! I agree with everything you said :)