John Lato wrote:
How would you implement bfnum? (If you've already read the paper,
what was your first answer?)
My first idea was something similar to what is described in appendix A.
However, after reading the paper, I wrote the following code:
data Tree a = E | T a (Tree a) (Tree a)
How would you implement bfnum? (If you've already read the paper,
what was your first answer?)
Actually, my first thought was Just traverse the tree twice. Then it
dawned on me, that the tree could be of infinite size and I settled for
the following solution:
bfsn :: Tree a - Tree Int
Thanks for providing this. I think this is pretty close to one of the
solutions he presents in the paper.
It seems that part of what prompted Okasaki to investigate this
further was trying to solve the problem in a strict language (ML)
after he saw a solution which relies upon laziness. What I
Hello ajb,
Wednesday, June 23, 2010, 6:58:30 AM, you wrote:
build ((w1,t1):(w2,t2):wts)
= build $ insertBy (comparing fst) (w1+w2, Node t1 t2) wts
this algo is O(n^2). to be O(n) you should handle separate lists of
leafs and nodes, adding new nodes to the tail of second list
--
From: Max Rabkin max.rab...@gmail.com
This seems like an example of list-chauvinism -- what Chris Okasaki
calls a communal blind spot of the FP community in Breadth-First
Numbering: Lessons from a Small Exercise in Algorithm Design --
http://www.eecs.usma.edu/webs/people/okasaki/icfp00.ps
I made (presumably) inefficient huffman algorithm not too long ago:
http://www.hpaste.org/fastcgi/hpaste.fcgi/view?id=26484#a26484
I guess it doesn't normally need to be terribly efficient as the
result can be stored in a map of some sort.
On Wed, Jun 23, 2010 at 10:41 PM, John Lato
On Wed, Jun 23, 2010 at 03:41:29PM +0100, John Lato wrote:
How would you implement bfnum? (If you've already read the paper,
what was your first answer?)
This was my first answer, and it is wrong, but I thought it was
slightly clever, so here it is:
bfnum :: Tree a - Tree Int
bfnum tree =
On Wed, Jun 23, 2010 at 4:35 PM, Daniel Lyons fus...@storytotell.org wrote:
On Wed, Jun 23, 2010 at 03:41:29PM +0100, John Lato wrote:
How would you implement bfnum? (If you've already read the paper,
what was your first answer?)
This was my first answer, and it is wrong, but I thought it
On Wed, Jun 23, 2010 at 05:41:17PM +0100, John Lato wrote:
If this answer did work, I don't think the question would be
interesting.
We don't have to be mean. - Buckaroo Banzai.
--
Daniel
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
On Wed, Jun 23, 2010 at 11:50 AM, Daniel Lyons fus...@storytotell.org wrote:
On Wed, Jun 23, 2010 at 05:41:17PM +0100, John Lato wrote:
If this answer did work, I don't think the question would be
interesting.
We don't have to be mean. - Buckaroo Banzai.
I certainly didn't want to upset
This seems like an example of list-chauvinism -- what Chris Okasaki
calls a communal blind spot of the FP community in Breadth-First
Numbering: Lessons from a Small Exercise in Algorithm Design --
http://www.eecs.usma.edu/webs/people/okasaki/icfp00.ps
Thanks for sharing; this was an
On Tue, Jun 22, 2010 at 06:24:22PM +0100, Andrew Coppin wrote:
John Meacham wrote:
In particular, a Huffman coding:
http://en.wikipedia.org/wiki/Huffman_coding
is ideal for this (assuming you just are taking advantage of frequency
analysis). A dynamic Huffman Tree will even adapt as it is
john:
On Tue, Jun 22, 2010 at 06:24:22PM +0100, Andrew Coppin wrote:
John Meacham wrote:
In particular, a Huffman coding:
http://en.wikipedia.org/wiki/Huffman_coding
is ideal for this (assuming you just are taking advantage of frequency
analysis). A dynamic Huffman Tree will even adapt
Don Stewart wrote:
http://hackage.haskell.org/package/huffman
A simple and pure Haskell implementation of the Huffman encoding algorithm.
What the...?
Oh, I see. It uses another package to handle the tricky sorting and
searching stuff. Well, yeah, that would make the code a bit
On Tue, Jun 22, 2010 at 4:18 PM, Andrew Coppin
andrewcop...@btinternet.comwrote:
What the...?
Oh, I see. It uses another package to handle the tricky sorting and
searching stuff. Well, yeah, that would make the code a bit shorter... ;-)
Even so, it's not nearly as elegant to behold as,
On Tue, Jun 22, 2010 at 10:18 PM, Andrew Coppin
andrewcop...@btinternet.com wrote:
Don Stewart wrote:
http://hackage.haskell.org/package/huffman
A simple and pure Haskell implementation of the Huffman encoding
algorithm.
What the...?
Oh, I see. It uses another package to handle
G'day all.
Quoting Andrew Coppin andrewcop...@btinternet.com:
What the...?
Oh, I see. It uses another package to handle the tricky sorting and
searching stuff. Well, yeah, that would make the code a bit shorter...
;-)
Even so, it's not nearly as elegant to behold as, say, the quicksort
17 matches
Mail list logo