발행일 : 03/10/2025

Recursion

The Recurse() function makes a recursive call of the defining function. For example, you can make a function to calculate factorials. A factorial is the product of a number, the number minus 1, the number minus 2, and so on, down to 1.

myfactorial = Function( {a},
	If( a == 1,
		1,
		a * Recurse( a - 1 )
	)
);
myfactorial( 5 );

120

You can define recursive calculations without using Recurse(). For example, you could replace Recurse() by myfactorial, and the script would still work. However, Recurse() offers these advantages:

It avoids name conflicts when a local variable has the same name as the function.

You can recurse even if the function itself has not been named (for example, assigned to a global variable, such as myfactorial above).

더 많은 정보를 원하십니까? 질문이 있습니까? JMP 사용자 커뮤니티에서 답변 받기 (community.jmp.com).