Can you guyz help me out in answering the following question?
Create a binary predicate called 'square' which will square each
number in a list. This pred. will be shallow.
e.g. ?-square([a,[[3]],b,4,c(5),8],X).
X=[a,[[3]],b,16,c(5),64]
2. Create a binary predicate called 'deepsquare' which will give
a list in which all numbers are squared, including those in sublists.
e.g. ?-dcountSublists([a,[[3]],b,4,c(5),4],C).
C=[a,[[9]],b,c(5),16]
3. Write a predicate 'addbubba' which will place 'bubba' after each atom in a
list. The empty list is unchanged.
e.g. ?-addbubba([a,b,8,c],X).
X=[a,bubba,b,bubba,8,c,bubba]
This one is shallow, not deep.
4. Write a predicate 'everyother' which will remove every other element in a list,
starting with the second element. List length can be odd or even.
e.g. ?- everyother([g,r,o,u,l,l,o,e,r,s,p],L).
L = [g,o,l,o,r,p];
fail
Create a binary predicate called 'square' which will square each
number in a list. This pred. will be shallow.
e.g. ?-square([a,[[3]],b,4,c(5),8],X).
X=[a,[[3]],b,16,c(5),64]
2. Create a binary predicate called 'deepsquare' which will give
a list in which all numbers are squared, including those in sublists.
e.g. ?-dcountSublists([a,[[3]],b,4,c(5),4],C).
C=[a,[[9]],b,c(5),16]
3. Write a predicate 'addbubba' which will place 'bubba' after each atom in a
list. The empty list is unchanged.
e.g. ?-addbubba([a,b,8,c],X).
X=[a,bubba,b,bubba,8,c,bubba]
This one is shallow, not deep.
4. Write a predicate 'everyother' which will remove every other element in a list,
starting with the second element. List length can be odd or even.
e.g. ?- everyother([g,r,o,u,l,l,o,e,r,s,p],L).
L = [g,o,l,o,r,p];
fail