Finding the index of an item in a list
Hello! I’m a new member of the forums, but it looks like there’s a fantastic community here that I’m excited to be a part of. Anyway, my question:
If I have a list, say 2 3 0 4 0 5 6 0 7 0 1 0 what’s an efficient way to get the index of the "1?" I’ve tried looking at the documentation of the zl object, but I can’t find anything that fits what I’m looking for.
Try zl sub
You could also use listfunnel, which takes a list and outputs each element one at time preceded by its index.
zl sub will return each index in the max window but only the last index will be viewable within the patch. If you are dealing with multiple occurrences of a value in a list, then your best bet is to combine [zl sub] and [zl group]. great combo… powerful and compact.
----------begin_max5_patcher---------- 605.3oc2W9sjZBCEF+Z3oHSt15j+HAnOA6E6zWfNc5fXVM6.AFRvZ2c128lD jJVkVTQ5N6EFIGOmjuyOOy2nu56AWVriqffOC9Jvy6UeOOWHa.u868f4I6Ry RTtzfoE44boFNq4yz7cZW775LsnLiCDRkNQlZN08o7T05k1TPyQ6iHqyKp0Y bs6Hai9TgTqDuvswvGRtrhqLWXhVTH+dEOU2nVbH0jBfFXWQ6W.eqsnDc5Fg bc2BXz4jfYfEDaxw34lmwQcpQrx0HEKe9SDDrinjI4NQAefmskqEoIfuvq4f GEq27aPX5Igrskv1Xu46aWlcifUYZiNXcrn5o.hFZASCdBcXsO7fimd7jyUp j07SvCAD.vX3YY.95lrZlohYCdxJngVKbuE3JAy5TSijz+rj2T.DdNpFcaPk bEPUx+g4lOgoujAVWUTWddpRtEpxhtTphC6P0n+JUm0CYieOQVU8R.9NP1Ez KjrwjaFrXzzS19MBv.DXgYM.vLOEZdYhbGbFvW5LLyMBiQQWoyvA+s++Xdb8 ZYXGRHjgRTR3XX0F9AwpsW9LBllrOHll8wnQv9i9dx8i5b+Pig6WeH6V8wHi GubGOLSH+y+8hS713GCQUQcUZq3Z8TAGZfUbkVHc1ScSBcTRaDqVwkc+00qD pjkYbWKhN6WmCVO1qB+OzS7Q4b2kCZ.xYZnS7.TSzjAG1.TS3joF5.TCax9l hNfwX1jwFx.XC8JYSiETRY4VdkZ+Q5Dhww94hJ6V1L2VgrYqy2EVw2JZym5h jTY7a0Fy15pFKwcQLnu8ddy+WvSJYHJ -----------end_max5_patcher-----------
Forums > MaxMSP