< Back to IRCAM Forum

Set value of first and last elements in list?

I’m working with a loop structure that generates variable-length lists to define BPFs and BPCs. I’d like to ensure that the first and last elements are always zero. Is there a straightforward way to do that ?

Hi Dave,

Yes, depending on your generated values in the loop. Can you send such a loop just to see how it is structured?


Hi Karim ! Hopefully this will clarify my intention. :slight_smile:

subpatch-bpf-loop.omp (8.0 KB)

Dear Dave,

If i understand you well, you don’t need at all omloop. You should instead use repeat-n as so:

The zeros are for ys i believe, no?
the xs in your loop are not ordered. So we will generate n x-points and recalculate them as dx->x list. Concerning the ys, you have only to append 0s at the beginning and at the end of your random list. Hope i got your idea right.


the patch:
subpatch-bpf-loop1.omp (16.0 KB)

Hi Karim,

That’s perfect, it works as needed and the logic is clear. I made a variant for another purpose that guarantees non-zero values at the start and end. Thank you very much !

Best regards,