Let me demonstrate with a piece of code taken from an answer to a "functional" Python question on SO
Python:
def grandKids(generation, kidsFunc, val):
layer = [val]
for i in xrange(generation):
layer = itertools.chain.from_iterable(itertools.imap(kidsFunc, layer))
return layer
Haskell:
grandKids generation kidsFunc val =
iterate (concatMap kidsFunc) [val] !! generation
The main difference here is that Haskell's standard library has useful functions for functional programming: in this case iterate
, concat
, and (!!)