klequis / zz-haskell-notebook

Notes from learning Haskell
1 stars 0 forks source link

identity element #76

Open klequis opened 2 years ago

klequis commented 2 years ago

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

Example: Lists

-- left
[]  ++ [1,2,3] = [1,2,3]

-- right
[1,2,3] ++ [] = [1,2,3]