movex [] a s = []
movex (x:xs) a s
| elem a x = moveNow x a s
| otherwise = x : (movex xs a s)
where
moveNow x a s
| s == 'l' = moveNow2 x a
where
moveNow2 [] _ = []
moveNow2 (x:y:xs) a
| x == ' ' && y == a = a : x : moveNow2 (y:xs) a
| otherwise = x : moveNow2 (y:xs) a
<- This is what I got right now
I am trying to make a function that iterates through [string], finds the right string and then mutates it.
given input
func ["abc", "dfg"] f l -- move f in this list 1 space left --
expected output
["abc", "fdg"]
Right now I am stuck at movex function that gives me error
Couldn't match expected type `Char' with actual type `[Char]'
In the first argument of `(:)', namely `x'
In the expression: x : (movex xs a s)
| elem a x = moveNow x a sbut what about xs? How can you drop it? Perhaps try giving your functions explicit type signatures.x==' '?x==' 'is to check whether x is a space character or not