[Haskell-beginners] A better way?

Keith Sheppard keithshep at gmail.com
Sat Feb 21 19:32:37 EST 2009


ghci still is not happy if we have many rows...

Prelude> :load Table.IO
[1 of 1] Compiling Table.IO         ( Table/IO.hs, interpreted )
Ok, modules loaded: Table.IO.
*Table.IO> let maxTableColumnWidths = foldr ((evalList .) . zipWithD
max) [] . map (map length)
*Table.IO> let maxTCWs = evalList . foldr (zipWithD max) [] . map (map length)
*Table.IO> maxTableColumnWidths  (replicate 1000000 ["hello", "world"])
*** Exception: stack overflow
*Table.IO> maxTCWs  (replicate 1000000 ["hello", "world"])
*** Exception: stack overflow

I hadn't thought of using ByteStrings since I don't know what they are
:-). I'll have to look into it, but I'm assuming that ByteStrings will
give some constant time/space improvement? I think it won't help with
my first problem though since what's happening is that the lazy
function calls are piling up too deep (at least thats what I think is
happening).

Thank you
Keith

On Sat, Feb 21, 2009 at 6:21 PM, Daniel Fischer
<daniel.is.fischer at web.de> wrote:
> Am Sonntag, 22. Februar 2009 00:16 schrieb Daniel Fischer:
>>
>> maxTableColumnWidths = foldr ((evalList .) . zipWithD max) []
>
> Oops again:
>
> maxTableColumnWidths =
>        foldr ((evalList .) . zipWithD max) [] . map (map length)
>
>>
>
>>
>> maxTCWs = evalList . foldr (zipWithD max) []
>>
>
> maxTCWs = evalList . foldr (zipWithD max) [] . map (map length)
>
>> > Cheers,
>> > Daniel
>>
>
>


More information about the Beginners mailing list