Tuesday, March 27, 2012

Mathematical invariance

The no-effect? predicate returns true if the specified function doesn't apply to some value. The no-effect? predicate can be used to establish many other predicates, for example each part function can establish a predicate:
(def int? (partial no-effect? int))
(def unit-vector? (partial no-effect? unit-vector-part))
(def non-negative? (partial no-effect? (fn [i] (Math/abs i)))
An understanding of the no-effect? predicate can be used to eliminate unnecessary calls to one-way functions.

No comments:

Post a Comment