Hi everyone,
I can’t figure how to solve an “apparently’“ simple problem on lists.
I’m dealing with a list of values following this pattern :
{0}
[400;0;0;0;0;120;0;0;30;0]
{1}
[650;0;0;320;0;0;0;0;0;0;0;110;0]
I’d like to replace the 0 values by the previous positive value. Following this simple rule, I expect :
{0}
[400;400;400;400;400;120;120;120;30;30]
{1}
[650;650;650;320;320;320;320;320;
320;320;320;110;110]
As you could have seen, number of items in branches may differ.
I really hope someone could help me 
Thanks,
Thib
Tom_Newsom
(Tom Newsom)
2
Is it always that structure? Single digits separated by zeros? Never two non-zero numbers next to each other?
Does it matter if it were?
Tom_Newsom
(Tom Newsom)
4
Not sure till I try, but it’s good to have clear specification of a problem 
It’s just a falling edge detector.
but we are sure that the first item is not 0 ?
I would assume, but in that case make <“null”>
Tom_P
9
you still have to define:
what should happen if the list starts with 0 ?
[0;0;400;0;0;0;0;120;0;0;30;0]
and yes, solve it by a simple script as @Jakob_v_Schirmeister showed.
Like I said, you then start replacement with a null.
Tom_Newsom
(Tom Newsom)
11
Well, just for fun, here’s a way without a script 
replace following zeros TN.gh (9.0 KB)
2 Likes