2

I keep on getting an error, variable MainMirror Not introduced. How do I fix this?

fun {MainMirror Int}

    local Mirror in
        fun {Mirror Int Acc}
       if Int == 0 then Acc
       else
          Acc + {Mirror (Int div 10) (Acc mod 10)} end
        end
        {Mirror Int 0}
    end
end
{Browse {MainMirror 1234}}
Will
  • 24,082
  • 14
  • 97
  • 108
  • 2
    If you are using the Emacs IDE: add a simple "declare" statement (without arguments) at the start of your script. – wmeyer May 16 '15 at 09:02

1 Answers1

0

You did not declare your variable MainMirror. In fact a function is a variable in OZ. You can declare MainMirror using 'declare' operator or 'local'.

declare
fun {MainMirror Int}

local Mirror in
    fun {Mirror Int Acc}
   if Int == 0 then Acc
   else
      Acc + {Mirror (Int div 10) (Acc mod 10)} end
    end
    {Mirror Int 0}
end
end
{Browse {MainMirror 1234}}
obronchain
  • 36
  • 4