Pure function

From CS 61A Wiki
Revision as of 16:06, 25 May 2014 by Axis (Talk | contribs)


Jump to: navigation, search

A pure function produces no effects other than returning a value. It cannot depend on external state (i.e., given the same arguments, it always returns the same value).

Contrast a pure function with a non-pure function.

Examples

  • add
  • square

Sources