I have 2 words with the same length, for example: "mother" and "father". My program should:
a) if the letter in the x position in the first word is the same as in the x position in the second word: the letter should stay on its place
b) if the letter in the x position in the first word isn't the same as in the x position in the second word: the letter should be replaced with sign "-"
function mother father
--result "--ther"
So far I made this:
function :: (Eq a) => [a] -> [a] -> [a]
function [] [] = []
function [x] [] = [x]
function [] [x] = [x]
function (x:xs) (y:ys) = if x == y
then x : function xs ys
else
"-" : function xs ys
It gives error
Couldn't match type `a' with `[Char]
I have no clue how make last line works. Do you have any idea what should I do here?