Hacker News new | ask | show | jobs
by o11c 920 days ago
One irritating thing is that there are at least 4 different senses of "idempotent" in the wild:

* In the object-oriented sense, `obj.f(args...)` does not mutate `obj` after the first time.

* For pure unary functions, `f∘f === f` - that is, repeated application does not change the result, e.g. `abs(abs(x)) === abs(x)`

* For pure binary functions, `f(x, x) === x`. I'm not sure how useful this is but it seems to be used in math.

* For pure binary functions, `f(x, a) === x` and/or `f(a, x) === x`. These would probably be individually called left-idempotent and right-idempotent in some order, along with two-sided idempotent for the combination (akin to left identity (related!), left inverse, etc.); notably these are more general than (and all imply) the above. This could be extended to further arities; usually the preserved element will be either first or last in sane functions. "and not" works in one direction; many functions like "bitwise and", "bitwise or", "min", and "max" work in both directions.

1 comments

Sense 2 is an example of sense 3, where the binary function is ∘.