Why doesn’t this script stop?

This may be a bug, or perhaps I’m missing something …

I made a variadic TO DO LIST block, which when applied looks like: Programming tools SANDBOX script pic 22

I made two implementations, one with FOR EACH, and the other: recursive.

Programming tools SANDBOX script pic 23 vs. Programming tools SANDBOX script pic 25

The FOR EACH implementation stops after having done the stuff it was asked to. The recursive implementation however keeps running (idling, actually) after it has finished all of its chores.

Does anyone know why?

just drag the allbutfirstof into the arrows just like what you would normally do

Do you mean: Programming tools SANDBOX script pic 27? - True, that version stops.

I tried yet another version: testing for ITEM 1 OF the input list instead of whether the list is empty:

Programming tools SANDBOX script pic 30, which also stops.

Now returning to the apparently defective implementation I decided to display the length of the input list before testing:

Programming tools SANDBOX script pic 31

As it turns out, with 2 inputs, the length of the input list is 2 at first, then 1, and after that it remains one, no matter how often the function is called with INPUT LIST: ALL BUT FIRST OF (action).

I’ll stop here, and leave it to the Snap! Team to find out what is happening here.

i'd guess the length is 1 because you left an empty slot in the to do list block

Nope! I just now tried:

, and it doesn’t stop.

that's still an empty slot, all you did was change the shape. click the left arrow on the variadic.

This is what I did after d4s_over_dt4 suggestion - seems to work
image

I think your trying to count angels on a pinhead even though you know the answer is 42 :slight_smile:

OK, I see it now.
I honestly didn’t grasp it (and still don’t, fully).
Input lists are at least somewhat complicated (or may be it’s just me :smirk:)
On the other hand I’m happy it’s not really a bug.
Thanks for your help, everyone.

Couldn't you remove the run entirely and just do
untitled script pic (84)

EDIT: Sorry, this is redundant, I didn't see that d4s_over_dt4 had already proposed this solution. Sorry again!

thatswhatimean

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.