I am trying to learn Prolog.I am suppose to write a predicate which will place 'bubbles' before each atom in a list.The empty list is unchanged.
?-addbubbles([a,b,8,c],X).
X=[bubbles,a,bubbles,b,8,bubbles,c]
I wrote the foll Code:
Addbubbles([],[]).
addbubbles([H|T],[A|B]) :-append([bubbles],[H],A),addbubbles(T,B).
But the output is not as expected :
?- addbubbles([a,v,2,4,f],M).
M = [[bubbles,a], [bubbles,v], [bubbles,2], [bubbles,4], [bubbles,f]] ;
How can i remove the extra brackets so that i get the output as:
M = [bubbles,a, bubbles,v,bubbles,2,bubbles,4,bubbles,f];