Re: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Carajillu
Definitely I'll take this solution, I'm reading about Pointfree, I think it's not that dificult to understand. And moreover it's the simpliest way to write code. Jón Fairbairn-2 wrote: > > Andrea Rossato <[EMAIL PROTECTED]> writes: > >> On Mon, Sep 18, 2006 at 04:16:55AM -0700, Carajillu wrote

Re: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Andrea Rossato
On Mon, Sep 18, 2006 at 05:35:47AM -0700, Carajillu wrote: > I'm testing it and it's working really well. The other solutions are a > little complicated for me, but I'm still trying to undestand them. Jón's approach (the last version of his message), usually cleaner and more concise, is called poi

Re: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Andrea Rossato
On Mon, Sep 18, 2006 at 02:52:45PM +0200, Andrea Rossato wrote: > On Mon, Sep 18, 2006 at 05:42:47AM -0700, Carajillu wrote: > > > > Not a good solution, it just substitutes the first occurrence of the item in > > the list. I'll try the others > > I did not get this point. > You must take Jón's a

Re: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Andrea Rossato
On Mon, Sep 18, 2006 at 05:42:47AM -0700, Carajillu wrote: > > Not a good solution, it just substitutes the first occurrence of the item in > the list. I'll try the others I did not get this point. You must take Jón's approach with map. andrea ___ Haske

Re[2]: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Bulat Ziganshin
Hello Andrea, Monday, September 18, 2006, 3:22:43 PM, you wrote: > substitute e l1 l2= [c | c <- check_elem l1] why not just substitute e l1 l2= check_elem l1 ? :) > where check_elem [] = l1 should be where check_elem [] = [] otherwise you just append second (backup? :) copy of or

Re: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Carajillu
Not a good solution, it just substitutes the first occurrence of the item in the list. I'll try the others Carajillu wrote: > > Finally I took Andrea's solution "check_elem (x:xs) = if x == e then (l2 > ++ xs) else [x] ++ check_elem xs" > I think it's easy to understand for me ( in my noob level

Re: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Carajillu
Finally I took Andrea's solution "check_elem (x:xs) = if x == e then (l2 ++ xs) else [x] ++ check_elem xs" I think it's easy to understand for me ( in my noob level), than the recursive one. I'm testing it and it's working really well. The other solutions are a little complicated for me, but I'm

Re: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Bulat Ziganshin
Hello Carajillu, Monday, September 18, 2006, 1:51:34 PM, you wrote: > Hi, I'm a student and I have to do a program with Haskell. This is the first > time I use this languaje, and I'm having problems with the indentation. I > want to check if this function is correct, but when I try to make the GH

Re: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Andrea Rossato
On Mon, Sep 18, 2006 at 12:25:21PM +0100, Neil Mitchell wrote: > Why not: > > check_elem (x:xs) = if x == e then (l2 ++ xs) else x : check_elem xs > > Thanks Thank you! Lists are my personal nightmare...;-) Andrea ___ Haskell-Cafe mailing list Haskell

Re: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Neil Mitchell
Hi check_elem (x:xs) = if x == e then (l2 ++ xs) else [x] ++ check_elem xs Why not: check_elem (x:xs) = if x == e then (l2 ++ xs) else x : check_elem xs Thanks Neil ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http:

Re: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Andrea Rossato
On Mon, Sep 18, 2006 at 04:16:55AM -0700, Carajillu wrote: > > Wow! I'm starting to love this languaje, and the people who uses it!:) > You spoke too early. My code had a bug, a huge one... this is the right one: -- Replaces a wildcard in a list with the list given as the third argument substi

Re: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Carajillu
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

Re: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Andrea Rossato
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

Re: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Ketil Malde
Carajillu <[EMAIL PROTECTED]> writes: > I get "line 18:parse error (possibly incorrect indentation)" ..which is a bit misleading, as the problem is on the preceeding line of code. > if x == e then return l2 And if x /= e? What is check_elem then?¹ > -- Tries to match two lists

Re: [Haskell-cafe] Problems interpreting

2006-09-18 Thread Andrea Rossato
On Mon, Sep 18, 2006 at 02:51:34AM -0700, Carajillu wrote: > > Hi, I'm a student and I have to do a program with Haskell. This is the first > time I use this languaje, and I'm having problems with the indentation. I > want to check if this function is correct, but when I try to make the GHCi > int

[Haskell-cafe] Problems interpreting

2006-09-18 Thread Carajillu
Hi, I'm a student and I have to do a program with Haskell. This is the first time I use this languaje, and I'm having problems with the indentation. I want to check if this function is correct, but when I try to make the GHCi interpret it, I get "line 18:parse error (possibly incorrect indentation