What is a lambda (function)?

后端 未结 23 2673
太阳男子
太阳男子 2020-11-22 04:47

For a person without a comp-sci background, what is a lambda in the world of Computer Science?

23条回答
  •  死守一世寂寞
    2020-11-22 05:00

    I have trouble wrapping my head around lambda expressions because I work in Visual FoxPro, which has Macro substitution and the ExecScript{} and Evaluate() functions, which seem to serve much the same purpose.

    ? Calculator(10, 23, "a + b")
    ? Calculator(10, 23, "a - b");
    
    FUNCTION Calculator(a, b, op)
    RETURN Evaluate(op)
    

    One definite benefit to using formal lambdas is (I assume) compile-time checking: Fox won't know if you typo the text string above until it tries to run it.

    This is also useful for data-driven code: you can store entire routines in memo fields in the database and then just evaluate them at run-time. This lets you tweak part of the application without actually having access to the source. (But that's another topic altogether.)

提交回复
热议问题