Dear Haskell friends,
what can I do, if a function gets an empty input list? I want, that it only
returns nothing.
This is my source code:
tmp:: [(Int, Int)] -> Int -> (Int, Int)
tmp (x:xs) y
| y == 1 = x
| y > 1 = tmp xs (y-1)
If this function gets an empty list, he throws "Exception:
sortAlgo.hs:(18,1)-(21,44): Non-exhaustive patterns in function Main.tmp"
*Main> tmp [(1,2),(3,2)] 1
(1,2)
*Main> tmp [(1,2),(3,2)] 2
(3,2)
*Main> tmp [] 1
*** Exception: sortAlgo.hs:(20,1)-(22,44): Non-exhaustive patterns in function
Main.listElementIntInt
Thank you for any help !
Best regards
Kevin
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe