get the range from a number in a list
maybe a dummy question, sorry for the hassle. So I have a list of, say 4 numbers : 2 4 9 11 and when I get the number – say 4 – from another part of the patch, I’m looking for a way to test this number in the list below and output it’s range, in fact here 2.
I can’t figure it out with zl, as zl nth gives me the value of the nth element of the list, and I need its range.
Thanks for your help.
I am not sure if I understand what you mean by "range" – do you mean the position of the item on the list? An easy solution is this:
-- Pasted Max Patch, click to expand. --Copy all of the following text. Then, in Max, select New From Clipboard.----------begin_max5_patcher---------- 825.3ocyX9sbiBBEF+ZySAiWmsif+I5d29bzoSGhRaYWDxHjca2N8cegCZVS aShFSRyEINfJ7wO93vQdcVP3R0yLcH56naQAAuNKH.pxUQPa4fvZ5ykBpFdr vZlVSejEN2eOC6YCTOF2U0pFllIMTCWIuugUZ7MONN6ln4HBIwcIp8Ozcsuk bcMWJXFnWHsU9fRZjzZFzC+ngSEccBuBpSs7meKdSOaaC0ZSWif6zC0T9DW9 Xesjh8ZIEt.Ev48TiuYLurh4egvvM2xoIM+uvMvjahb091rYt+lOQFVbPDt. zaT1oFgQGKBwEYWUHjLLDhyWbhQHo3nQXb9WBBKU00VB8ADVJ3k+BQkHlf4d .jQgrhlJDHtQiVozbGTQbIx7DCI35MsgfKYkp0RSe7sESwiho4eNSi1CSi7T j.WRfKwI8X5YGbJGV3ZTqCEYaKGAoUUH6nXIqQ6JdaoRHt6bwsrQys3Xv9U3 4VZzkjatUpFzR1CpFF5E0Zj1PaLgSGCIiFCjH+HGBpgIw9vsmVL3cAmfg2NB ZS1yvKsMTCrGreVdqg2Gh3vcyWnvkT4iWj32IgSNRLN+niDms3KIRrj8Gqv+ .KLHNZ4z8I3ri0mfwEvpAxMoWa9jRAi1bB7JjQ6UHIvxlLvjzkMwEyprbswn j60Tze3M975h8wFv37tfCGZpucN+TlD2bThcuHmJl9Tb13mg8t+bv7mEecDL .ROf0fvnOODY5XXxN1XLYOLwmvbaFUKhG7NGc+bEu.XZE0lBFGwmtuI9X8M3 L3qJSxOLitLFGg3Djrw3cLszn.BgjVb38P5aW1MYZqVS+Mq5dqzrc38Tioga CM5OJifM.JHjYy0BFE.Q8HsCrPW.4d+tS.AFMt52l1Z05lxNw1sypcAYmRqX ZCWBewYuGxtVC8+A8S7pJlreVn07pUJ6pCc2BMe1G9cYH1OuNsszNBwNXwFs kP1sXICWrSTRICPQwag3yshbmkzAkDYbynSURQWcRxcVGWYRxkz+0ljHCPRu aU4gCOj.AR8muQr8CTaKL0YzgPunKK9xFXzgKmjFhhdmruJLYjixigy8Gsq8 ih6JM0PYm40n1BuM6ev28N6b -----------end_max5_patcher-----------
However, this only works if you DON’T have repeating numbers in your initial list of numbers. Can’t think of anything else (i don’t really work with lists much), so maybe someone more knowledgeable on [zl] or other list-manipulation objects can help you out more (I’m curious as to the answer too)
thanks – a more dummy one : how to save your text as a maxpatch (on a mac) ? thanks.
Copy the whole kaboodle in your clipboard (so from —begin to —end, including those lines.
Then in the Max window choose either File -> New from clipboard or press its key function (on Windows control-alt-N, dunno on Mac).
Thanks, the patch works for me
Forums > MaxMSP