Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
25
Task/Sort-three-variables/Haskell/sort-three-variables.hs
Normal file
25
Task/Sort-three-variables/Haskell/sort-three-variables.hs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import Data.List (sort)
|
||||
|
||||
sortedTriple
|
||||
:: Ord a
|
||||
=> (a, a, a) -> (a, a, a)
|
||||
sortedTriple (x, y, z) =
|
||||
let [a, b, c] = sort [x, y, z]
|
||||
in (a, b, c)
|
||||
|
||||
sortedListfromTriple
|
||||
:: Ord a
|
||||
=> (a, a, a) -> [a]
|
||||
sortedListfromTriple (x, y, z) = sort [x, y, z]
|
||||
|
||||
-- TEST ----------------------------------------------------------------------
|
||||
main :: IO ()
|
||||
main = do
|
||||
print $
|
||||
sortedTriple
|
||||
("lions, tigers, and", "bears, oh my!", "(from the \"Wizard of OZ\")")
|
||||
print $
|
||||
sortedListfromTriple
|
||||
("lions, tigers, and", "bears, oh my!", "(from the \"Wizard of OZ\")")
|
||||
print $ sortedTriple (77444, -12, 0)
|
||||
print $ sortedListfromTriple (77444, -12, 0)
|
||||
Loading…
Add table
Add a link
Reference in a new issue