andyferris / Dictionaries.jl

An alternative interface for dictionaries in Julia, for improved productivity and performance
Other
278 stars 28 forks source link

term "idempotent" might not apply #47

Closed goretkin closed 3 years ago

goretkin commented 3 years ago

It seems like "f is idempotent" is being used to mean f(..., x) == x, but I understand it to mean (at least when describing a function) that f(f(x)) = f(x). I see that there is perhaps also a notion of "idempotent element of a set", which I am not familiar with.

Unfortunately, I do not have a term to suggest for this. "f is the identity function after partial application" doesn't roll off the tongue.

andyferris commented 3 years ago

Yeah the terminology is awkward.

A dictionary is just a finite "map" in the mathematical sense. A map being a function. For a dictionary you give this function the index and it gives you back the value. For AbstractIndices this function is the identity function where the domain is the valid indices. In Julia code, yes the Function we are talking about is f = index -> getindex(dict, index), but in colloquial mathematical discussion it suffices to discuss dictionaries as isomorphic to functions (as they are just two synonyms for maps).

It is the keys function that is idempotent, so keys(keys(dict)) = keys(dict).

I'm not sure - can you think of a better way to describe it?

goretkin commented 3 years ago

I admit I had missed the keys(keys(dict)) = keys(dict) property, which does indeed match my understanding of "idempotent. Thanks for humoring the pedantry. I'd say the PR closes this issue.

andyferris commented 3 years ago

Thanks :)