Skip to content

Instantly share code, notes, and snippets.

@mattyw
Created November 10, 2016 16:50
Show Gist options
  • Save mattyw/d4ea753cbb6c5f3e6fd6658a169ed293 to your computer and use it in GitHub Desktop.
Save mattyw/d4ea753cbb6c5f3e6fd6658a169ed293 to your computer and use it in GitHub Desktop.
let random_object = System.Random()
let filelines filename = System.IO.File.ReadAllLines(__SOURCE_DIRECTORY__ + "/" + filename)
let get_random_line file = random_object.Next(0, Seq.length(file))
let get_random_word word_file = Seq.nth (get_random_line word_file) (word_file)
type words =
| Verb
| Noun
| Adjective
| Word of string
[<EntryPoint>]
let main argv =
let noun_file = filelines "nounlist.txt"
let verb_file = filelines "31kverbs.txt"
let adjective_file = filelines "commonadjectives.txt"
let input_list = [Word("In what sort of world is"); Adjective; Noun; Word("allowed to be a thing")]
let replacer = function
| Verb -> get_random_word verb_file
| Noun -> get_random_word noun_file
| Adjective -> get_random_word adjective_file
| Word(word) -> word
let output_list = List.map replacer input_list
printfn "%A" output_list
0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment