Pure Functions

Functional programming is the central theme of JAX. This lesson will shed some light on what exactly this means.

Functional programming (FP)

Functional programming is a paradigm focused on functions. It’s okay if you are unfamiliar with functional programming because JAX mainly centers around just one of its key features.

Pure functions

Pure functions are similar to mathematical functions and have the following properties:

  1. Identical outputs: No matter how many times we run the function, it gives the same output for the same tuple of inputs.
  2. No side-effects: The function doesn’t change any variable other than variables in its local scope.


Here is a basic example of a pure function:

Get hands-on with 1000+ tech skills courses.