How does currying work?

后端 未结 5 1620
误落风尘
误落风尘 2020-12-09 11:14

I\'m very new to Haskell and FP in general. I\'ve read many of the writings that describe what currying is, but I haven\'t found an explanation to how it actually works.

5条回答
  •  孤街浪徒
    2020-12-09 11:49

    If you come from C-like languages, their syntax might help you to understand it. For example in PHP the add function could be implemented as such:

    function add($a) {
        return function($b) use($a) {
             return $a + $b;
        };
    }
    

提交回复
热议问题