【问题标题】:Mozart Function parse error莫扎特函数解析错误
【发布时间】:2014-12-28 21:05:25
【问题描述】:

当我试图在这个莫扎特在线上运行这个阶乘函数时 complier

我遇到了解析错误!

    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}}

我如何在这个在线compiler 上运行这段代码!

【问题讨论】:

  • 您是否收到特定的错误消息?还是对一行的引用?
  • 我刚从互联网上得到这段代码,我只是想在线运行它,我无法合并这段代码以正确运行,当我编写函数时它只给我语法错误第 11 行,当我将它与仿函数导入应用程序系统合并时给我解析错误!

标签: factorial oz mozart


【解决方案1】:

您的代码是 Oz 脚本。它可以在交互式 Mozart IDE (Emacs) 中使用。

在线编译器需要一个 Oz 程序,即函子定义。试试这个代码:

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

【讨论】:

    猜你喜欢
    • 2014-05-10
    • 1970-01-01
    • 2010-09-22
    • 1970-01-01
    • 1970-01-01
    • 2013-07-03
    • 1970-01-01
    • 2011-06-18
    • 1970-01-01
    相关资源
    最近更新 更多