Live data from Hacker News

Conversations with a six-year-old on functional programming (2018)

byorgey.wordpress.com

21–30 of 161 posts

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

#23
post #18

Surprising because I have seen few 6 years olds can do multiplications and divisions. If I'm not mistaken, standard US 1st grade curriculum expects kids to be familier with only addition below 100 and subtraction in low teens.

The specific examples are with factors 2 and 10, most kids can handle those earlier.

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

#25
post #22

What's the optimal strategy for choosing inputs in order to guess the nature of the machine?

I don't think that this problem is even computable, since the functions could be arbitrarily complex.

If you restrict the nature of the functions e.g. "polynomials of degree at most d", then the answer depends on the restriction. For the polynomial of degree <= d case the solution is d+1 inputs, every polynomial of degree at most d is uniquely determined by d+1 points.

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

#26

I find kids understand the concept of functions really intuitively if it is stated simply - input -> func -> output, it doesn't have to be difficult maths, and it can make for some great games. It looks a little intimidating if using the notation in this article but they easily grasp that a function transforms inputs and returns outputs, and it can be a fun introduction to maths and programming, and then later to thi…

Agreed! My kids are slightly older but we've long enjoyed a roadtrip game that's a variation on 20 questions: "give me an input, I'll respond with an output, then you guess what the 'machine' [algorithm|function] did". They'd get to provide one input, I'd respond w one output, then they'd get one chance to define the operation -- to which I'd respond only yes or no -- before the next person's turn to test it. Whoever…

I taught at a programming camp one summer, and my favourite example of this that I drove several kids crazy with was "above the line, below the line".

Given any input word, I would tell them whether it was above the line, or below the line (which corresponded to acceptable and unacceptable behaviour in camp-speak). I think only two kids figured it out on their own, and each time I challenged them to write a program to categorize words automatically.

I wonder if hacker news can figure it out :)

"Hacker" -> Above the line

"News" -> Above the line

"chrisweekly" -> Below the line

"functional" -> Above the line

"programming" -> Below the line

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

#28

I was 16 and learning FORTRAN at school. I was a lazy bum at that time (well, that stayed ;-), didn't really prepare, and at the final exam, the teacher asked me in what order the program is executed. Not knowing any better I replied "a value is calculated when the rest of the code needs it" (like in regular math that we did a lot at the time too). She said "not correct, it executes in the order it is written". -- I…

Fun fact about fortran: its creator (John Backus) was fond of functional programming, but that was after the fortran creation.

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

#29
post #25
post #22

What's the optimal strategy for choosing inputs in order to guess the nature of the machine?

I don't think that this problem is even computable, since the functions could be arbitrarily complex. If you restrict the nature of the functions e.g. "polynomials of degree at most d", then the answer depends on the restriction. For the polynomial of degree <= d case the solution is d+1 inputs, every polynomial of degree at most d is uniquely determined by d+1 points.

I'm having flashbacks to middle school when this was a (childish and easy, I thought, because we were 12 or whatever, not 6) exercise in a maths lesson.

I vividly recall facetiously making this point, that for all we knew it was the 'number machine' (as I think the teacher called them) that responded 'as described for the inputs shown, and zero for all others', or something; that 'it sure looks like 2x, but we can't possibly know for all numbers'.

If I'd been told the machines were linear I would have learnt something (probably, hard to recall one's knowledge at a specific time) and shut up. Alas, I was sent out...

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

#30

I find kids understand the concept of functions really intuitively if it is stated simply - input -> func -> output, it doesn't have to be difficult maths, and it can make for some great games. It looks a little intimidating if using the notation in this article but they easily grasp that a function transforms inputs and returns outputs, and it can be a fun introduction to maths and programming, and then later to thi…

Agreed! My kids are slightly older but we've long enjoyed a roadtrip game that's a variation on 20 questions: "give me an input, I'll respond with an output, then you guess what the 'machine' [algorithm|function] did". They'd get to provide one input, I'd respond w one output, then they'd get one chance to define the operation -- to which I'd respond only yes or no -- before the next person's turn to test it. Whoever…

For a non-road-trip version of this idea, check out Zendo: http://www.koryheath.com/zendo/

You don’t have to use the official Looney pyramids, of course, but those work really well. Just enough variations to be really interesting.

There’s an older game that uses playing cards, Eleusis: https://en.wikipedia.org/wiki/Eleusis_(card_game)

Post reply on HN