recreating Peter Elsea's Lmatch/Lpos objects

yunny's icon

I'm trying to recreate the behaviour of Peter Elsea's Lmatch/Lpos object: basically rotating a list till it matches another list and reporting at which position the match was found. I'm trying to go through rotations quickly using uzi and zl.rot. I thought I could get the position index from uzi by banging a pause when zl.compare reports a match. But I just can't get it to work. Anybody got an idea?

(Yes, I could just use the Lobjects externals but that's not very educational :) )

Elsea describes the Lpos object as such:

Lpos will search for a short list within a longer one and report the position of the first
member. If the list occurs more than once, all matching positions are reported in a list. If
there is no match, the list is output from the right. (Lpos replaces an older version called
Lmatch.)

Source Audio's icon

If you get an answer , than what about educational part ?
I mean trying to find out why something does not work.
You could at least post your construct, then one could tell you what is wrong.

But if you prefer cooked answer ...
if you look for a list then you need to slice rotated list,
then match nn nn nn
if found grab current rotation index and continue.
uzi should output only as many numbers as input list length is -1
and you rotate into negative direction, right ?