title: Elixir equivalent to while true
body: <p>I want  to rewrite this method (written here in Python) in Elixir</p>
  <pre class="lang-python prettyprint-override"><code>def something()
      while True:
          x = function()
          y = function()
          if x != y:
              return x
      
  </code></pre>
  <p><code>function()</code> generates a random value, so the execution would end sooner or later.</p>
  <p>My problem is to translate the <code>while True</code> in the most &quot;functional way&quot; possible.</p>
  <p>I came up with this solution, but I think is not very readable.</p>
  <pre class="lang-ex prettyprint-override"><code>
  def something() do
      internal(function(), function())
  end
  
  defp internal(a, a) do
      internal(function(), function())
  end
  
  defp internal(a, _) do
      a
  end
  </code></pre>
  <p>Is there a better way to do it?</p>
  <p>PS: <code>function()</code> must be always called twice at every cycle and it cannot be rewritten.</p>
  <p>Thanks</p>