# Mind blowing Elixir

**URL:** <https://forum.elixirforum.com/t/mind-blowing-elixir/13949>\
**Category:** Discussions\
**Tags:** community\
**Created:** [April 29, 2018, 5:35pm UTC](https://forum.elixirforum.com/t/mind-blowing-elixir/13949 "2018-04-29T17:35:44Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![idi527](https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/i/85e7bf/32.png) [@idi527](https://forum.elixirforum.com/u/idi527)\
**Post date:** [April 29, 2018, 9:07pm UTC](https://forum.elixirforum.com/t/mind-blowing-elixir/13949/8 "2018-04-29T21:07:33Z")

</div>

```elixir
def calculate(arr) when length(arr) <= 1, do: # ...

```

could be expressed as

```elixir
def calculate([]), do: # ...
def calculate([elem]), do: # ...

```

which is a bit easier to understand (at least for me, since I can’t think of a function which would handle both an empty list and a list with a single element in it the same way), and probably slightly [faster](http://erlang.org/doc/efficiency_guide/commoncaveats.html#id62873).

---

_[View the full topic](https://forum.elixirforum.com/t/mind-blowing-elixir/13949)._
