CP2003 - Tutorial 12

Prolog and Functional Programming


  1. Define the relations predecessor, grandparent and grandchild using the parent relation.




  2. Translate the following statements into Prolog rules: (a) two people are relatives if one is a predecessor of the other, (b) two people are relatives if they have a common predecessor, (c) two people are relatives if they have a common successor.




  3. Define the relation
     
         conc(L2, L2, L3)
    
    so that L1 and L2 are two lists and L3 is their concatenation. For example:

    ?- conc([a,b,c], [1,2,3,e], List). L = [a,b,c,1,2,3,e]




  4. Define the relation
         del(X, L1, L2)
    
    so that X is an atom and deleting X from list L1 gives list L2. For example:

    ?- del(a, [a,b,a,a], L).
    
    L = [b,a,a];
    
    L = [a,b,a];
    
    L = [a,b,a];
    
    no
    




  5. Explain the terms first-order function and high-order function.




  6. Discuss efficieny/inefficiency of functional programming language.