
6 Jan
2008
6 Jan
'08
1:45 p.m.
On Jan 6, 2008 4:40 PM, Jonathan Cast
let is always recursive in Haskell, so this is a recursive definition of pos. To break the recursion, use
matchReverse (x:xs) (y:ys) pos = let (matched, pos') = matchReverse xs ys (pos + 1) in if matched then ((x==y), pos') else (False, pos')
Actually, I think he meant matchReverse (x:xs) (y:ys) pos = let (matched, pos') = matchReverse xs ys (pos + 1) in if matched then ((x==y), pos) else (False, pos') As as side note, GHC's flag -Wall would have warned about creating a variable with a name already in scope. -- Felipe.