[Haskell-cafe] Java or C to Haskell

Carajillu crespi.albert at gmail.com
Wed Sep 20 05:22:29 EDT 2006


Yes, they must be equal the whole way, I like this recursive solution :)

Ketil Malde-3 wrote:
> 
> Carajillu <crespi.albert at gmail.com> 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 at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 
> 

-- 
View this message in context: http://www.nabble.com/Java-or-C-to-Haskell-tf2303820.html#a6404344
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.



More information about the Haskell-Cafe mailing list