Difference between revisions of "Pure function"

From CS 61A Wiki
Redirect page
Jump to: navigation, search
[checked revision][checked revision]
(add)
(Redirected page to Function#Pure function)
 
Line 1: Line 1:
A '''pure function''' produces no effects other than returning a value. Its return value depends only on the inputs. Given the same arguments, it always returns the same value.
+
#REDIRECT [[Function#Pure function]]
 
+
Contrast a pure function with a [[non-pure function]].
+
 
+
== Examples ==
+
*<code>add</code> always returns the sum of the arguments and has no side effects.
+
*<code>square</code>
+
 
+
== Sources ==
+
* 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/su12/discussion/discussion10/discussion10.pdf
+

Latest revision as of 15:54, 31 May 2014