Does anyone know of any tricks for array comparison in teletype? Say have a pattern looks something like [0 10 20 30] and I want to run it through a conditional to check the entire value of the pattern. Naively, I could so something like:
IF NE P 0 10: break
IF NE P 1 20: break
IF NE P 2 30: break
IF NE P 3 40: break
;;;OK, it matches!
But this obviously blows 4 lines of code. Is there a shorter way to do this?
That’s something for which a custom operator would be the ideal solution as it can be very easily and cleanly done in a very small amount of C/C++ code…
I’m not in front of my Teletype now but something like this should work though :
Note : in this example I compare the first X variables of pattern 1 with the first X variables of pattern 4, adjust as desired.
A 1; X 4
L 0 X: A AND A EQ PN 1 I PN 4 I
So we start with A being true (1) and for each index A only stays true if the patterns values are equal for that index. So at the end A is either 1 if the (sub)patterns are identical or 0 otherwise.
I’m not sure the whole second line fits or not, it’s 31 characters so probably ok.
It’s not optimal at all and keeps comparing even after one value differs but I guess that’s ok for Teletype scripts
Edit : you can shave one character by using && instead of AND :
A 1; X 4
L 0 X: A && A == PN 1 I PN 4 I
Basically, I track the number of hits for a given instrument- say a kick drum in the first pattern.
So, [0 1 1 2] could mean, the kick triggered 0 times on the last 8th note, 1 time on the 8th note before that, 1 time on the 8th note before that, 2 times on the 8th note before that. Then I apply rules on this history to determine if I should trigger a snare for example.
I have gen~ code that does this pretty well but I prefer using teletype whenever possible as it is simpler.