title: Walk through list using elements, but not losing elements Haskell
body: <p>I am looking for a way of walking through a list, grabbing an element (in that order its given I suppose), using it with another function, then returning to that list and continuing the operation WITHOUT losing that element from the list.</p>
  
  <p>In examples I've seen the only way to accomplish this would be to do the following:</p>
  
  <pre><code>counter :: (Eq a1, Num a) =&gt; a1 -&gt; [a1] -&gt; a
  counter a []            = 0
  counter a [x]           = if a == x then 1 else 0
  counter a (x:xs)        = if a == x then counter a xs + 1 else counter a xs
  
  
  permut :: Eq a =&gt; [a] -&gt; [a] -&gt; Bool
  permut [] []            = True
  permut [x] []           = False
  </code></pre>
  
  <p>But this gets rid of the element x from the list xs when called again both within permut. I know that this also serves to end the recursive calls/terminate the function, but I need to have the whole list available in my counter function in order for it to work. I want to simply walk through the list and keep the whole thing intact. Is this possible?</p>
  
  <p>EDIT: Updated use case. I am trying to work on checking if one list is a permutation of another. My thought process is within each list two properties will hold if they are a permutation: </p>
  
  <ol>
  <li><p>They will have the same number of total elements (will implement this piece later) </p></li>
  <li><p>They will have the same number of each element</p></li>
  </ol>
  
  <p>Right now my counter function works, but I am losing elements as I iterate recursively through the permut function. I don't care about efficiency, I don't mind counting the same element again and comparing it if the number shows up in the list multiple times. </p>