Pure functions, as defined by Functional Programming, can provide a simple set of rules for one to follow to improve code testability.

🤔 What are pure functions?

Pure functions, when called with a given input, compute and return output and do nothing else. It’s a mapping of values to values.
Pure functions should verify these three rules:

  • total: there’s a result for any possible input
  • deterministic: the result will always be the same if the input is the same
  • no side-effect: the function does nothing but computing the result

Pure functions are crucial in Functional Programming for “referential transparency”. It allows for composition of functions…

Benjamin Petit

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store