Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

choosing a random line from a file in haskell

Name: Anonymous 2009-01-20 3:35

is there any way to do it that's not slow as fuck?

Name: Anonymous 2009-01-20 21:57

>>31
input where every line is the same length would be pathological input. in the real world most text files have lines of different lengths.

>>32
that would be slow as fuck and overkill when the only thing i'm ever going to do with this text file is pick a random line from it each time the program is run... but now that i think about it, maybe it'd be a good idea to just make a file containing the positions of all the newlines as fixed-size integers, then i can seek to a random position in that file (modulo the length of each integer), read the number, and seek to the right place in the text file...

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List