| CSC 8310-002 Final Exam Villanova University, Fall 2000 |
Name __________________________________________ |
Please keep all answers brief and to the point. Illegible answers will be counted
as wrong. None of the questions ask for examples.
General Questions
<thing> ::= <x> x <x>
<x> ::= a | b | c | <thing> * <thing>
<thing>?
(Write "yes" or "no" for each.)
- x
- a x b
- a * b x c
- a x b * c
- a x b x c
- a * b x c * d
public, protected,
private) help specify the scope of names. [a-zA-Z]* and
C(A|D)+R are called ____________________________________
.LISP Questions
(CAR '(A
(B)) )
(CAR '((A)
(B) (C)) )
(CAR '(()
A ()) )
(CDR '(A
B C) )
(CDR '(A
(B)) )
(CDR '(() ()) )
(CONS '() '(A B) )
(CONS '(()) '((A) (B)) )
(APPEND '(A ()) '(B ()) )
(APPEND '((A) (B)) '(()) )
(LIST '(A B) '((C) (D)) )
(LIST 'A '(B) '((C)) )
(CAAR '((A (B (C)))) )
(CADR '((A (B (C)))) )
(CDAR '((A (B (C)))) )
(CDDR '((A (B (C)))) )
DEFUN:COND: (defun enigma (L)
(cond
((null (cdr L)) ())
(t (cons (car L) (enigma (cdr L)))) ) )
what is the result of the following function calls?
(enigma '(a b c) )
(enigma '((a) (b c)) )
(defun unclear (L1 L2)
(cond
((null L1) L2)
(T (cons (car L1) (unclear (cdr L1) L2))) ) )
what is the result of the following function calls?
(unclear '((a) b) '((c) d) )
(unclear '(a (b)) '(c d) )
() is an atom. (MEMBER 'B '(A B C)) is implementation-dependent.ATOM tests whether its single argument is an atom.LIST tests whether its single argument is a list. COND evaluates to
NIL.ML Questions
odd that returns true
if its integer parameter is odd, and false otherwise.bool list
('a * 'a)
('a * 'b)
char -> string
char -> string -> int
#"a"
not
round
[#"a"]
fun confuse [] = []
| confuse (x::y::rest) = (x, y)::(confuse rest);
what is the result of the following function calls?
confuse [1,2,3,4];
confuse [[5, 6], [7, 8]];
fun bumble [] = []
| bumble [x] = [x]
| bumble (x::y::rest) = y::(bumble (x::rest));
what is the result of the following function calls?
bumble [1,2,3,4];
bumble [1,2,3,4,5];
fun mappit L = map (fn x => Int.max (x, 0)) L;
what is the result of the following function calls?
mappit [1,2,3];
mappit [~2, ~1, 0, 1, 2];
isUpper ch instead of
Char.isUpper ch, what command would you give to ML?(f o g)x gives the same result as g(f(x)).
Scratch paper (OK to tear off; don't need to hand it in)