Look up or insert new element to string list in Haskell
Posted
by
nightscream
on Stack Overflow
See other posts from Stack Overflow
or by nightscream
Published on 2014-06-01T02:37:15Z
Indexed on
2014/06/01
3:26 UTC
Read the original article
Hit count: 92
haskell
So I want to have a function that takes a String and a list as an argument, and checks if that element is already on the list, if it is, returns the same list, if it isnt, adds it to the list and returns it, 'im a begginer with haskell so heres what I have tried with no sucess:
check:: String ->[String] ->[String]
check x [] = []++[x]
check x (y:xs)
| x==y = (y:xs)
| otherwise = check x xs
Can someone point me the way ? thks
© Stack Overflow or respective owner