       24
 
   """
-  @spec reduce(t, (element, any -> any)) :: any
+  @spec reduce(t, (element, acc -> acc)) :: acc
   def reduce(enumerable, fun)
 
   def reduce([h | t], fun) do

      {[[1], [2], [3], [4], [5]], 15}

  """
  @spec flat_map_reduce(t, acc, fun) :: {[any], any}
        when fun: (element, acc -> {t, acc} | {:halt, acc}),
             acc: any
  def flat_map_reduce(enumerable, acc, fun) do
    {_, {list, acc}} =
      Enumerable.reduce(enumerable, {:cont, {[], acc}}, fn entry, {list, acc} ->

      {[2, 4, 6], 6}

  """
  @spec map_reduce(t, acc, (element, acc -> {element, acc})) :: {list, acc}
  def map_reduce(enumerable, acc, fun) when is_list(enumerable) do
    :lists.mapfoldl(fun, acc, enumerable)
  end
