Book contents
- Frontmatter
- Contents
- Preface
- 1 An introduction to Mathematica
- 2 The Mathematica language
- 3 Lists
- 4 Patterns and rules
- 5 Functional programming
- 6 Procedural programming
- 7 Recursion
- 8 Numerics
- 9 Strings
- 10 Graphics and visualization
- 11 Dynamic expressions
- 12 Optimizing Mathematica programs
- 13 Applications and packages
- Solutions to exercises
- Bibliography
- Index
5 - Functional programming
Published online by Cambridge University Press: 05 February 2013
- Frontmatter
- Contents
- Preface
- 1 An introduction to Mathematica
- 2 The Mathematica language
- 3 Lists
- 4 Patterns and rules
- 5 Functional programming
- 6 Procedural programming
- 7 Recursion
- 8 Numerics
- 9 Strings
- 10 Graphics and visualization
- 11 Dynamic expressions
- 12 Optimizing Mathematica programs
- 13 Applications and packages
- Solutions to exercises
- Bibliography
- Index
Summary
Functional programming, the use and evaluation of functions as a programming paradigm, has a long and rich history in programming languages. Lisp came about in the search for a convenient language for representing mathematical concepts in programs. It borrowed from the lambda calculus of the logician Alonzo Church. More recent languages have in turn embraced many aspects of Lisp – in addition to Lisp's offspring such as Scheme and Haskell, you will find elements of functional constructs in Java, Python, Ruby, and Perl. Mathematica itself has clear bloodlines to Lisp, including the ability to operate on data structures such as lists as single objects and in its representation of mathematical properties through rules. Being able to express ideas in science, mathematics, and engineering in a language that naturally mirrors those fields is made much easier by the integration of these tools.
Functions not only offer a familiar paradigm to those representing ideas in science, mathematics, and engineering, they provide a consistent and efficient mechanism for computation and programming. In Mathematica, unlike many other languages, functions are considered “first class” objects, meaning they can be used as arguments to other functions, they can be returned as values, and they can be part of many other kinds of data objects such as arrays. In addition, you can create and use functions at runtime, that is, when you evaluate an expression. This functional style of programming distinguishes Mathematica from traditional procedural languages like C and Fortran.
- Type
- Chapter
- Information
- Programming with Mathematica®An Introduction, pp. 115 - 188Publisher: Cambridge University PressPrint publication year: 2013