Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lambda Expressions for a 5th Grader

Tags:

c#

If you had to explain Lambda expressions to a 5th grader (10/11 years old), how would you do it? And what examples might you give, or resources might you point them to? I may be finding myself in the position of having to teach this to 5th grade level developers and could use some assistance.

[EDIT]: The "5th Grader" reference was meant to relate to an American TV show which pits adults vs. 5th graders in a quiz type setting (I think). I meant to imply that the people who need to be taught this know nothing about Lambda's and I need to find a way to make things VERY simple. I'm sorry that I forgot this forum has a worldwide audience.

Thanks very much.

like image 236
Randy Minder Avatar asked Jun 03 '10 11:06

Randy Minder


4 Answers

Just call it a function without a name. If she has not been exposed to much programming her mind not already have been calcified in thinking that all functions should have names.

Most of the complexity related to lambda expressions is caused by complicated naming and putting it on a marble pedestal.

Lot's of kids create great websites with lot's of Javascript stuff. Chances are they are using lambda expressions all the time without knowing it. They just call it a 'cool trick'.

like image 171
Peter Tillemans Avatar answered Oct 23 '22 04:10

Peter Tillemans


I don't think you need to explain lambda expressions to kids aged 10-11. Just show them how lambda expressions look like, what you can do with them, and where you can use them. Kids in that age still have the capability to learn something new without relying on analogies to understand it.

like image 22
dtb Avatar answered Oct 23 '22 04:10

dtb


Lambda expressions are what I consider higher order programming. Rigorous explanation will require extensive prerequisite learning. Certainly, this is not practical at the 5th grade level.

However, it might help to just cover some concepts by example in a way that mirrors real life physical situations.

For instance, a scale is a sort of a lambda expression. It tallies the mass of the objects placed on it. It is not a variable because it does not store the number anywhere. Instead, it generates the number at the time of use. When used again, it recalculates based on its inputs. You can take it places and use it somewhere else, but the underlying mechanics (expression) is the same.

like image 21
spoulson Avatar answered Oct 23 '22 06:10

spoulson


if he already understands what "function" is that you can say that it is the function that you need only once and therefore it doesn't need a name.

Anyway, if you need to explain functional programming I would recommend to try to steal some ideas from http://learnyouahaskell.com/ - it's one of the best explanations of ideas behind functional programming I've ever read.

like image 1
Andrey Taptunov Avatar answered Oct 23 '22 06:10

Andrey Taptunov