Lesson 4. First-class functions

 

After reading lesson 4, you’ll be able to

  • Understand the definition of first-class functions
  • Use functions as arguments to other functions
  • Abstract computation out of a function
  • Return functions as values

Although functional programming has long had the reputation of being overly academic, nearly all of the key features of functional programming languages are starting to appear in many other more mainstream programming languages. The most widespread of these features is that of first-class functions. These are functions that can be passed around like any other values. A decade ago, this idea was shocking to many programmers, but today the majority of programming languages support and frequently use this concept. If you’ve ever assigned an event handler in JavaScript or passed custom sort logic into a sort method in a language such as Python, you’ve already used first-class functions.

4.1. Functions as arguments

 
 

4.2. Returning functions

 
 

Summary

 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage