Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

    >>> let = lambda
      File "<stdin>", line 1
        let = lambda
               ^
    SyntaxError: invalid syntax
Am I misunderstanding you?


>>> let = lambda x: 2*x

>>> print let(4)

8

Edit: Awesome, downvoted for helping.


That's not what they mean. The usage they are discussing is more like this, I believe. In a functional context, instead of doing:

    print expensive_computation(), expensive_computation()
You can do:

    (lambda x: print x, x)(expensive_computation())
Which would be equivalent to, with an imaginary let syntax:

    (let x be expensive_computation(): print x, x)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: