python - Output gets erased in a recursive function -
i have created recursive function in python down below calculates power reached node other , finding based on radius of coverage of nodes.
what want take output function , call recursive function on 1 more time without losing output got , don't know how that.
this function below:
def find_new_int(node_in_ex, old_inters): global power_sensitivity global copy_of_int_list intersection_list_method = [] wall_coordinates in lines: if intersection_rand_point(wall_coordinates[0], wall_coordinates[1], node_in_ex-1, old_inters) not false: intersection_list_method.append(intersection_rand_point(wall_coordinates[0], wall_coordinates[1], node_in_ex-1, old_inters)) intersection_list_method = sorted(list(itertools.chain(*intersection_list_method)), key=cal_distance_av) points in intersection_list_method: if cal_pow_rec_plndwall(node_in_ex, points) > power_sensitivity: return intersection_list_method points in intersection_list_method: return find_new_int(node_in_ex, points)
i want loop on intersection_list_method outputed first time ran function >>if<< function didn't return intersection_list_method in 3rd line bottom. problem im doing here when call
find_new_int(node_in_ex, points)
again intersection_list_method looping on gets erased , new 1 created want loop on each point in list instead , see if function return list every point in intersection_list_method till ends
any help?
your code this:
for points in intersection_list_method: return find_new_int(node_in_ex, points)
but want is:
but if didn't find point power > power sensitivity in list want again call same function on each point in list again till returns something.
assuming opposite of "returns something" "returns none
", this:
for points in intersection_list_method: result = find_new_int(node_in_ex, points) if result not none: return result
Comments
Post a Comment