hello there,
To be honest I'm not very familiar with haskell and stuff
so don't laugh with my question...
here it goes..
We can represent a matrix as a list of lists...
which means that
1 2 3
4 7 6
2 5 1
could be written as follows:
cris cris wrote:
We can represent a matrix as a list of lists...
which means that
1 2 3
4 7 6
2 5 1
could be written as follows: [[1,2,3],[4,7,6],[2,5,1]]
The question is how can I reverse the matrix (each row becomes a column)
Sounds like homework time again.
At the risk of being
1. Haskell 98 does not explicitly mandate tail recursion optimisation.
However, in practice Haskell compilers must provide this since it is
impossible to write a loop without using recursion and if your loops
don't use constant stack space, you're not going to run for very long.
(In
G'day all.
On Thu, Jan 02, 2003 at 08:39:18AM +, Alastair Reid wrote:
Please note that this is NOT TRUE!
Whoops, you're right. Sorry, my mistake.
Cheers,
Andrew Bromage
___
Haskell mailing list
[EMAIL PROTECTED]
On Wed, 1 Jan 2003, Andrew J Bromage wrote:
G'day all.
On Mon, Dec 30, 2002 at 01:47:37PM -0600, Artie Gold wrote:
One suggestion, though is that you're working too hard; there's really
no reason to define a locally defined function. The much simpler:
long [] = 0
long (x:xs) = 1 +
G'day all.
On Wed, 1 Jan 2003, Andrew J Bromage wrote:
It has quite different performance characteristics, though. In
particular, this uses O(n) stack space whereas the accumulator one
uses O(1) stack space.
On Wed, Jan 01, 2003 at 12:17:10PM +0200, Shlomi Fish wrote:
This is assuming
G'day all.
On Mon, Dec 30, 2002 at 01:47:37PM -0600, Artie Gold wrote:
One suggestion, though is that you're working too hard; there's really
no reason to define a locally defined function. The much simpler:
long [] = 0
long (x:xs) = 1 + long xs
will do quite nicely.
It has quite
Hello! I'm Working with Lists in Haskell, I´m a Beginner in Functional Programming and I would like to know if there isa way to write a more efficient function that return the length of a list, I wrote this one:
long :: [a]-Intlong p = longitud p 0 where longitud [] s=s longitud (x:xs) s=longitud
Hi Cesar
If you check the prelude, you will find the definition (something like):
length::[a]-Int
length= foldl' (\n _ - n + 1) 0
and the definition of foldl'
foldl' :: (a - b - a) - a - [b] - a
foldl' f a [] = a
foldl' f a (x:xs) = (foldl' f $! f a x) xs
Which also
On Mon, 30 Dec 2002, Cesar Augusto Acosta Minoli wrote:
Hello! I'm Working with Lists in Haskell, I´m a Beginner in Functional
Programming and I would like to know if there is a way to write a more
efficient function that return the length of a list, I wrote this one:
long :: [a]-Int
Cesar Augusto Acosta Minoli wrote:
Hello! I'm Working with Lists in Haskell, I´m a Beginner in Functional
Programming and I would like to know if there is a way to write a more
efficient function that return the length of a list, I wrote this one:
long:: [a]-Int
long p =
On Mon, Dec 30, 2002 at 01:47:37PM -0600, Artie Gold wrote:
One suggestion, though is that you're working too hard; there's really
no reason to define a locally defined function. The much simpler:
long [] = 0
long (x:xs) = 1 + long xs
will do quite nicely.
HTH,
--ag
There is already a
long = sum . map (const 1)
How's this?
/JongKeun
-Original Message-
From: William Lee Irwin III [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 31, 2002 5:18 AM
To: Artie Gold
Cc: Cesar Augusto Acosta Minoli; [EMAIL PROTECTED]
Subject: Re: Question About lists
On Mon, Dec 30, 2002
13 matches
Mail list logo