Just a quick disclaimer I have been learning Haskell for about a month and have been reading, watching and searching the web but I just cant get my head around this.
So my question is, I want to compare two strings say "p16201348" & "p16202068" and basically check that the first two numbers after the p are from the year 2016 so 16. In my first example below i'm just using the same lists to compare. When I input this into ghci then it evaluates to true as you would expect. My problem is actually writing this as a callable function.
"p16201348" !! 1 == '1' && "p16201348" !! 1 == '1' && "p16201348" !! 2 == '6' && "p16201348" !! 2 == '6'
My first attempt at writing the function is below, as I said the p is irrelevant so from what I understand I split the list into x:xs butt disregard the head which ends up being _:xs and _:ys. When I try and call this I get the ambiguous occurrence.
compare (_:xs) (_:ys) = xs !! 1 == '1' && ys !! 1 == '1' && xs !! 2 == '6' && ys !! 2 == '6'
My final function (protptype) is using a guarded equation, although im not even sue if it is possible to split a list and then evaluate certain elements within it
compare (_:xs)(_:ys)
| xs !! 1 == '1' && ys !! 1 == '1' && xs !! 2 == '6' && ys !! 2 == '2' = "Same Year"
| otherwise = "Different year"
Thanks in advance for any help.