Live data from Hacker News

Conversations with a six-year-old on functional programming

byorgey.wordpress.com

181–190 of 319 posts

Re: Conversations with a six-year-old on functional programming

#181
post #66

Earlier quoted context omitted.

A phrasing more to the point is that one expects the input to have some effect on the output . One usually obtains this by, colloquially speaking, performing actions on the input, since if you don't act upon the input in some way, you're going to get a constant result. Of course, you are correct in that some actions don't really do anything, but they're observationally indistinguishable from not acting on the input i…

Your comment seems confused in exactly the same way as coldtea's. How are you imagining turning input 20 into output 6 without acting on the input? If you don't act on the input, you have an identity function , not a constant function. Constant functions must alter their input whenever it doesn't match the constant output. Nobody ever complained that the problem with Procrustes was that he didn't do anything to the g…

>Your comment seems confused in exactly the same way as coldtea's. How are you imagining turning input 20 into output 6 without acting on the input?

Easily:

f(x) = 20

No action on the input -- discarding the input is not an intuitive action for a 6-year old that just got a handful of of ax+k and xk + n style examples.

>Nobody ever complained that the problem with Procrustes was that he didn't do anything to the guests in his bed.*

You seem confused. Procrustes operated on his guests, which is neither the identity (they would come of unscratched) or the constant function (in which the same person or thing would emerge out of the bed).

Their height in the end was the same, but that's not the argument to the Procrustes function -- their overall body was.

>And in the other direction, I don't understand why you want to characterize "multiply the input by zero" as an action that "doesn't do anything"? In what sense would that be true?

Obviously in the intuitive sense for a 6-year old -- which is what we're discussing, and which was based on some operation on the argument that resulted in a different value each time, not degenerate versions of functions like the identity, constant, 0, etc.

(That said, it "doesn't do anything to the input" in the sense that it's not dependent on the particular input. 2x gives you 4 and 10 if you pass 2 and 5. 0x gives you 0 whatever you pass it, so could just as well be a constant fx = 0).

Re: Conversations with a six-year-old on functional programming

#183

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...."?

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

#184
post #167

Earlier quoted context omitted.

As someone who takes pride in having solved the first 100 problems of project Euler, I am slightly ashamed to admit that I probably spent as much time as your daughter to solve that. I got stuck thinking in integers, and quite quickly left the exercise as an oversight in writing the post (since X + y = even, X - y = odd is impossible for integers) 3 seconds into the first coffee of the day the realisation of my stupi…

I mean, is there any other solution? There are certainly no integral solutions to the problem, but there is a unique (rational) solution. I feel like I’m missing something entirely, though...

I was also stuck thinking in integers for a few seconds, perhaps because of the context. But yeah, a 10-year-old would already know about fractions.

Re: Conversations with a six-year-old on functional programming

#185
post #49
post #3

What is truly astounding about this is the patience to even attempt to explain free theorems to a 6 year old. Most parents would likely answer "math" and that would be the end of it. I don't (yet) have kids, but when I do I hope I have the wherewithal to recognize and take advantage of moments like these.

It's an immense amount of effort to do it consistently. And it gets harder with each kid, at least for me. One of the things you figure out is that some kids aren't interested. And if your kid isn't interested in thinking about prime numbers, you're going to be hard pressed to change that. Conversely they will have interests that you don't share, and it's going to be harder for you to participate meaningfully in that…

>And it gets harder with each kid, at least for me.

That is the most depressing thing I've read in a good while.

Re: Conversations with a six-year-old on functional programming

#186
post #167

Earlier quoted context omitted.

When my daughter was 10 we were waiting in line to checkout at a Home Depot. She asked me what was algebra. I think she had heard the older kids mention it. I responded with a question. "A plus B = 10, and A minus B = 1. What are the values of A and B?" She puzzled it over while I check out. Then her face lit up like a whole realm of knowledge had just opened up to her, and she proudly told me the answer. It's a spec…

As someone who takes pride in having solved the first 100 problems of project Euler, I am slightly ashamed to admit that I probably spent as much time as your daughter to solve that. I got stuck thinking in integers, and quite quickly left the exercise as an oversight in writing the post (since X + y = even, X - y = odd is impossible for integers) 3 seconds into the first coffee of the day the realisation of my stupi…

For the posterity: {a+b=10;a-b=1} translates to {a+b=10;a=b +1}, thus the first equation is ((b+1)+b=10) giving (b=4.5), and from there we get (a=5.5).

Re: Conversations with a six-year-old on functional programming

#187

Earlier quoted context omitted.

The child was stuck on the intuition that the argument must change in some way (i.e. that the function was linearly typed).

This and this: >> I think he was just stuck on the idea of the function doing something arithmetical to the input, and was having trouble coming up with some sort of arithmetic procedure which would result in 6 no matter what you put in don't really seem, to me, like they can explain what's happening -- f(x) = 6 is trivially easy to express in terms of arithmetic operations being applied to x. If you assume that a fu…

"Trivially easy" to a six-year old? Who may or may not even have a good grasp of the concept of zero yet? You don't seem to be very self-aware of the extent of your knowledge and understanding compared to a preschooler.

Re: Conversations with a six-year-old on functional programming

#188

Earlier quoted context omitted.

I disagree with your example being a bad and reason is right there in your comment: the word "protocol". From wikipedia we find that a "communication protocol is a system of rules that allow _two or more entities_ of a communications system to transmit information...", where I have underscored the essential phrase and cryptographic protocols are just a subset of communication protocols. The reason that Alice and Bob…

What about a definition of protocol that allows sending messages to yourself for recursion.

What about it? Why should it be treated differently?

Re: Conversations with a six-year-old on functional programming

#190

Earlier quoted context omitted.

One of those functions is to consume nothing and returns their (the programmer's) current age. This is - or at least might be - ambiguous. Current age as of implementation time or current age as of function invocation time? And while a result in whole years is a pretty natural and obvious choice for the age of a person in absence of an explicit requirement, it is certainly not the only sensible choice.

I'd argue it's not ambiguous: current age would have to be a function of invocation time, while "age at time of writing the function" would be a constant. Expressing "age" in whole years is acceptable in English, but using a decimal would be highly defensible. That's an issue of grading though.

If we were talking about pure functions, I would certainly agree, but in Python it would of course be perfectly fine and not unusual to have an impure function implicitly depending on the current time. Obviously assuming »consume nothing« only refers to the parameters of the function, so this too could be less ambiguous.
Post reply on HN