1. Assume that you are dealing with an input that consists of some text in English (an essay, report or whatever). The text is non-technical and not formatted, so words should be formed entirely from upper and lower-case letters, and the punctuation symbols used should be "." ";" "," and ":". Paragraphs are separated by a newline character.

    Write a filter for this text so that the output always has exactly one space between words, and the standard typographical conventions are observed for punctuation - i.e. no space before a punctuation symbol, and one space after one, except for "." which is followed by two spaces. In addition, print a list of all proper nouns at the end (a proper noun can be taken as any word that starts with a capital letter, but does not immediately follow a full-stop.)

    Solution

  2. Writing a number in Binary-Coded Decimal (BCD) involves translating each digit of a base-10 number into binary (using 4 bits). Assume that the user will type in a number that has been translated into BCD and presented backwards (thus "524" is "010000100101"). Write a program to take in such a number and write out its base-10 equivalent.

    Solution

  3. You are given the syntax of a statements in a simple programming as follows:
    STAT -> '{' STATSEQ '}'
    STAT -> if '(' EXPR ')' STAT
    STAT -> while '(' EXPR ')' STAT
    STAT -> IDENT '=' EXPR ';'
    
    STATSEQ -> STAT
             | STAT STATSEQ
    
    Assume that an EXPR is just a non-empty sequence of digits, and an IDENT is a non-empty sequence of letters.

    Your task is to translate this into (really bad) LISP using the following rules:

    Translate from to (in LISP)
    if '(' EXPR ')' STAT '(' COND '(' EXPR ')' '(' STAT ')' ')'
    while '(' EXPR ')' STAT '(' DO '(' ')' '( EXPR ')' '(' STAT ')'
    IDENT '=' EXPR ';' '(' SETQ IDENT '(' EXPR ')' ')'
    '{'STAT1 STAT2 ... '}' '(' STAT1 STAT2 ... ')'

    Solution