0

when am trying to run this factorial function on this Mozart online complier

i got parse error !

    declare
fun {Fact N}
   fun{Aux N Nmax FactNminus1}
      if N>Nmax then nil
      else (FactNminus1*N)|{Aux N+1 Nmax FactNminus1*N}
      end
   end
in
   {Aux 1 N 1}
end
{Browse {Fact 4}}

how i can run this piece of code on this online compiler !

Mohamed A. Shebl
  • 384
  • 3
  • 5
  • 16
  • Do you get a specific error message? Or a reference to a line? – fejese Dec 28 '14 at 21:07
  • i just got this piece of code from the internet and i just wanted to run it online, i can't merge this code to run correctly, when i write the function only it gives me syntax error at line 11, when i merge it with functor import Application System gives me parse error ! – Mohamed A. Shebl Dec 28 '14 at 21:42

1 Answers1

0

Your code is an Oz script. It can be used in the interactive Mozart IDE (Emacs).

The online compiler expects an Oz program, i.e. a functor definition. Try this code:

functor
import
   Application
   System
define
   fun {Fact N}
      fun{Aux N Nmax FactNminus1}
         if N > Nmax then nil
         else (FactNminus1*N)|{Aux N+1 Nmax FactNminus1*N}
         end
      end
   in
      {Aux 1 N 1}
   end

   {System.show {Fact 4}}
   {Application.exit 0}
end
wmeyer
  • 3,426
  • 1
  • 18
  • 26