Short Erlang function to demonstrate hd and tl I'm simultaneously learning Erlang and writing a short guide on list operations. Here is a trivial function I wrote to demonstrate hd and tl:

headAndTail(List) -&gt;
  Head = hd(List),
  Tail = tl(List),
  {Head, Tail}.


This works, but it throws "Warning: variable 'Head' is unused." I know this function could be written with {hd(List), tl(List)}, but is the way I did it considered bad practice?
First, your code sample does not produce warnings under the Erlang compiler (I'm almost certain that specific version does not matter).

$ cat bar.erl
-module(bar).

-export([headAndTail/1]).

headAndTail(List) -&gt;
  Head = hd(List),
  Tail = tl(List),
  {Head, Tail}.

$ erlc bar.erl 
$ 




Now, regarding bad practises, the only comment is that what you are trying to do with hd and tl is usually done with pattern matching in functional programming languages:

headAndTail([Head|Tail]) -&gt;
    {Head, Tail}.


Another minor bad practise is that Erlang's common naming convention does not use CamelCase for function names, preferring names_with_underscores instead. CamelCase is ok for variables.