F# curried function

前端 未结 6 2389
独厮守ぢ
独厮守ぢ 2020-12-15 06:02

Anyone have a decent example, preferably practical/useful, they could post demonstrating the concept?

6条回答
  •  死守一世寂寞
    2020-12-15 06:15

    I gave a good example of simulating currying in C# on my blog. The gist is that you can create a function that is closed over a parameter (in my example create a function for calculating the sales tax closed over the value of a given municipality)out of an existing multi-parameter function.

    What is appealing here is instead of having to make a separate function specifically for calculating sales tax in Cook County, you can create (and reuse) the function dynamically at runtime.

提交回复
热议问题