[Haskell-cafe] Problems interpreting

Carajillu crespi.albert at gmail.com
Mon Sep 18 07:16:55 EDT 2006


Wow! I'm starting to love this languaje, and the people who uses it!:)


Andrea Rossato wrote:
> 
> On Mon, Sep 18, 2006 at 12:54:34PM +0200, Albert Crespi wrote:
>> Thank you very much for your reply!
>> As I said, it is my first experience with Haskell, I have been
>> programming
>> in Java and C for some years, and I find this language very different
>> from
>> them. Anyway I'll try to fix the function with the information that you
>> gave
>> me.
>> Thanks again!
>> 
> You're welcome.
> 
> By the way, this is what the comments say you are trying to do:
> 
> -- Replaces a wildcard in a list with the list given as the third argument
> substitute :: Eq a => a -> [a] -> [a] -> [a]
> substitute e l1 l2= [c | c <- check_elem l1]
>     where check_elem [] = l1
>           check_elem (x:xs) = if x == e then (l2 ++ xs) else check_elem xs
> 
> This is the result:
> 
> *Main> substitute 1 [1,2,3] []
> [2,3]
> *Main> substitute 1 [1,2,3] [7,8,9]
> [7,8,9,2,3]
> *Main>     
> 
> Have fun with Haskell.
> 
> Ciao
> Andrea
> _______________________________________________
> 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/Problems-interpreting-tf2290155.html#a6361815
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.



More information about the Haskell-Cafe mailing list