我想在Gforth中编写一个while()循环。不幸的是,唯一的在线教程由于缺乏示例而无用,并且有关计数循环的示例(我不需要的内容)似乎根本不同。你能给出一些具体的示例来代表类似这样的东西吗?while (x > 3) { print(x); x--; } 或者说,只是一些具体的方式来表示任何形式的东西: while (predicate) { expression(s) }
你的第一段代码翻译为:\ Assuming x is on the top of the stack. begin dup 3 > while dup . 1- repeat \ Or if x is in memory. begin x @ 3 > while x ? -1 x +! repeat 第二个:begin predicate while expressions repeat