[Haskell-cafe] elementsinlist

Jenny678 mestor1 at gmx.de
Tue Jun 13 18:32:25 EDT 2006


Hallo
I search a code for 

>elements_in_List([1,2],[1,2]). 
>True
>elements_in_List([1,8],[1,2,3,4,8]). 
>True
>elements_in_List([2,1],[1,2]). 
>True
>elements_in_List([1,1],[1]). 
>False

I have a code
elements_in_List :: Eq a => [a] -> [a] -> Bool
elements_in_List [] _ = True
elements_in_List _ [] = False
elements_in_List (x:xs) (y:ys)
 | x == y = elements_in_List xs ys
 | True = elements_in_List (x:xs) ys

but it failed at 
>elements_in_List([2,1],[1,2]). 
>True

I hope somebody can help me 
Please don't use built-in-Functions.

Thanks for Help 


--
View this message in context: http://www.nabble.com/elementsinlist-t1782975.html#a4855615
Sent from the Haskell - Haskell-Cafe forum at Nabble.com.



More information about the Haskell-Cafe mailing list