In fold function in functional paradigm, we pass and accumulator value which is generally initialized as the identity element of the operator the function applies.
Like for addition over a list it will be 0, for multiplication 1, and so on.
i.e., +(0, a) = a
and
*(1, a) = a
So what it will be for mod operator %(identity, a) = a?
Mod will be from [0,a)
so identity does not seem to be possible.
I understand that computers don't necessarily follow the mathematical definition of modulus.
Moreover do all operators have an identity element or it is dependent on some specific properties that the operator should have?
And is there any generalised way to find the identity element of any operator?
My questions are:
- What is identity element for modulus operator if it exists? %(identity, a) = a
- Are there any specific properties that the operator must follow to have an identity?
- Is there a general way to find the identity of an operator if it has an identity.