Summary

In this chapter, we introduced lambda calculus as the basis for the functional programming paradigm. In functional programming, programs are written in a declarative language, expressing the desired result as a composition of functions instead of a procedural set of steps to execute.

In Java and Python, this appears as lambda expressions or lambda functions - small pieces of code that can be used to create anonymous functions. In addition, those functions can be treated as first-class citizens in our language, so we can store them in variables, pass them as arguments, and more.

However, due to the fact that lambda expressions are not well understood by a large number of programmers who do not have experience with functional programming, we’ll generally avoid their use in our code. In most cases, anything that can be done in a lambda expression can also be done using procedural code and functions, and that is much more readable to the average programmer.

Review Quiz

Check your understanding of the new content introduced in this chapter below - this quiz is not graded and you can retake it as many times as you want.

--- primaryColor: '#512888' secondaryColor: '#cccccc' textColor: black shuffleQuestions: true shuffleAnswers: true locale: en --- # Lambda Calculus **Lambda calculus** is a formal notation used to describe what? 1. [X] Computation 1. [ ] Mathematics 1. [ ] Algebra 1. [ ] Combinatorics # Programming Paradigms The use of lambda calculus leads to what programming paradigm? 1. [X] Functional Programming 1. [ ] Object-Oriented Programming 1. [ ] Procedural Programming 1. [ ] Imperative Programming # Structured Programming The **structured programming** paradigm is best described by what statement? 1. [X] Programs are constructed from small parts like ifs and while loops 1. [ ] Programs are lists of commands that modify state 1. [ ] Programs are built from classes representing real-world ideas 1. [ ] Programs are mathematical functions to convert inputs to outputs # Imperative Programming The **imperative programming** paradigm is best described by what statement? 1. [ ] Programs are constructed from small parts like ifs and while loops 1. [X] Programs are lists of commands that modify state 1. [ ] Programs are built from classes representing real-world ideas 1. [ ] Programs are mathematical functions to convert inputs to outputs # Object-Oriented Programming The **object-oriented programming** paradigm is best described by what statement? 1. [ ] Programs are constructed from small parts like ifs and while loops 1. [ ] Programs are lists of commands that modify state 1. [X] Programs are built from classes representing real-world ideas 1. [ ] Programs are mathematical functions to convert inputs to outputs # Functional Programming The **functional programming** paradigm is best described by what statement? 1. [ ] Programs are constructed from small parts like ifs and while loops 1. [ ] Programs are lists of commands that modify state 1. [ ] Programs are built from classes representing real-world ideas 1. [X] Programs are mathematical functions to convert inputs to outputs # Lambda Expressions In some languages, **lambda expressions** are also known by what name, mainly because they themselves don't have a name? 1. [X] Anonymous functions 1. [ ] Virtual functions 1. [ ] Function prototypes 1. [ ] Abstract functions # First-class Citizens When we say that a function is a **first-class citizen** in a programming language, what does that mean? 1. [X] It can be treated like any other part of the state 1. [ ] It is given a special keyword 1. [ ] It uses special syntax in the compiler or interpreter 1. [ ] It cannot be removed from the program # State and Behavior Going back to object-oriented concepts, a **lambda expression** that is treated as a first-class citizen in a language is best described by what statement? 1. [X] Behavior as State 1. [ ] State only 1. [ ] Behavior only 1. [ ] State as Behavior # Readability True or false: in general, using lots of lambda expressions in code makes it easier for novice developers to understand the code? 1. [X] False 1. [ ] True