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

i before e cept after c

Name: Anonymous 2012-12-29 8:06

prog/

I had a great idea

search for statistically valid spelling rules like "i before e cept after c"

who is with me? this could be a great probject. Just need a dictionary with words counted by frequency of use in writing.

Name: Richard Stallman 2012-12-29 8:29

#include <stdio.h>

void I_BEFORE_E(void)
{
    puts("EYE BEFORE EEH! EYE BEFORE EEH! *GETS HANDCUFFS AND CURLS UP TO"
            "THE NEAREST AUTHORITY FIGURE");
}

void EXCEPT_IN_THE_SEA(void)
{
    puts("'cause I lost my glasses in there");
}

enum {
    SEE, EYE, EEH, NOONOO, DONKEYS
};

static int aner(c)
{
    switch (c) {
    case 'c':
    case 'C':
        return SEE;
    case 'i':
    case 'I':
        return EYE;
    case 'e':
    case 'E':
        return EEH;
    default:
        ;
    }
    return NOONOO;
}

int main(void)
{
    static const struct trans {
        void (*donkey) (void);
        int state;
    } trans[][DONKEYS] = {
        { { 0, 1 }, { 0, 2 }, { I_BEFORE_E, 0 },        { 0, 0 } },
        { { 0, 1 }, { 0, 3 }, { 0, 0 },                 { 0, 0 } },
        { { 0, 1 }, { 0, 2 }, { 0, 0 },                 { 0, 0 } },
        { { 0, 1 }, { 0, 2 }, { EXCEPT_IN_THE_SEA, 0 }, { 0, 0 } }
    };
    int c, state = 0;

    while ((c = getchar()) != EOF) {
        const struct trans *toiletpaper = trans[state] + aner(c);

        if (toiletpaper->donkey)
            toiletpaper->donkey();
        state = toiletpaper->state;
    }
    return 0;
}

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