title: How do I store and access a list within a variable in Prolog?
body: <p>I am attempting to learn the basics of Prolog for a class. I'm running into the seemingly simple problem of not being able to store a list within a rule and retrieve it for usage in other clauses. For example:</p>
  
  <pre><code>% These are the contents of the pl file I want to consult
  
  % Numbers I want to process
  inputList([3,2,1,0]).
  
  % Prints out the contents of a list
  printList([First | Tail]) :- 
      write(First),nl,
      printList(Tail).
  </code></pre>
  
  <p>What I want to do is call the following within Prolog:</p>
  
  <pre><code>?- inputList(X).
  ?- printList(X).
  </code></pre>
  
  <p>The goal is to avoid constantly entering long lists into the Prolog interpreter and instead store them in the .pl file. However, entering the commands above results in the list not being properly checked against the given clause. How can this be accomplished, preferably using the structure above to store a list {listContents([a,b,c,d]).}?</p>