title: Why is this elixir function undefined
body: <p>I have rebooted my learning of the Elixir language.  I am trying to try a variation of the Fizzbuzz problem with the following code.</p>
  
  <pre><code>defmodule FizzBuzz.Fb4a do
  
    def upto(n) when n &gt; 0 do
      fizzbuzz(n)
    end
  
    defp toTuple(n), do: {n, ""}
  
    defp toString({v,a}) do
      if String.length(a) == 0 do v else a end
    end
  
    defp genFB(d, s) do
      fn ({v, a}) -&gt;
        cond do
          rem(v, d) == 0 -&gt; {v, a+s}
          true           -&gt; {v, a}
        end
      end
    end
  
    # do3 = genFB(3, "Fizz")
    # do5 = genFB(5, "Buzz")
    # do7 = genFB(7, "Bang")
  
    defp fizzbuzz(n) do
      1..n
      |&gt; Enum.map(&amp;toTuple/1)
      # |&gt; Enum.map(&amp;do3/1)
      # |&gt; Enum.map(&amp;do5/1)
      # |&gt; Enum.map(&amp;do7/1)
      |&gt; Enum.map(&amp;toString/1)
    end
  
  end
  </code></pre>
  
  <p>When I uncomment the <code>do3 = genFB(3, "Fizz")</code> line, I get the following error:</p>
  
  <pre><code>** (CompileError) lib/fib4a.ex:22: undefined function genFB/2
  </code></pre>
  
  <p>I do not understand how <code>genFB/2</code> can be undefined or not seen by the compiler.  I have obviously missed something very fundamental in the definition of functions somewhere.  What have I missed?</p>