Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要创建一个 X 和 Y (含)之间所有整数的递减列表。
我正在尝试这个:
declare local fun {Dec From To} From | {Dec From-1 To} end in {Browse {Loop 8 1}} % Should Display: [8, 7, 6, 5, 4, 3, 2, 1] end
Mozart 编译器显示代码被接受,但没有打开浏览窗口。
怎么了?
我认为没有显示任何内容,因为您的函数Dec是一个无限循环,因为您从未设置何时停止,这就是不显示浏览窗口的原因。
函数应该是:
fun {Dec From To} if From == To then nil else From | {Dec (From-1) To} end end
我希望这可以帮到你 :)