title: Erlang string to atom and formatting a string
body: <p>Using just <code>list_to_atom()</code> gives:</p>
  
  <pre><code>list_to_atom("hello"). 
  hello
  list_to_atom("Hello").
  'Hello'
  </code></pre>
  
  <p>why the difference? </p>
  
  <p>I am trying to format a string with numbers, strings and atoms as follows:</p>
  
  <pre><code>lists:flatten(io_lib:format("PUTVALUE ~p ~p", [list_to_atom("hello"), 40])).
  "PUTVALUE hello 40"
  lists:flatten(io_lib:format("PUTVALUE ~p ~p", [list_to_atom("Hello"), 40])).
  "PUTVALUE 'Hello' 40"
  </code></pre>
  
  <p>what is the best way of doing this in Erlang?</p>
  
  <p><strong>Edit:</strong> To make the question clear, there are more values than the example above and in some cases the value can be a string or an atom, like</p>
  
  <pre><code>lists:flatten(io_lib:format("PUTVALUE ~p ~p ~p", [list_to_atom("hello"), X, 40])).
  </code></pre>
  
  <p>where the first parameter is always a string but <code>X</code> can either be an atom or a string. The third parameter is always a number. </p>