Am Samstag, 16. Juli 2011 08:46:42 UTC+2 schrieb Steven D'Aprano: > Rainer Grimm wrote: > > > I think it's relatively difficult to get a feeling what a are the key > > points behind functional programming. So I think you should start > > explaining the concepts behind functional programming. A few ideas. > > - higher order functions > > - first class functions > > - currying > > - pure functions > > - list processing > > - lambda functions > > - recursion instead of iteration > > - pattern matching > > Avoiding global state. Thats pure functions. > Lazy data processing, including infinite data streams. You are right. I forget to mention lazy versus eager evaluation. > Decorators. > Iterators. > Using iterators as a form of pipelining. Thats special about python adapting functional ideas. > > Some of these might not count as strictly functional in the lambda calculus > sense, but they're closely related and less academic and more practical. > > > > And that should end with the three guys (map, filter and reduce ) as > > building blocks of functional programming. And that is a good point to > > introduce list comprehension. Because it's only syntactic sugar for map > > filter. But what kind of sugar. It's very impressive. Thats my typical way > > to introduce it in seminars. > > If it were me, I'd probably take a less pure approach and concentrate on > concrete examples. As far as Python goes, the use of list comps/generator > expressions, iterators and decorators are the main functional idioms, not > so much map, filter and especially reduce, which only avoided being removed > from Python 3 by the narrowest margin. That is not my point. Before you talk about functional, your audience have to have a feeling, what you are talking about. The problem with functional is, that this expression is very difficult to grab. Like 15 years ago with OO or Design Pattern 10 years ago. I think the ideas behind functional programming are so great, that they a worth to reason a little bit about. Especially for people, that think, each problem can be solved in a OO manner.
But to be honest. I gave a many python seminars in the last years, talking 3 hours about functional programming in Python and use no pure approach. Sorry I answered to fast in my first mail. He asked for functional style programming, not functional programming in Python and doing the whole in one hour. Maybe the hour is a good starting point for further investigations. Greeting from Rottenburg, Rainer -- http://mail.python.org/mailman/listinfo/python-list