[Haskell-cafe] Re: How would you hack it?

Andrew Coppin andrewcoppin at btinternet.com
Wed Jun 4 16:54:57 EDT 2008

Achim Schneider wrote:
> Andrew Coppin <andrewcoppin at btinternet.com> wrote:
>> I have a file that contains several thousand words, seperated by
>> white space. [I gather that on Unix there's a standard location for
>> this file?]
> Looking at /usr/share/dict/words, I'm assured that the proper seperator
> is \n.

Thanks. I did look around trying to find this, but ultimately failed. 
(Is it a standard component, or is it installed as part of some specific 

As I understand it, Haskell's "words" function will work on any kind of 
white space - spaces, line feeds, caridge returns, tabs, etc. - so it 
should be fine. ;-) Since I'm developing on Windows, what I actually did 
was have Google find me a file online that I can download.

[Remember my post a while back? "GHC panic"? Apparently GHC doesn't like 
it if you try to represent the entire 400 KB file as a single [String]...]

> Generate a Map Int [String] map, with the latter list being an infinite
> list of words with that particular size.
> Now assume that you want to have a 100 character sentence. You start by
> looking if you got any 100 character word, if yes it's your sentence,
> if not you divide it in half (maybe offset by a weighted random
> factor [1]) and start over again.
> You can then specify your whole document along the lines of
> (capitalise $ words 100) ++ ". " ++ (capitalise $ words 10) ++ "?" ++
> (capitalise $ words 20) ++ "oneone1!" 
> [1] Random midpoint displacement is a very interesting topic by itself.

I'm not following your logic, sorry...

More information about the Haskell-Cafe mailing list