wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

CSCI0823 UnitTest_Finals

Total questions: 35

Worksheet time: 18mins

Name
Class
Date
1.

Determine the result of predicate append


?- append([1, 2, 3], [d, e, f, g], X).

a)

X = [1, 2, 3]

b)

X = [1, 2, 3, d, e, f, g]

c)

X = [d, e, f, g,1, 2, 3]

2.

Assess the result of the given query


?- [1,2,3,4,5].

a)

Head = 1,

Tail = [2, 3, 4, 5].

b)

ERROR

c)

[1,2,3,4,5].

3.

What does the given fact mean


list([_|_]).

a)

number of argument in list predicate

b)

head and tail in list predicate

c)

empty list in list predicate

4.

list_to_set([1,2,a,q,@], X).

a)

X = [1, 2, a, q, @].

b)

X = [a, q, 1, 2, @].

5.

Below are valid examples of ___

[ ]

[0, 1, 2, 3, 4, 5]

[‘a’, ‘b’, ‘c’]

[‘mon’, ‘tue’, ‘wed’]

a)

Set elements

b)

Sets

c)

Head and Tail

6.

member(1,2, [1,2,5,4]).

a)

True

b)

False

c)

ERROR: Unknown procedure: member/3

ERROR: However, there are definitions for:

ERROR: lists:member/2

false.

7.

?- sumlist([1,2,3,1,1], Sum).

a)

Sum = 8.

b)

ERROR: Arithmetic: `a/0' is not a function

8.

?- is_ordset([1,3,5]).

a)

True

b)

False

9.

?- subtract([1,2,3], [1,2,3,4], Answer).

a)

Answer = ( ).

b)

Answer = [1,2,3].

c)

Answer = [ ].

10.

?- is_set([[H]|T]).

a)

True

b)

False

11.

?- intersection([1,2,3,4], [1,2,3,4,5], Answer).

a)

Answer = [1, 2, 3, 4].

b)

Answer = [5].

12.

?- union([1,2,3,4,4], [1,2,3,4,5], Answer).

a)

Answer = [4, 4].

b)

Answer = [1, 2, 3, 4, 5].

13.

?- ord_empty([1,2,3 ]).

a)

True

b)

False

14.

?- ord_seteq([[ ]], [[ ]]).

a)

True

b)

False

15.

?- list_to_ord_set([b,a,+,4,*,3], Set).

a)

Set = [3, 4, *, +, a, b].

b)

Set = [3, 4, a, b, *, +, ].

16.

Let A = [29,30,41],B = [1,2,3], C = [30,41] find

A U B ∩ C

a)

[30,41]

b)

[1,2,3,29,30,41]

c)

[29,30,41]

17.

sample.pl

list([]).

list([_|_]).

lt(X,Y):-var(X);var(Y).

lt(X,Y):-nonvar(X),nonvar(Y),X<Y.


Using the database sample.pl, project the result of evaluation


?-list([5435,63,868]).

a)

True

b)

False

18.

sample.pl

list([]).

list([_|_]).

lt(X,Y):-var(X);var(Y).

lt(X,Y):-nonvar(X),nonvar(Y),X<Y.


Using the database sample.pl, project the result of evaluation


?- list([5435,63|868]).

a)

True

b)

False

19.

reverse.pl

reverse([ ], [ ]).

reverse([H|Tail],Result) :- reverse(Tail,Tailreversed), append(Tailreversed,[H],Result).


Using reverse.pl database, evaluate

?-reverse([ 4,5| [6] ],X).

a)

X=[4,5,6]

b)

X=[6,5,4]

c)

Error

20.

Succeeds if Set3 unifies with the

intersection of Set1 and Set2

a)

intersection(-Set1, -Set2, +Set3)

b)

intersection(+Set1, +Set2, -Set3)

21.

subtract(+Set, +Delete, -Result)


The predicate subtract means ___

a)

Delete all elements of set ‘Delete’ from ‘Set’

b)

Delete all elements of Set ‘Delete’ from ‘set’

22.

The first element and the last element in a set

a)

[ H | T ]

b)

[ _ ]

23.

Identify the result of the query

?- [342, 899, 190, 3788, 5134] = [_, X | _].

a)

X = 899.

b)

X = [899, 190, 3788, 5134].

24.

The arity of append( ).

a)

append/3

b)

append/2

c)

append/1

25.

append(FL,BL,[c,d,e,1,2,3]).

is categorized as ___

a)

Finding Back List

b)

Finding Front List

c)

Indeterministic List Decomposition

26.

?- append(FL,BL,[c,d,e,1,2,3]).

will return__

a)

FL = [],

BL = [c, d, e, 1, 2, 3] ;

FL = [c],

BL = [d, e, 1, 2, 3] ;

BL = [e, 1, 2, 3] ;

FL = [c, d, e],

BL = [1, 2, 3] ;

FL = [c, d, e, 1],

BL = [2, 3] ;

FL = [c, d, e, 1, 2],

BL = [3] ;

FL = [c, d, e, 1, 2, 3],

BL = [] ;

false.

b)

FL = [],

BL = [c, d, e, 1, 2, 3] ;

FL = [c],

BL = [d, e, 1, 2, 3] ;

FL = [c, d],

BL = [e, 1, 2, 3] ;

FL = [c, d, e],

BL = [1, 2, 3] ;

FL = [c, d, e, 1],

BL = [2, 3] ;

FL = [c, d, e, 1, 2],

BL = [3] ;

FL = [c, d, e, 1, 2, 3],

BL = [] ;

false.

c)

FL = [],

BL = [c, d, e, 1, 2, 3] ;

FL = [c],

BL = [d, e, 1, 2, 3] ;

FL = [c, d],

FL = [c, d, e],

BL = [1, 2, 3] ;

FL = [c, d, e, 1],

BL = [2, 3] ;

FL = [c, d, e, 1, 2],

BL = [3] ;

FL = [c, d, e, 1, 2, 3],

BL = [] ;

false.

d)

FL = [],

BL = [c, d, e, 1, 2, 3] ;

FL = [c],

BL = [d, e, 1, 2, 3] ;

FL = [c, d],

BL = [e, 1, 2, 3] ;

FL = [c, d, e],

BL = [1, 2, 3] ;

FL = [c, d, e, 1],

BL = [2, 3] ;

FL = [c, d, e, 1, 2],

BL = [3] ;

BL = [] ;

false.

27.

Arity of last( ).

a)

last/2

b)

last/1

28.

Arity of select( ).

a)

select/3

b)

select/2

29.

Arity of member( ).

a)

member/3

b)

member/2

30.

?- append([1, 2, 3], [ ], [a, f, t, p, w], X).

ERROR: Unknown procedure: ______

a)

append/4

b)

append/3

31.

?- is_ordset([*, +, -, /]).

a)

True

b)

False

32.

?- is_ordset([#,1,3,5]).

a)

False

b)

True

33.

?- subset([1,2,4], [1,2,3]).

a)

False

b)

True

34.

Below is the database finals.pl


b(f).

b(i).

b(n).

b(a).

c(l).

c(g).

c(r).

c(a).

c(d).

c(e).

d(1).

d(0).

d(0).

a(X):- b(X), c(X), d(X).

a(X):- c(X), d(X).

a(X):- d(X).


Determine the result of a(X)

a)

X = 1 .

b)

X = 1 ;

X = 0 ;

X = 0.

c)

X = 0.

35.

?- sumlist([ ], Sum).

a)

Sum = [ ].

b)

Sum = 0.