Open klequis opened 2 years ago
In math: Is an element of a set that when applied in a binary operation, leaves unchanged every element in the set.
Zero (0) is the identity element for addition.
A = {1,2,3} Apply +0 to each element of A to produce B B = {1,2,3}
source: https://en.wikipedia.org/wiki/Identity_element
x <> mempty = x
mempty <> x = x
mempty
Example: Lists
mappend
++
[]
-- left [] ++ [1,2,3] = [1,2,3] -- right [1,2,3] ++ [] = [1,2,3]
Identity Element
In math: Is an element of a set that when applied in a binary operation, leaves unchanged every element in the set.
Zero (0) is the identity element for addition.
A = {1,2,3} Apply +0 to each element of A to produce B B = {1,2,3}
source: https://en.wikipedia.org/wiki/Identity_element
Left & Right Identity in Haskell
x <> mempty = x
mempty <> x = x
mempty
is the identity element.Example: Lists
mappend
is++
[]