title: How to specify return value based on if element is found in list?
body: <p>I have a list of tuples looking e.g. like this:</p>
  
  <pre><code>[{apple, fruit},{pear, fruit},{tomato, vegetable}]
  </code></pre>
  
  <p>One of my functions is supposed to go through the list and return an element by key like this:</p>
  
  <pre><code>1&gt; db:find(pear, Db).
  {ok,fruit}
  </code></pre>
  
  <p>My function does this and looks like this:</p>
  
  <pre><code>find(Key, DbRef) -&gt; [{ok, Element} || {Key1, Element} &lt;- DbRef, Key =:= Key1].
  </code></pre>
  
  <p>But I also want it to return something like this:</p>
  
  <pre><code>2&gt; db:find(cucumber, Db).
  {error,unknown}
  </code></pre>
  
  <p>when the Key is not found in the list.</p>
  
  <p>Is this possible??</p>