CSC 8310 -- Final Exam
Section 001: Tuesday & Thursday 4:30 to 5:45pm in Mendel G30
Section 002: Thursday 6:15 to 8:45 in Mendel G30
Spring 2000, Villanova University
Name: _________________________________
<digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
<unary> ::= + | -
<binary> ::= * | /
<expr> ::= <digit> | <expr> <unary> | <binary> <expr> <expr>
(4 points) Which of the following things are valid <expr>s? Write
"yes" for each valid <expr>, "no" for each
expression that is not a <expr>.
2 + 3 *
+ 2 3 *
2 3 / - 4 /
- 2 3 4 / / (2 points) Write a valid <expr> that is exactly seven symbols long.
f(X, Y) = g(5, 7)mother(john, Dick) = mother(Jack, richard)mother(tom, Dick) = mother(Dick, harry)Me = grandpaw(Me, myself)male(X). /* X is a male. */
female(X). /* X is a female. */
child(X, Y). /* X is a child of Y. */
Write Prolog rules (exactly one each) for:
mother(X, Y). /* X is the mother of Y. */
grandmother(X, Y). /* X is the mother of a parent of Y. */
sibling(X, Y). /* X and Y have the same mother and the same father. */
(car '(a b c))(car '((a b) (c d)))(car '(()))(cdr '(a (b (c))))(cdr '(((a) b) c))(cdr '(()))(cons 'a '(b (c)))(cons '(a b) '(c d))(cons '() nil)(eq 'a 'A)(eq '(a b) '(a b))(cond ((cdr '(a)) 1) (t 2) )(null nil)(cons (car '(a b c)) (cdr '(a b c)))(list (car '(a b c)) (cdr '(a b c)))(append
(list a) b)length "hello"
map even [1..10]
init [1..5]
[x | x <- [1..5], even x]
init "curry"
break (== 'c') "abracadabra"
:type even
take 5 (iterate (2 *) 1)
(x `mod` y) means the same as (mod x y) last has the same type as head.x is a variable, (x) has the same type as x. . (dot) operator in
Haskell?sq.