10.4.5 흐름 제어 요소
10.4.5 흐름 제어 요소
R에는 특별한 문법 구조로 다음 제어 구조가 있어요.
if ( cond ) expr
if ( cond ) expr1 else expr2
while ( cond ) expr
repeat expr
for ( var in list ) expr
이 구조들 안의 표현식은 보통 복합 표현식(compound expression)이에요.
반복 구조(while, repeat, for) 안에서는 break(반복 종료)와 next(다음 반복으로 건너뛰기)를 사용할 수 있어요.
내부적으로 이 구조들은 다음과 같은 함수 호출로 저장돼요.
"if"(cond, expr)
"if"(cond, expr1, expr2)
"while"(cond, expr)
"repeat"(expr)
"for"(var, list, expr)
"break"()
"next"()