[Haskell-cafe] Packed String parameters
Scherrer, Chad
Chad.Scherrer at pnl.gov
Wed Jan 18 17:09:38 EST 2006
To read a file using a packed string, I need to use this function,
right?
hGetPS :: Handle -> Int -> IO PackedString
What's the Int? Do you have to specify the length in advance? I don't
know how packed strings are implemented, and I'm having trouble finding
much documentation.
I'm trying to speed up this horribly slow thing:
dot :: [Double] -> [Double] -> Double
dot x y = sum $ zipWith (*) x y
main = getContents >>= sequence_ . map (print . dot weights . map read .
words) . lines
The idea is to take a dot product of each line of a file with a fixed
vector of weights, and send the result to stdout. I thought
PackedString's might help, but I'm not sure what to do with that
parameter. The input file is over 1 million lines long. Any ideas?
Thanks,
Chad Scherrer
Computational Mathematics Group
Pacific Northwest National Laboratory
"Time flies like an arrow; fruit flies like a banana." -- Groucho Marx
More information about the Haskell-Cafe
mailing list