1

This is my program:

boolToInt True  = 1
boolToInt False = 0

gt :: Int -> Int -> Int
gt x y = boolToInt $ (>) x y

I try refactoring gt with gt = boolToInt . (>) but getting an error:

‘(>)’ is applied to too few arguments

The only idea come to me is curry and uncurry, but I suppose it might make gt even more complicated than gt x y = boolToInt $ (>) x y.

Do I have a prettier functional solution to this composition?

Rahn
  • 4,787
  • 4
  • 31
  • 57

2 Answers2

2

The magical pointfree.io has come up with the following solution:

gt :: Int -> Int -> Int
gt = (boolToInt .) . (>)
ljedrz
  • 20,316
  • 4
  • 69
  • 97
0

You can do:

(boolToInt .) . (>)
ThreeFx
  • 7,250
  • 1
  • 27
  • 51