Aw: Functional style programming in python: what will you talk aboutif you have an hour on this topi

R

Rainer Grimm

Hello,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
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.
Now it's a good time to explain, what's special in python with
functional programming. (A lot if you compare it with haskell)
I wrote an article about your topic. You have only to learn german.
About the concepts:
http://www.linux-magazin.de/Online-Artikel/Funktionale-Programmierung-1-Grundzuege?category=0
What's special about Python:
http://www.linux-magazin.de/NEWS/Online-Artikel-Funktionale-Programmierung-in-Python?category=0


Greetings from Rottenburg,
Rainer
 
S

Steven D'Aprano

Rainer said:
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. Including singletons *wink*
Lazy data processing, including infinite data streams.
Decorators.
Iterators.
Using iterators as a form of pipelining.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top