How to teach 'functional programming' to a 6-year-old child
There are two types of programming concepts: object-oriented and functional. Tend to understand difficult and frustration compared to object-oriented '
Conversations with a six-year-old on functional programming | blog :: Brent-> [String]
Professor Brent Yogyay, a professor of mathematics and computer science at Hendricks College, came while reading Janis Voigtländer's ' (PDF file) Types for Programming and Reasoning ' article on free theorems. The old son asked, 'Dad, what are you reading?' Yogai, who was puzzled not to know where to explain it, answered straight, 'I'm reading a long story about free theorems,' but what I got back from my son was, as expected, what 'free theorems is?' The answer was '?'
Professor Yohei, who is an educator, thinks about answering his son's questions for a while, and in other words, 'What do you know what a function?' Yogaya's answer to this was to explain the function in the parable that 'function is like a machine where something comes out from the opposite exit when something is entered from the entrance'.
'For example, if you put in a number, one big number might come out. If you put 3 in, 4 will come out, if you put 6 in 7, it will come out,' Professor Yogaya explained. The son appeared to be interested. So, Professor Yogaya says, 'There is a type in the function machine. So, if you enter numbers, numbers will appear, and if you enter a list of numbers, numbers may appear.' Could you possibly put in a word? '
Professor Yogaya said, 'Of course you can put in words to put out a word, or put a function machine in a function machine and put out a function machine', then 'you can put a function machine in the function machine My son was surprised by the new idea of '!' In a conversation like this, Professor Yogyay concluded that 'free theorems is about functional machines that do not know what's in, but only types can understand.'
“I have a good game. It's a 'functional machine game,'” said Yogaya, who wanted to use parables to explain to children in an easy-to-understand way, but also wanted to use another approach to deepen their understanding. It is proposed to play a game. 'Dadda thinks about the function machine. When you decide how many to put in the function machine, the function machine gives an answer. Then, you have what kind of function machine it is.' It seems that the game started soon to understand the rules.
The functions “λx.x + 1” (add 1 to the number entered, “λx.x−3” (subtract 3 from the number entered), “λx.2x” (double the entered number) It seems that the answer was immediately found about, but it was said that the function 'λx. 6' (which returns 6 regardless of what you put in) is very tedious. Having struggled to come up with the idea that 'the function machine doesn't care about input,' he finally came to the answer, and Professor Yogaya, who was watching this, turned to the integration constant (C) in the calculus class. It seems that he has accumulated many of the students who are skilled.
After that, Professor Yogay and his son repeat the function machine game even in the drive and bath, and the son clears the function “λw.English noun.plural (w)” (to put the plural words into plural form), “λx Solve complex things such as .min (x + 2, 10) '(add 2 to the number you entered and choose the smaller of 10) and make your own' function machine ' It was said that Professor Yogaya described “the best parenting day” as an experience in learning the parables about functions and letting them understand the concept of functions while playing in a function machine game while free theorems explain something. You