title: Prolog - Search a list for an element, print the list if element is found
body: <p>So I am trying to write a small program that does the following. </p>
  
  <p>I can search for a element inside a list, if the element is found in the list, then the list is printed out to confirm that it has been found. </p>
  
  <p>So in basic pseudo - </p>
  
  <ol>
  <li>list of elements - computer, mouse, keyboard, webcam</li>
  <li>search for mouse in this list</li>
  <li>output the list which mouse has been found in </li>
  </ol>
  
  <p>While doing some reading I found something which does what I want to do pretty much. This is below </p>
  
  <pre><code>on(Item,[Item|Rest]).  
  
  on(Item,[DisregardHead|Tail]):-
  on(Item, Tail). 
  </code></pre>
  
  <p>If I type the query -
      on(apples, [pear, grape, banana, plum, apples]).
  then it searches through the list, discarding non-relevant elements until it comes to the end and succeeds. </p>
  
  <p>What I want to do is write my own list in the editor and work from it by doing the same kind of function to it like above.(Rather than just inputting the list as a query into the console.)</p>
  
  <p>Thanks</p>