Re: [Haskell-cafe] elemt from list

2004-01-27 Thread Ketil Malde
Pajo Patak [EMAIL PROTECTED] writes: I want to return a list, from and list of lists (all integers), where is the erroe in the code? nthList :: [[a]] - Int - [a] nthList ([x]:xs) 1 = [x] nthList ([x]:xs) (n+1) = nthListh xs n Did you try it at all? Prelude let { nthList ([x]:xs) 1

RE: [Haskell-cafe] elemt from list

2004-01-27 Thread Bayley, Alistair
There is a Prelude function !! which I think would do what you want: http://haskell.org/ghc/docs/latest/html/libraries/base/Data.List.html#v%3A! ! You may find other useful list functions in this library... -Original Message- From: Pajo Patak [mailto:[EMAIL PROTECTED] Sent: 27

Re: [Haskell-cafe] elemt from list

2004-01-27 Thread Christian Maeder
The pattern [x] only matches singleton lists. Pajo Patak wrote: I want to return a list, from and list of lists (all integers), where is the erroe in the code? nthList :: [[a]] - Int - [a] nthList ([x]:xs) 1 = [x] nthList ([x]:xs) (n+1) = nthListh xs n

[Haskell-cafe] Simple Maybe question

2004-01-27 Thread Jim Lewis
I'm new to Haskell and can't find an example to solve a trivial problem. I have code like this: findBlank :: [] - Int findBlank str = findIndex (==' ') str But interpreter complains elsewhere of mismatch of Int with Maybe Int. I want to handle the maybe only here and nowhere else. This just

Re: [Haskell-cafe] Simple Maybe question

2004-01-27 Thread Mark Carroll
On Tue, 27 Jan 2004, Jim Lewis wrote: I'm new to Haskell and can't find an example to solve a trivial problem. I have code like this: findBlank :: [] - Int findBlank str = findIndex (==' ') str But interpreter complains elsewhere of mismatch of Int with Maybe Int. I want to handle the

[Haskell-cafe] Interpreting fields in a buffer

2004-01-27 Thread Dominic Steinitz
I looked at the Erlang syntax when I wrote my helper functions and I agree it is very nifty. I didn't have the time to investigate how to do it in Haskell but it would be disappointing if it (or something like it) couldn't be done. Dominic. Mikael, Thanks, that's very helpful and seems to be

Re: [Haskell-cafe] Interpreting fields in a buffer

2004-01-27 Thread Jeremy Shaw
Hello, I just wanted to chime in with a 'me too' in regards to this whole thread. Many of the programs I want to write involve reading and writing binary file formats, and writing the code to actually do that tends to be the ugliest, most error prone, boring part of the whole program. I have not