Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Re: Fast tree manipulation (Stephen Tetley)
2. Fast tree manipulation (Gabi)
3. Re: Fast tree manipulation (Stephen Tetley)
4. Fast tree manipulation (Gabi)
5. Re: Fast tree manipulation (Stephen Tetley)
6. Fast tree manipulation (Gabi)
7. Re: Fast tree manipulation
(Stephen Blackheath [to Haskell-Beginners])
8. wanto post haskell question (???)
----------------------------------------------------------------------
Message: 1
Date: Wed, 3 Feb 2010 12:08:34 +0000
From: Stephen Tetley <[email protected]>
Subject: Re: [Haskell-beginners] Fast tree manipulation
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
Hi Gabi
Performance will depend on the shape of the trees and the nature of
the manipulations, so a general library won't really exist. What data
do you have and what do you want to do with it?
------------------------------
Message: 2
Date: Wed, 3 Feb 2010 14:47:01 +0200
From: Gabi <[email protected]>
Subject: [Haskell-beginners] Fast tree manipulation
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
I plan to implement some form of GP (GeneticProgramming) system.
The trees would represent execution trees which means each node in the
tree will represent a function, and leaves would represent terminals.
An efficient GP system would fail if the tree manipulation operators
(crossover, mutation) are slow.
--
Regards,
Gabi
http://bugspy.net
------------------------------
Message: 3
Date: Wed, 3 Feb 2010 14:42:58 +0000
From: Stephen Tetley <[email protected]>
Subject: Re: [Haskell-beginners] Fast tree manipulation
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
On 3 February 2010 12:47, Gabi <[email protected]> wrote:
> An efficient GP system would fail if the tree manipulation operators
> (crossover, mutation) are slow.
Impeccably true, by definition.
There might some information to be gleaned from following the links here:
http://www.haskell.org/haskellwiki/Applications_and_libraries/Genetic_programming
... but otherwise I can't find anything Haskell related by a quick search.
While its not directly related, Robert Giegerich has done a lot of
work with dynamic programming for Haskell for bio informatics and
checking his work might interesting at least for 'methodology'. A
paraphrase of the conclusion from his paper a decade ago[1] was that
Haskell was invaluable for prototyping but C was essential for speed.
Haskell (GHC) has got a lot faster in the decade since, but it seems
for absolute speed his research group currently use a 'domain-specific
compiler' written in Haskell that generates C. This line of 'off
shore' optimization is a recurring theme in Haskell and has been
explored by Conal Elliott and others for graphics.
Best wishes
Stephen
[1] "An Algebraic Dynamic Programming Approach to the Analysis of
Recombinant DNA Sequences"
http://eref.uqu.edu.sa/files/an_algebraic_dynamic_programming_approac_2173614.pdf
------------------------------
Message: 4
Date: Wed, 3 Feb 2010 17:12:52 +0200
From: Gabi <[email protected]>
Subject: [Haskell-beginners] Fast tree manipulation
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
I might be wrong but I think this is a weak spot for many functional
langs, including Haskell - The ability to manipulate in high rate data
structures without killing the performance . Even in langs like
Clojure, which enable the cheap creation of new modified structures
out of old ones(using "persistent structures") -it is much slower than
using an imperative language to manipulate data in place. What is the
approach of Haskell to this ?
--
Regards,
Gabi
http://bugspy.net
------------------------------
Message: 5
Date: Wed, 3 Feb 2010 17:55:58 +0000
From: Stephen Tetley <[email protected]>
Subject: Re: [Haskell-beginners] Fast tree manipulation
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
Data structures in Haskell are persistent useless you use ST-refs or
similar. Coupled with sharing this can bring some optimizations, e.g.
here:
http://www.haskell.org/pipermail/haskell-cafe/2009-May/061368.html
Admittedly the efficiencies in that message are on somewhat trivial use-cases.
Best wishes
Stephen
------------------------------
Message: 6
Date: Wed, 3 Feb 2010 21:53:18 +0200
From: Gabi <[email protected]>
Subject: [Haskell-beginners] Fast tree manipulation
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
Maybe Data.Sequence is a good option. Seems to be designed to give
good performance when mutating
If trees could be represented using Data.Sequence, I think that tree
manipulation performance would be bearable.
Any other libraries that might be useful?
--
Regards,
Gabi
http://bugspy.net
------------------------------
Message: 7
Date: Thu, 04 Feb 2010 09:08:40 +1300
From: "Stephen Blackheath [to Haskell-Beginners]"
<[email protected]>
Subject: Re: [Haskell-beginners] Fast tree manipulation
To: Gabi <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Gabi,
If the structure is simple enough that it can be represented using
arrays, or if you write it in IO using IORefs, you can do it, but
idiomatic Haskell generally can't perform as well for the problem you
describe as a language that updates in place. Even so, overall the
compiler optimizes very well. Haskell is such a good language that you
may be able to achieve the performance you want with IORefs (IORefs are
_very_ fast), and even though it's not as pleasing as Haskell code can
be, the code may still be better than you could do in an imperative
language, but this would depend a bit on the details of your problem.
Gabi wrote:
> Maybe Data.Sequence is a good option. Seems to be designed to give
> good performance when mutating
> If trees could be represented using Data.Sequence, I think that tree
> manipulation performance would be bearable.
> Any other libraries that might be useful?
I use Data.IntMap a lot, including a wrapped version that takes any Enum
as a key (which I intend to put on Hackage some time). Data.IntMap,
Data.Map and Data.Sequence are a bit slower than update-in-place
languages, but algorithmically they're very good and the performance is
definitely not terrible.
You might be interested in taking a look at
http://haskell.org/haskellwiki/DDC. Disciple is a Haskell-like language
- with the project being at a very early stage - that includes
mutability in its type system so you can mutate state in place, but with
the same strong guarantees of purity that you get in Haskell with the ST
and State monads. The compiler is incomplete but it does work for the
core of the language, so it's possible to write small programs in it.
Steve
Gabi wrote:
> I might be wrong but I think this is a weak spot for many functional
> langs, including Haskell - The ability to manipulate in high rate data
> structures without killing the performance . Even in langs like
> Clojure, which enable the cheap creation of new modified structures
> out of old ones(using "persistent structures") -it is much slower than
> using an imperative language to manipulate data in place. What is the
> approach of Haskell to this ?
>
------------------------------
Message: 8
Date: Tue, 2 Feb 2010 18:32:08 +0900
From: ??? <[email protected]>
Subject: [Haskell-beginners] wanto post haskell question
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
hi I have a question about haskell coding.
Matrices
One of many ways to define matrices in Haskell is the list of matrix rows,
where a row is a list of double precision oating point numbers:
type Matrix=[[Double]]
Using this type you should define the following functions (definition of dim
is given as an inspirational example).
dim :: Matrix -> (Int,Int) --returns matrix dimension (number of rows
and columns)
dim m = if (not.isMatrix) m then error "Not a matrix" else (length m,
length (head m))
isMatrix :: Matrix -> Bool --checks whether all rows have the same length
isMatrix m = and [length (head m) == length a | a <- m]
I have done upto here and I am stuck on multSM.
multSM :: Double -> Matrix -> Matrix --multiplies a scalar and a matrix
when I do:
multSM d m = [[(b*a)| b<-[d], a<-(head m)]] or [map (*d) (head m)]
...I get (using Hugs):
Main> multSM 3 [[2,3,4],[1,3,4],[6,3,0]] [[6.0,9.0,12.0]]
So I solve 3 [2,3,4] but I do not know how to get the rest 3
[[1,3,4],[6,3,0].
Please help me on this problem.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://www.haskell.org/pipermail/beginners/attachments/20100202/3e0ef10d/attachment.html
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 20, Issue 8
****************************************