Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Haskell: Comparison operators

Comparison operators determine if one operand is greater than, less than, Equal to, or not equal to another operand.


Operator
Description
Example
==
Equal to

a==b Returns True if a is equal to b, else false
/=
Not equal to

a/=b returns true if a is not equal to b, else false.
>
Greater than
a>b returns true, if a is > b, else false
>=

Greater than or equal to
a>=b returns true, if a is >= b, else false.
<
Less than
a<b returns true, if a is < b, else false.
<=

Less than or equal to
a<=b returns true, if a is <= b, else false.

*Main> let a = 10
*Main> let b = 12
*Main>
*Main> a == b
False
*Main> a /= b
True
*Main> a > b
False
*Main> a < b
True
*Main> a >= b
False
*Main> a <= b
True

Operators are implemented as functions internally.

10 == 12 is represented as '(==) 10 12', note that the function name must be enclosed in parenthesis.
*Main> (==) 10 12
False
*Main> (/=) 10 12
True
*Main> (>) 10 12
False
*Main> (<) 10 12
True
*Main> (>=) 10 12
False
*Main> (<=) 10 12
True




Previous                                                 Next                                                 Home


This post first appeared on Java Tutorial : Blog To Learn Java Programming, please read the originial post: here

Share the post

Haskell: Comparison operators

×

Subscribe to Java Tutorial : Blog To Learn Java Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×