Page 1 of 1

Question 2 [8] Which of the following pairs of expressions are unifiable? If they are, give the resulting bindings for t

Posted: Fri May 20, 2022 3:26 pm
by answerhappygod
Question 2 8 Which Of The Following Pairs Of Expressions Are Unifiable If They Are Give The Resulting Bindings For T 1
Question 2 8 Which Of The Following Pairs Of Expressions Are Unifiable If They Are Give The Resulting Bindings For T 1 (56.48 KiB) Viewed 41 times
Question 2 [8] Which of the following pairs of expressions are unifiable? If they are, give the resulting bindings for the variables. Otherwise give reasons why they cannot be unified a) [[a, b, c)] and [X|Y] b) [AA] and [X,[c, d e]] c) (A,A) and [X][c, d e]] d) f(Z) +1-Y*2 and U-(1+2) *Z Question 3 [6] Write a procechure that has a list L1 as input and produces a list L of ordered pairs such that the first element of the ordered pair is the position of the pair in the list and the second element of the ordered pair is the element from Ll in the corresponding position. For example, if L1 = [ a, b,c,d), the output list should be: L = [(1, a),(2,b). (3.c), (4. )]. Question 4 [12] Let L denote a list. Write Prolog procedures to do the following: (a) count(X,L.N: Count the number of occurrences of X in L to give the result N. delete_all(XL,LI): Delete all occurences of X from L to give the result L1. ©) replace_all(XL,1,L2): Replace all occurences of X in L with Y to give the result L1. Questions [10] a Write a procedure that finds both the minimum and maximum values of elements in a list. If the list is empty, the minimm and maximm should both be set to zero. If the list contains more than n elements, an error message list is too long should be displayed (See Bratko, page 135 for a discussion of the write predicate that can be used to display messages.) When the program traverses the list to find the minimum and maximum, all negative mumbers should be ignored