joyofelixir icon indicating copy to clipboard operation
joyofelixir copied to clipboard

Chapter 14: List recursion in a function

Open radar opened this issue 8 years ago • 0 comments

We should show an example of doing list recursion in a function here, because it is hinted at in Chapter 6.

defmodule People do
  def list_names([]), do: :ok
  def list_names([%{"name" => name} | names]) do
    IO.puts name
    list_names(names)
  end
end

radar avatar Sep 04 '17 07:09 radar