Generate an understandable sentence

Matlab

why

example of outputs:

>> why
The programmer suggested it.
>> why
To please a very terrified and smart and tall engineer.
>> why
The tall system manager obeyed some engineer.
>> why
He wanted it that way.

[This is one of Matlab's easter eggs]

EDIT: you can see the code of this function here: why.m


Bash

fgrep '/* ' /usr/src/linux* -r | cut -d '*' -f 2 | head -$((RANDOM)) | tail -1

Requirements: linux kernel source installed in /usr/src

This pulls random comments out of the kernel source. Whether the sentences are actually understandable is open to debate.

Examples of actual output:

  • end of packet for rx
  • I don't know what to do
  • 256 byte packet data buffer.
  • The rest of this junk is to help gdb figure out what goes where
  • Convert page list back to physical addresses, what a mess.
  • ???
  • Only Sun can take such nice parts and fuck up the programming interface

PHP

Given enough time, this will produce all literature, past, present and future. The rules didn't mention that no other text may be produced.

The string 'TOS...' provides a logarithmic scale frequency of the letters to more closely match English. This is used to generate a larger string with the approximate relative letter frequencies.

$a = ord('A');
$s = '';

foreach (str_split('TOSRWQPPUALRQTTRGUUUQMMLMFZ') as $i=>$f)
{
    if (!ctype_alpha($c = chr($a + $i)))
        $c = ' ';
    $s .= str_repeat($c, round(exp((ord($f) - $a) / 3.976)));
}

$l = strlen($s) - 1;
for (;;)
    echo substr($s, mt_rand(0, $l), 1);

Running it, I have discovered such literary gems as:

  • GO NOW - You as a subject is implied.
  • IM AOK - I'm A-OK
  • IM FDR - I'm F(ranklin) D(eleano) R(oosevelt)

Also, numerous invectives to concisely express displeasure with the current situation. [Some letters redacted.]

  • F**K
  • S**T

As well, the following using the fine-tuned scaling:

  • IS IT ON
  • I AM STU
  • I SEE HTML