Hereβs a simple loop example in Cairo calling another function:
@view
func test_loop{bitwise_ptr: BitwiseBuiltin*, range_check_ptr}() {
let mut n = 5;
loop {
test_function_to_call();
n = n - 1;
if n == 0 {
break;
}
}
return ();
}
Make sure test_function_to_call is defined and callable. Recursion limits occur due to call stack size, so loops avoid that. Also, confirm Protostar config supports your syntax and try using let mut for mutable variables instead of tempvar in loops.