Carajillu <[EMAIL PROTECTED]> writes:

> compare function just compares the two lists and return true if they are
> equal, or false if they are not.

> find_match "4*h&a" "4*5&a" 'h' ----> returns '5' (5 matches with the h)
> find_match "4*n&s" "4dhnn" "k" ----> returns ''  (no match at all - lists
> are different anyway)

Must they be equal the whole way, or just up to the occurrence of the
searched-for character?

  find_match (x:xs) (y:ys) c | x==c = Just y 
                             | x/=y = Nothing
                             | True = find_match xs ys c
  find_match [] [] _ = Nothing

Or, to check the whole list:

  find_match (x:xs) (y:ys) c | x==c && xs == ys = Just y 
                             | x/=y = Nothing
                             | True = find_match xs ys c
  find_match [] [] _ = Nothing

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to