Referential Transparency

Published: 1/18/2020
Last edited: 1/26/2020

A function which (when invoked with all inputs) can be replaced in all instances without changing the program's behavior.

const times = a => b => a * b
const double = times(2)
const ten = double(5) 
const four = double(2) 
const forty = times(ten)(four)
times(ten)(four) === times(times(2)(5))(times(2)(2))
// === times(2 * 5)(2 * 2)
// === 2 * 5 * 2 * 2
Published: 1/18/2020
Last edited: 1/26/2020
See this page on Github
Built with 💛 by Open Sorcerers
Created with Gatsby using the 😎 foresight starter