Skip to content

Warning about recursion #40

@karthikchiru12

Description

@karthikchiru12
  • 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.

Metadata

Metadata

Labels

bugSomething isn't workingenhancementNew feature or requestgood first issueGood for newcomers

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions