R中的do-while循环 [英] do-while loop in R
本文介绍了R中的do-while循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何编写同时做"风格的循环吗?
I was wondering about how to write do-while-style loop?
我发现了此帖子:
您可以使用repeat {}并使用if()和 用"break"控制字退出循环.
you can use repeat{} and check conditions whereever using if() and exit the loop with the "break" control word.
我不确定这到底是什么意思.如果您理解和/或有其他解决方案,请有人详细说明吗?
I am not sure what it exactly means. Can someone please elaborate if you understand it and/or if you have a different solution?
推荐答案
很容易解释.
repeat{
statements...
if(condition){
break
}
}
或者类似的东西我会认为.要获得do while循环的效果,只需在语句组末尾检查条件即可.
Or something like that I would think. To get the effect of the do while loop, simply check for your condition at the end of the group of statements.
这篇关于R中的do-while循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文