Thou Impertinent Urchin-Faced Miscreant!

November 25, 2014

Our program takes a list of word lists and returns a list of words, one chosen randomly from each word list:

(define (buzz xss) (string-join #\space (map fortune xss)))

And here are some examples using the buzz-phrase generators on the previous page:

> (buzz broughton)
"integrated digital mobility"
> (buzz broughton)
"functional digital options"
> (buzz broughton)
"compatible policy concept"
> (buzz corporate)
"objectively cultivate cross-unit deliverables"
> (buzz corporate)
"proactively communicate fully researched markets"
> (buzz corporate)
"dynamically maintain user friendly infrastructures"
> (buzz shakespeare)
"Thou dissembling shard-borne baggage"
> (buzz shakespeare)
"Thou villainous crook-pated clack-dish"
> (buzz shakespeare)
"Thou unmuzzled toad-spotted maggot-pie"

We used string-join, fortune and the random number generator from the Standard Prelude. You can run the program at


Pages: 1 2 3

3 Responses to “Thou Impertinent Urchin-Faced Miscreant!”

  1. The real code is in the map line at the end – the rest is just loading in the definitions from the file using YAML, and then checking we have a valid key!

    use strict;
    use YAML::Loader;
    my ($t,$k);
    { local $/ = undef; $t = YAML::Loader->new->load(<DATA>); }
    $k = 'shakespeare' unless exists $t->{$k = shift};
    print "@{[ map { $_->[rand @{$_}] } @{$t->{$k}} ]}\n";
        - integrated
        - total
        - systematized
        - parallel
        - functional
        - responsive
        - optional
        - synchronized
        - compatible
        - balanced
  2. Francesco said


    import System.Random
    import Control.Applicative
    bs = [["integrated", "total", "systematized", "parallel", "functional",
           "responsive", "optional", "synchronized", "compatible", "balanced"],
           ["options", "flexibility", "capability", "mobility", "programming",
            "concept", "time-phase", "projection", "hardware", "contingency"]]
    main = f <$> sequence (replicate 3 (randomRIO (0,9))) <*> pure bs
        where f ns ws = (!!) <$> ZipList ws <*> ZipList ns
  3. Josef Svenningsson said

    Only the code, put in whatever list of insults you fancy.

    import System.Random
    generate :: RandomGen g => g -> [[a]] -> [a]
    generate _ [] = []
    generate g (ls:lss) = ls !! ix : generate g' lss
      where (ix,g') = randomR (0,length ls-1) g

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: