Functions Made Super Simple

Explained so simply anyone can understand

What is a Function?

A function is like a machine.

You put something in → the machine does something → you get something out

Example:

That machine is a function.

Functions That Take Objects

An object is just a thing.

A function can take a thing and do something to it.

Function: “Add one”
Input: 2
Output: 3

The function takes an object (the number 2) and gives back a new object (3).

Functions That Take Other Functions

Some functions are more powerful.

Instead of taking a thing, they take another function.

Function A: “Add one”
Function B: “Use this function twice”

“Use this function twice” does not care about numbers or apples. It only cares about another function.

This is called a function that takes a function.

Why We Do Not Mix Things Up

You should not give the wrong thing to a function.

This idea was explained by Frege a long time ago. Today, programming languages use the same idea to avoid mistakes.

The Big Idea

Some functions work on things.
Some functions work on other functions.
You must give the right input.