Lambda for Dummies…anyone, anyone? I think not

后端 未结 10 1484
迷失自我
迷失自我 2020-12-22 23:45

In my quest to understand the very odd looking \' => \' operator, I have found a good place to start, and the author is very concise and clear:

         


        
10条回答
  •  太阳男子
    2020-12-23 00:35

    Lambda calculus is common in many programming languages. They're also called anonymous functions in some languages. Though different languages have different syntax for lambda, the principle is the same, and their various parts are usually identical.

    Perhaps the most famous one is Javascript's anonymous functions.

    lol = function() {laugh()}
    # is equivalent to
    function lol() {laugh()}
    

    What's the difference? Well, sometimes you don't want to go through the trouble of creating a function just to pass it somewhere once and then never again.

    window.onload = function() {laugh()}
    # is way easier than
    function lol() {laugh()}
    window.onload = lol
    

    You can see the wikipedia article for indept information or you can skip directly to Lambda in programming in the same article.

提交回复
热议问题