title: How to check if a list is empty in Erlang?
body: <p>Basically I have a structure that includes a Value and a list of Ids.
  What I want to do is map over the list of Ids and send a message to them but when I first initialize the list of Ids I put the variable "empty_set".(Maybe I should rename it to empty_list :P).</p>
  
  <p>The problem is that whenever I call the map function I want to check first if the list is an "empty_set" and if not then use the map function in it. Here is the code:</p>
  
  <pre><code>{From, set_value, V} -&gt;
    if ViewerSet /= empty_set -&gt; set_viewer_values(V, ViewerSet)
    end,
  looper(V, ViewerSet)
  </code></pre>
  
  <p>This is the function that is called:</p>
  
  <pre><code>set_viewer_values(Value, ViewerSet) -&gt;
    if ViewerSet /= empty_set -&gt;
      lists:map(fun(ViewerPid) -&gt;
          ViewerPid ! {self(), set_value, Value} end, ViewerSet)
    end.
  </code></pre>
  
  <p>This is how I initiate the process:</p>
  
  <pre><code>process() -&gt;
    C = spawn(fun() -&gt; looper(no_value, empty_set) end),
    {ok, C}.
  </code></pre>
  
  <p>The problem is that when I run it I get this error:</p>
  
  <pre><code>=ERROR REPORT==== 2-Nov-2014::15:03:07 ===
  Error in process &lt;0.367.0&gt; with exit value: {function_clause,[{lists,map,
  [#Fun&lt;sheet.2.12938396&gt;,empty_set],[{file,"lists.erl"},{line,1223}]},{lists,map,2,
  [{file,"lists.erl"},{line,1224}]},{sheet,cell_loop,2,[{file,"sheet.erl"},{line,93}]}]}
  </code></pre>
  
  <p>From what I understand is that despite the if expression that I have to check whether or not the list is empty, it still tries to map over it. </p>
  
  <p>So what am I doing wrong with the expression?</p>
  
  <p>Thanks</p>