loading...

re: Why I love learning functional programming VIEW POST

FULL DISCUSSION
 
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.

 

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

Code of Conduct Report abuse