Look up or insert new element to string list in Haskell
- by nightscream
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