title: Prolog List Predicates
body: <p>I need some help with three prolog predicates for checking and manipulating lists. I'm new to prolog and any help would be much appreciated.</p>
  
  <p>The three predicates are:</p>
  
  <ul>
  <li><code>double_up(+List1, -List2)</code> is true when <code>List2</code> has each element of <code>List1</code> twice. The query <code>double_up([a,b,c],X)</code> should give <code>X=[a,a,b,b,c,c]</code>. The order of the elements in the output list does not matter.</li>
  <li><code>pivot(+List1, +Pivot, -Smaller, -GreaterEq)</code> is true when <code>Smaller</code> is the list of numbers in <code>List1</code> smaller than <code>Pivot</code>, and <code>GreaterEq</code> is the list of numbers in <code>List1</code> bigger than or equal to <code>Pivot</code>.</li>
  <li><code>fancy_replace(+List, +Takeout,+Putin, -NewList, -Count)</code> is true when <code>NewList</code> is the same list as the input <code>List</code>, but where each <code>Takeout</code> element in the list is replaced with the <code>Putin</code> element. Count should be the number of Takeouts that got replaced. For example, the query <code>fancy_replace([9,10,1,9,2],9,0, X, C)</code> should give <code>X = [0,10,1,0,2]</code> and <code>C = 2</code>. The order of the elements in the output list does not matter.</li>
  </ul>