Concept:
Equality
Headline
Some kind of equality in programming
Illustration
Let us focus here on equality of data as it is used in programming. Different kinds of equality exist: structural equality, semantic equality, reference equality, and possibly others. For example, trivially, the following equalities or inequalities hold as demonstrated at the interpreter prompt of Language:Haskell:
> 42 == 42
True
> 42 == 41
False
> True == True
True
> "Foo" == "Bar"
False
In various programming languages, equality may be defined by the programmer. For instance, Language:Haskell designates a type class Eq to equality (readily defined in the Haskell Prelude:
-- A type class for equality
class Eq a
where
(==) :: a -> a -> Bool
For instance, equality of Booleans would be defined by the following type-class instance:
-- Equality of Booleans
instance Eq Bool
where
True == True = True
False == False = True
_ == _ = False
More interestingly, equality of lists would be defined such that the two lists need to be of the same length and their elements need to be equal in a pairwise manner; thus we also need equality for the element type, which is expressed by the extra constraint in the instance:
-- Equality of lists
instance Eq a => Eq [a]
where
x == y = length x == length y
&& and (map (uncurry (==)) (zip x y))
There are no revisions for this page.
User contributions
User edits
Syntax for editing wiki
For you are available next options:will make text bold.
will make text italic.
will make text underlined.
will make text striked.
will allow you to paste code headline into the page.
will allow you to link into the page.
will allow you to paste code with syntax highlight into the page. You will need to define used programming language.
will allow you to paste image into the page.
is list with bullets.
is list with numbers.
will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.
will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.
will allow your to insert code snippets from @worker.
Syntax for editing wiki
For you are available next options:will make text bold.
will make text italic.
will make text underlined.
will make text striked.
will allow you to paste code headline into the page.
will allow you to link into the page.
will allow you to paste code with syntax highlight into the page. You will need to define used programming language.
will allow you to paste image into the page.
is list with bullets.
is list with numbers.
will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.
will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.
will allow your to insert code snippets from @worker.