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