Why is `($ 4) (> 3)` equivalent to `4 > 3`?

后端 未结 3 1912
暖寄归人
暖寄归人 2021-01-04 18:58

I noticed as I was playing around with Haskell today that it is possible to do something like

($ 4) (> 3)

which yields True

3条回答
  •  温柔的废话
    2021-01-04 19:21

    ($ 4) is the function that takes a function and applies 4 to it.

    (> 3) is the function that takes a number and checks if it is greater than 3.

    So by giving the latter function to the former, you are essentially applying 4 to the function that checks if its input is greater than 3, and thus you get True.

提交回复
热议问题