Reputation: 1658
If given list of numbers [3,1,4,6,2] -> I increase every odd element by 1 and decrease every even element by 1 I should get [4,0,5,5,3]
my code is
change [] = []
change (x:y:xs) = (x+1)(y-1):change xs
I write function change with a base case where if list is null it returns null list and then it recursively increases every odd elment by 1 and decrease all even indexed elements by 1 and pushes them back to the list
However I get a pattern matching error. What have I done wrong? And how can this be fixed?
Upvotes: 0
Views: 59