[Haskell-cafe] Pattern matching problems
Marcin Tustin
mm3 at zepler.net
Fri Sep 23 20:27:21 EDT 2005
In case I confused anyone, this is a separate issue. Thanks for your attention and help.
On Sat, Sep 24, 2005 at 01:20:22AM +0100, Marcin Tustin wrote:
>
> For some reason the following code is producing an error message from ghci that the the patterns are non-exhaustive. Does anyone have any idea why that could be, given that the patterns are, at least in my meaning, provably exhaustive?
>
> choosenonuniqueset n (a:r)
> | (length r) > (n-1) = [ (sort (a:x)) | x <- (choosenonuniqueset (n-1) r)]
> `union`
> [ (sort (a:x)) | x <- (choosenonuniqueset n r)]
> | (length r) == (n-1) = [a:r]
> | (length r) < (n-1) = []
>
> Error message is:
>
> *Main> :reload
> Compiling Main ( birthday.hs, interpreted )
> Ok, modules loaded: Main.
> *Main> choosenonuniqueset 2 [1..5]
> *** Exception: birthday.hs:(22,0)-(27,29): Non-exhaustive patterns in function choosenonuniqueset
>
> *Main> choosenonuniqueset 5 [1..5]
> [[1,2,3,4,5]]
> *Main>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
More information about the Haskell-Cafe
mailing list