fivemack: (Default)
[personal profile] fivemack
haarStep x y = [s*(x+y), s*(x-y)]

disorderedHaar [] = []
disorderedHaar (x:y:xs) = haarStep x y : disorderedHaar xs

haar [a,b] = haarStep a b
haar s = let w = disorderedHaar s in 
         (haar (map head w)) ++ (map (!!1) w)


Divide-and-conquer algorithms come over amazingly naturally in Haskell; it's a deeply uncluttered language. First-class functions mean that it's almost always possible to abstract rather than to cut-and-paste; memory allocation and deallocation is dealt with by the garbage collector, looping by the magic of tail recursion. You can write down an algorithm in not many more words than you'd use in English, and with less ambiguity.

On the other hand, everything I've actually written in the language has been a pedagogical exercise. I've implemented pseudoprimality testing, Shanks' algorithm for square roots modulo p, arithmetic on elliptic curves, some rudimentary image processing, two different kinds of wavelet, a routine for counting polyominoes; didn't bother porting my sudoku solver from python. It's a great language for the sort of things I'd have written as a couple of hundred lines of BASIC on the Archimedes.

It may even be possible to write 'real applications'; but most of the real applications inside my head are highly graphical, pictures in the sense of maps from the complex space to a colour-wheel parameterised by arg f(x), to be computed either by vectorised assembly language or by pixel shaders (there's not much of a difference there, of course), and I wonder how to get to there from here, and once I've got there, how to distribute the result. The closest I can get to pictures are

          hPutStr hdl "P6\n1000 1000\n255\n"
          hPutStr hdl (map chr (concat (map pix (newtonset 255 zz (1000,1000)))))


and that's punched-card-era: run the program to generate the file which can be loaded into the gimp. The model in my head is to have a routine compiling an expression-tree representation of what I want to do into machine code which the program can then call; can that actually be done?

I know I used to drip with ideas for that kind of thing, to plan web-sites of moderate grandeur in the bath. What's gone wrong?

Date: 2005-08-19 11:25 pm (UTC)
From: [identity profile] meirion.livejournal.com
I know I used to drip with ideas for that kind of thing, to plan web-sites of moderate grandeur in the bath. What's gone wrong?

ah, the eternal questions. you and me both :-(

umm, i hope that doesn't sound flippant. i know where you're coming from, because i'm there myself, d00m.

*hugs*

-m-

Date: 2005-08-20 01:43 am (UTC)
fanf: (Default)
From: [personal profile] fanf
I think there are Hs bindings for OpenGL. Would they provide you with pixel shader support? (I don't know if OpenGL gets that modern.)

There is a lot of interest amongst serious Haskell people in making the language useful for Real World applications, hence Simon Marlow's impressively brief demo web server. http://www.haskell.org/~simonmar/papers/web-server-jfp.pdf

I think they would be very interested in making haskell do graphical stuff better.

Date: 2005-08-20 11:19 am (UTC)
From: [identity profile] hsenag.livejournal.com
There are a lot of people on #haskell who can probably answer this question better than I could. Conal Elliott's work on Pan shows how you can do cool stuff to describe images in a functional language.

March 2024

S M T W T F S
     12
3456789
10111213141516
17181920212223
24 252627282930
31      

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 13th, 2025 01:35 pm
Powered by Dreamwidth Studios