News for hackers. Stuff that matters.
Re:Why Haskell is beyond ready for Prime Time by time_management on Friday January 16, 2009 @12:20AM (#436189)
There's a trick for efficient appending that's somewhat analogous to laziness. It's quite clever. Sadly, I cannot claim to have come up with it, and I don't know who did.

Instead of working with [a] lists, work with [a] -> [a] prepender functions. So the analogue of [1, 2, 3] is f: \x -> [1 2 3] ++ x. Then the analogue of the append of f and 4 is f . (\x -> [4] ++ x), where the . represents composition. Appending using these analogues, I believe, is O(1) instead of O(n).

To "evaluate" an element of this "closure space", just apply it to the empty list.

Re:Why Haskell is beyond ready for Prime Time by eru on Monday January 19, 2009 @04:22AM (#440260)
You can also re-use some form of balanced binary trees where all interesting operations are doable in log(n) and adding requires about log(n) (mostly internal) nodes to be rebuild. That is worse than the optimum O(1) for linked lists you can reach --- but it's easy to come up with and often good enough.