Saturday, 4 June 2016

Haskell: Check whether three numbers are in ascending order (or) not


Sample.hs
isAscending :: Int -> Int -> Int -> Bool
isAscending x y z = (x <= y) && (y <= z)

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



Previous                                                 Next                                                 Home

No comments:

Post a Comment