Skip to Content
Functional Programming in Python
book

Functional Programming in Python

by David Mertz
May 2015
Intermediate to advanced
50 pages
55m
English
O'Reilly Media, Inc.
Content preview from Functional Programming in Python

Preface

What Is Functional Programming?

We’d better start with the hardest question: “What is functional programming (FP), anyway?”

One answer would be to say that functional programming is what you do when you program in languages like Lisp, Scheme, Clojure, Scala, Haskell, ML, OCAML, Erlang, or a few others. That is a safe answer, but not one that clarifies very much. Unfortunately, it is hard to get a consistent opinion on just what functional programming is, even from functional programmers themselves. A story about elephants and blind men seems apropos here. It is also safe to contrast functional programming with “imperative programming” (what you do in languages like C, Pascal, C++, Java, Perl, Awk, TCL, and most others, at least for the most part). Functional programming is also not object-oriented programming (OOP), although some languages are both. And it is not Logic Programming (e.g., Prolog), but again some languages are multiparadigm.

Personally, I would roughly characterize functional programming as having at least several of the following characteristics. Languages that get called functional make these things easy, and make other things either hard or impossible:

  • Functions are first class (objects). That is, everything you can do with “data” can be done with functions themselves (such as passing a function to another function).

  • Recursion is used as a primary control structure. In some languages, no other “loop” construct exists.

  • There is a focus on list processing ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Functional Programming with Python

Functional Programming with Python

Christopher Armstrong

Publisher Resources

ISBN: 9781492048633Errata Page