Difference between revisions of "Pure function"

From CS 61A Wiki
Jump to: navigation, search
[unchecked revision][unchecked revision]
m (sources)
(use definition from su12 disc10)
Line 1: Line 1:
A '''pure function''' just returns a value. Given the same arguments, it returns the same value. An example is the <code>add</code> function.
+
A '''pure function''' produces no effects other than returning a value. Given the same arguments, it returns the same value. An example is the <code>add</code> function.
  
 
== Sources ==
 
== Sources ==
 
* http://inst.eecs.berkeley.edu/~cs61a/sp14/slides/02_6pp.pdf
 
* http://inst.eecs.berkeley.edu/~cs61a/sp14/slides/02_6pp.pdf
 
* http://inst.eecs.berkeley.edu/~cs61a/sp14/disc/discussion01.pdf
 
* http://inst.eecs.berkeley.edu/~cs61a/sp14/disc/discussion01.pdf
 +
* http://inst.eecs.berkeley.edu/~cs61a/su12/discussion/discussion10/discussion10.pdf

Revision as of 15:57, 25 May 2014

A pure function produces no effects other than returning a value. Given the same arguments, it returns the same value. An example is the add function.

Sources