6FUNCTIONAL PROGRAMMING

Image

In many ways, the concepts of functional programming predate programming itself. This paradigm is strongly based on the l-calculus invented by Alonzo Church in the 1930s.

SQUARES OF INTEGERS

To explain what functional programming is, it’s best to examine some examples. Let’s investigate a simple problem: printing the squares of the first 25 integers.

In a language like Java, we might write the following:

public class Squint {   public static void main(String args[]) {     for (int i=0; i<25; i++)       System.out.println(i*i);   } }

In a language like Clojure, which is a derivative of Lisp, ...

Get Clean Architecture: A Craftsman's Guide to Software Structure and Design now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.