# pure function

This is a page from my book, Functional Programming, Simplified

## Functional Programming is Like Algebra

Some advanced Lispers will cringe when someone says that a function “returns a value.” This is because Lisp derives from something called lambda calculus, which is a fundamental programming-like algebra developed by Alonzo Church.

This is a page from my book, Functional Programming, Simplified

## Pure Function Signatures Tell All

“In Haskell, a function’s type declaration tells you a whole lot about the function, due to the very strong type system.”

Learn You a Haskell for Great Good!

One thing you’ll find in FP is that the signatures of pure functions tell you a lot about what those functions do. In fact, it turns out that the signatures of functions in FP applications are much more important than they are in OOP applications. As you’ll see in this lesson:

This is a page from my book, Functional Programming, Simplified

## The Definition of “Pure Function”

“When a function is pure,
we say that ‘output depends (only) on input.’”

From the book, Becoming Functional
(with the word “only” added by me)

## Goals

This lesson has two goals:

This is a page from my book, Functional Programming, Simplified

## The “Great FP Terminology Barrier”

“They say no ship can survive this.”

Hikaru Sulu, talking about “The Great Barrier”
(Star Trek V: The Final Frontier)

## A short excursion to ... The Twilight Zone

Hello, Rod Serling of The Twilight Zone here. Al will be back shortly, but for now, let me take you to another place and time ... an alternate universe ...

This is a page from my book, Functional Programming, Simplified

## What is “Functional Programming”?

“Object-oriented programming makes code understandable by encapsulating moving parts. Functional programming makes code understandable by minimizing moving parts.”

Michael Feathers, author of
Working Effectively with Legacy Code

This is a page from my book, Functional Programming, Simplified

## Rules for Programming in This Book

“Learn the rules like a pro, so you can
break them like an artist.”

Pablo Picasso

“Learn the rules, and then forget them.”
Haiku Master Matsuo Basho

Alright, that’s enough of the “preface” material, let’s get on with the book!

As I wrote earlier, I want to spare you the route I took of, “You Have to Learn Haskell to Learn Scala/FP,” but, I need to say that I did learn a valuable lesson by taking that route:

This is a page from my book, Functional Programming, Simplified

## Question Everything

“I have no special talent. I am only passionately curious.”

Albert Einstein

A Golden Rule of this book is to always ask, “Why?” By this I mean that you should question everything I present. Ask yourself, “Why is this FP approach better than what I do in my OOP code?” To help develop this spirit, let’s take a little look at what FP is, and then see what questions we might have about it.