[Haskell-cafe] Java or C to Haskell

2006-09-20 Thread Carajillu
I'm trying to write in Haskell a function that in Java would be something like this: char find_match (char[] l1, char[] l2, char e){ //l1 and l2 are not empty int i = 0; while (l2){ char aux = l2[i]; char[n] laux = l2;

Re: [Haskell-cafe] Java or C to Haskell

2006-09-20 Thread Carajillu
wow, the simpliest ever! Andrea Rossato wrote: On Wed, Sep 20, 2006 at 01:31:22AM -0700, Carajillu wrote: compare function just compares the two lists and return true if they are equal, or false if they are not. it is really a simple function, but I've been thinking about it a lot

Re: [Haskell-cafe] Java or C to Haskell

2006-09-20 Thread Carajillu
That works good, but I have a problem with the return type, I forgot to mention... can it be a [char]?? Donald Bruce Stewart wrote: crespi.albert: I'm trying to write in Haskell a function that in Java would be something like this: char find_match (char[] l1, char[] l2, char e){

Re: [Haskell-cafe] Java or C to Haskell

2006-09-20 Thread Carajillu
Yes, they must be equal the whole way, I like this recursive solution :) Ketil Malde-3 wrote: 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*ha 4*5a 'h' returns '5' (5

[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

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 C for

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 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
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