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

Haskell: return two numbers in ascending order

Implement a function, that takes two numbers and return them in Ascending Order.


Sample.hs
type MinMax = (Integer, Integer)

getMinMax :: Integer -> Integer -> MinMax
getMinMax x y = if (x then (x, y) else (y, x)

Prelude> :load Sample.hs
[1 of 1] Compiling Main ( Sample.hs, interpreted )
Ok, modules loaded: Main.
*Main>
*Main> getMinMax 10 20
(10,20)
*Main> getMinMax 20 10
(10,20)
*Main> getMinMax 10 10
(10,10)
*Main>



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: return two numbers in ascending order

×

Subscribe to Java Tutorial : Blog To Learn Java Programming

Get updates delivered right to your inbox!

Thank you for your subscription

×