CSC324H Programming Languages

Fall 2009 -- Assignments

Homepage

Assignment 1

Assignment 2

Assignment 3

Assignment 4

Assignment 5

Assignment 1

All assignments should be done individually, no group works. Please check the course policy for general discussion.

A1 hand out

A1 Marking Scheme

Clarifications:
Question 4:

  1. English word may be not very precise, let me make it more precise: The primitive concept can be any string of mixed characters starting with an upper case character. The primitive role can be any string of mixed characters starting with a lower case character. Characters are lower cases a to z and upper cases A to Z.
  2. The notation A|B (the operator |) for a K formula I used originally is confusing, it can be mixed up with the pipe line we use for BNF notations. Please using single quotation around the operator | (i.e., '|') to distinguish it from BNF pipeline.
  3. Some student asked me about the precedence order of ~, exist R.A , forall R.A. How to treat
    ~ exist r. A or B
    This formula should be comprehended as the negation of the whole exist r. A or B. To make the description more clearer for ~, let's say, ~ has the highest priority than any other operators in general, but when it is immediately followed by an existentially (that is, exist r....) or a universally (that is, forall r. ....) quantified subformula, it will be considered as negation of the whole quantified sub-formula. This is achievable in a CFG. I.e., there is solution for doing so.
    However, we will also accept a solution which forces parentheses around quantified formulas, that is, ~ (exist r. A or B).
    Another example,
    (~ forall r. A or B) and C
    notice that ( ) assures whatever inside should be considered first, and the inside formula is a negation of a quanified formula forall r. A or B. On the other hand,
    ~ forall r. A or B and C
    is considered as the negation of the quantified subformula forall r. A or B and C.

[Home|Back to the index]

Assignment 2

Due date extended: Please the due date Assignment 2 will be Oct. 10, 2009 (6:00pm sharp) .

All assignments should be done individually, no group works. Please check the course policy for general discussion.

A2 hand out

Assignment Cover Page You may type your name on the line of signature if you don't have a scannar or e-signature.

Before start your assignment, please read the coding guidelines and follow this guideline document for testing.

Electronic submission
Only plain text submissions will be graded. It is your responsibility to ensure that your submission is readable. You should not have any lines longer than 81 characters. Unreadable work will not be graded.

Assignment submission website.

Clarifications:
Question 5:

  1. For (left ...) and (right ...) when the input is '(), you may return '() as well.

[Home|Back to the index]

Assignment 3

Due date extended: Please the due date Assignment 3 will be Nov 2, 2009 (6:00pm sharp) .

Assignment Cover Page You may type your name on the line of signature if you don't have a scannar or e-signature.

There will be two parts in this assignment.

  1. A3 Part A hand out
  2. A3 Part B hand out
  3. A3 Part B starter code

Before start your assignment, please read the coding guidelines and follow this guideline document for testing.

Electronic submission
Only plain text (for programming) and pdf (for written assignment) submissions will be graded. It is your responsibility to ensure that your submission is readable. You should not have any lines longer than 81 characters. Unreadable work will not be graded.
Assignment submission website.

Clarifications/Correction:

  1. marginal examples for pairs:
        >(pairs '() '(1 2 3))
        ()
        >(pairs '(1 2 3) '())
        ()
        
  2. Q3(a) examples:
        > (tree-height1 (leaf 3))
        1
        > (tree-height1 (node (leaf 3)  
             (node (leaf 4)
               (leaf 5))))
        3
        >  (tree-yield1 (leaf 1)))
        (1)
        >  (tree-yield1 (node (leaf 1) (leaf 2)))
        (1 2)
        > (tree-yield1 (node (leaf 1)  
             (node (leaf 3) (leaf 2))))
        (1 3 2)
        > (tree-yield1 (node  
             (node (leaf 3) (leaf 4))
             (leaf 1)))
        (3 4 1) 
        
  3. Question 3(d): The last example of match should be
    (match (div (num 2) (num 5))
            ((add x y) x)
                ((div x y) (list x y))
                    ((num x) x)) => ((num 2) (num 5))
    
  4. Question 1(b): (range from to) will return empty list when from is greater than to.
  5. Question 2(b): (asum '(1 2 3 4 5))should be evaluated to 3
    In the original file, it was evaluated to 5, which is a typo.

[Home|Back to the index]

Assignment 4

Note the abnormal due date: Nov 19, 2009 (11:59 pm sharp). Also, the total number of grace days is increased to 3 days.

Assignment Cover Page You may type your name on the line of signature if you don't have a scannar or e-signature.

There will be two parts in this assignment.

  1. A4 hand out
  2. movies.pl for Question 5

Before start your assignment, please read the description carefully in the assignment, and follow this guideline document for testing.

Electronic submission
Only plain text (for programming) and pdf (for written assignment) submissions will be graded. It is your responsibility to ensure that your submission is readable. You should not have any lines longer than 81 characters. Unreadable work will not be graded.
Assignment submission website.

Clarifications/Correction:

  1. Q3: Correction for the example.
    ?- unique([a,b,b,a,c],[b,a,c]).
    true.
    
    ?- unique([b,a,[b,b],b], K).
    Y = [a,[b,b],b];
    false.
    
    You may use predicate not/1.
    
    Bonus (5 points): Note that in the above example, unique([a,b,b,a,c], Y) is true iff Y=[b,a,c]. 
    If you could implement unique(+List,?Set), so that  unique([a,b,b,a,c], Y) will be true iff 
    Y is a collection of a, b and c no matter which order they are in. For example,
    
    ?- unique([a,b,b,a,c],[b,a,c]).
    true.
    ?- unique([a,b,b,a,c],[a,b,c]).
    true.
    ?- unique([a,b,b,a,c],[b,c,a]).
    true.
    ?- unique([a,b,b,a,c],[b,b,a,c]).
    false.
    
  2. Q5(a): where to save your queries?
    Test your queries and save them in the testing.txt file.
  3. Q5(b): where to save your definitions?
    Save them in a4.pl. To test them with movies.pl, you may load both a4.pl and movies.pl by using
    ?-[movies, a4].
    

[Home|Back to the index]

Assignment 5

Assignment Cover Page You may type your name on the line of signature if you don't have a scannar or e-signature.

There will be two parts in this assignment.

  1. A5 hand out

Before start your assignment, please read the description carefully in the assignment, and follow this guideline document for testing.

Electronic submission
Only plain text (for programming) and pdf (for written assignment) submissions will be graded. It is your responsibility to ensure that your submission is readable. You should not have any lines longer than 81 characters. Unreadable work will not be graded.
Assignment submission website.

Clarifications/Correction:

  1. Q5: the predicate name should be heap_q5, not heap, in the examples.

[Home|Back to the index]

Yilan Gu ©2009, University of Toronto