There's a neat Haskell solution to the knapsack problem which runs very
fast. I'm not 100% sure that it runs faster than an optimal solution in
other GC'd imperative languages, but it's very concise and not (too)
convoluted. Have a search for the thread with "xkcd" in the title.
Chung-chieh Shan
On 8/2/07, Jon Harrop <[EMAIL PROTECTED]> wrote:
> Any suggestions for a perfect example that uniquely demonstrates the benefits
> of the Haskell language compared to other languages?
For short and sweet, power series is a nice example. Try
http://www.polyomino.f2s.com/david/haskell/hs/PowerSeries
BP> If I want a small example to show to people I usually use zipWith.
I'd suggest unfoldr + lazyness, such as
hammings = 1 : unfoldr (Just . generator) (map (\n -> map (n*) hammings)
[2,3,5])
where generator xss =
let x = minimum $ map head xss
in (x, map (dropWhile (x==)) x
Hello Jon,
Thursday, August 2, 2007, 11:02:14 PM, you wrote:
> Any suggestions for a perfect example that uniquely demonstrates the benefits
> of the Haskell language compared to other languages?
http://www.haskell.org/haskellwiki/Simple_unix_tools
--
Best regards,
Bulat
Hi
I know that Audrey Tang (the Pugs project) has used hamming numbers
for this, see http://www.perl.com/lpt/a/959
Thanks
Neil
On 8/2/07, Jon Harrop <[EMAIL PROTECTED]> wrote:
>
> Any suggestions for a perfect example that uniquely demonstrates the benefits
> of the Haskell language compared to
That's a tough one,
If I want a small example to show to people I usually use zipWith. It
is higher-order and lazy, and I include a discussion of "lists as
loops", which means zipWith is a loop combiner. When my audience is C
programmers I ask them to implement it in C, which is always amus
Any suggestions for a perfect example that uniquely demonstrates the benefits
of the Haskell language compared to other languages?
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
OCaml for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists/?e