title: How to delete from list, return the deleted element, and return the "modified" list
body: <p>(Newbie alert)</p>
  
  <p>I'm trying to write a function with the following signature, because I couldn't find something similar in the standard libraries:</p>
  
  <pre><code>deleteFromList :: (b -&gt; a -&gt; Bool) -&gt; b -&gt; [a] -&gt; (Maybe a, [a])
  
  -- Example 1: Item found in the list, and deleted
  deleteFromList (\(id1, name1), (id2, name2) -&gt; id1==id2) 3 [(1, "Jack"), (2, "Jill"), (3, "Joe"), (4, "Jimmy")]
  -- returns (Just (3, "Joe"), [(1, "Jack"), (2, "Jill"), (4, "Jimmy")]
  
  -- Example 2: Item not found in list
  deleteFromList (\(id1, name1), (id2, name2) -&gt; id1==id2) 5 [(1, "Jack"), (2, "Jill"), (3, "Joe"), (4, "Jimmy")]
  -- returns (Nothing, [(1, "Jack"), (2, "Jill"), (3, "Joe"), (4, "Jimmy")]
  </code></pre>
  
  <p>I know this can probably be written by calling <code>Data.List.find</code> and <code>Data.List.deleteBy</code>, but that would result in two traversals of the list. I want to make my life tougher and do this in just a single traversal.</p>