A pure function is one that always evaluates to the same thing given the same arguments, and cannot change or depend on any external state.
10
votes
5answers
531 views
Compute if a function is pure
As per Wikipedia:
In computer programming, a function may be described as pure if both these statements about the function hold:
The function always evaluates the same result value given the ...
2
votes
3answers
1k views
Is this method pure?
I have the following extension method:
public static IEnumerable<T> Apply<T>(
[NotNull] this IEnumerable<T> source,
[NotNull] Action<T> action)
...
1
vote
2answers
152 views
When to use [Pure] on a constructor?
I'm learning about code contracts in .NET, and I'm trying to understand the idea of pure constructors. The code contracts documentation states:
All methods that are called within a contract must ...