title: Use =.. to define the predicate subterm(T1,T2)
body: <p>I want to review my lessons quickly by doing some practice. But I have no solution for those practice to check. Could you give me a solution, so when I get stucke. I could find some guidance here quickly.The first question is described below. Thanks in advance.</p>
  
  <p>Question1. We recall that the built in predicate  T  =.. L is satisfied if T is a term and L is the list that contains the functor and the main subterms of L.
  For example, f(a,g(b)) =.. L is satisfied when L = [ f, a, g(b) ],and a =.. List is satisfied when List = [a].</p>
  
  <p>Use =.. to define the predicate subterm(T1,T2) which is satisfied when T1 is a subterm of T2. You may assume that T1 and T2 have no variables. You may also want to use the built in predicates atomic(X) or compound(X) that check if X is an atomic term and a structure, in this order.</p>
  
  <p>My solution is:</p>
  
  <pre><code>subterm(X,[X]):-atom(X),!.
  subterm(T1,T2):-
  compound(T1),
  T1=..U,
  U=[X|Y],
  T2=Y.
  </code></pre>
  
  <p>Any advice will be appreciated. Thanks!</p>