News for hackers. Stuff that matters.
Re:Conversations with a six-year-old on functional programming by jason_slack on Monday May 07, 2018 @10:19PM (#17018327)
I'm taking a discrete math class right now.

How is this read: \lambda x.\, x - 3 and what is a simple example?

In a discrete math perhaps it is the same as "All x, x is an integer such that...."?

Re:Conversations with a six-year-old on functional programming by bovik on Tuesday May 08, 2018 @04:02AM (#17019551)
It's just jargon. I really don't know why the title isn't just "Conversations with a six-year-old on functions" and "f(x) = x - 3." You lose nothing, increase your audience 100fold, and it's more intellectually honest. It is a less hackernews clickbaity title, though.
Re:Conversations with a six-year-old on functional programming by omegaham on Tuesday May 08, 2018 @09:31AM (#17020735)
> "How is this read: \lambda x.\, x - 3"

I'd read it as "Lambda x maps to x - 3."

In Python, you can rewrite lambdas as regular functions if you want.

    lambda x : x - 3
is the same as

    def f(x):
        return x - 3
This runs in the IDLE as such:

    >>> f = lambda x : x - 3
    >>> def g(x):
    ...     return x - 3
    ... 
    >>> f(0)
    -3
    >>> g(0)
    -3
    >>> (lambda x : x - 3)(0)
    -3
Re:Conversations with a six-year-old on functional programming by craftyguy on Monday May 07, 2018 @10:34PM (#17018379)
The '\lambda x' is just another way of saying "f(x)"

So '\lambda x., x-3' --> 'f(x): x-3'

Also, I really enjoyed my discrete math courses! The proofs were.. tedious.. but the amount and breadth of 'stuff' covered was excellent.

Re:Conversations with a six-year-old on functional programming by jason_slack on Monday May 07, 2018 @10:39PM (#17018402)
It is a difficult course! We are doing graph theory right now.