Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning about recursion #40

Open
karthikchiru12 opened this issue Aug 5, 2024 · 0 comments
Open

Warning about recursion #40

karthikchiru12 opened this issue Aug 5, 2024 · 0 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers

Comments

@karthikchiru12
Copy link
Member

karthikchiru12 commented Aug 5, 2024

  • Essentially, using a subTransform block and for each, one can achieve recursion. Below is an example of a factorial using recursion.
 _$factorial :
   n : derived.item
   n1 : derived.n -1
   isOne : derived.n == 1
   item : derived.isOne ? derived.n : derived.n * ([derived.n1] | forEach({},derived._$func) | pluck(['item']))

 output : [1,2,3,4,5,6] | forEach({},derived._$factorial) | pluck(['item'])

A simple and short-term solution would be to add a check if anywhere in the code _$func is used. Then, in the UI, throw a warning that "If termination condition is not met, in recursion, the playground may get stuck. "

A long-term solution would involve adding a max run duration if and only if there is a recursion involved in the code.

@karthikchiru12 karthikchiru12 added bug Something isn't working enhancement New feature or request good first issue Good for newcomers labels Aug 5, 2024
@karthikchiru12 karthikchiru12 self-assigned this Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant