list question


    Feb 16 2007 | 3:58 am
    Hi
    I'm looking for an object (or patch) to perform the following operation on a list:
    input: 1 2 3 4 5 6 7 8
    output: 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8
    Any suggestions?
    Thanks David

    • Feb 16 2007 | 5:49 am
      There has to be an easier way to do this. This code feels very baroque to me. But, anyway, here is one solution.
      b
      David Morneau wrote: > Hi > > I'm looking for an object (or patch) to perform the following operation on a list: > > input: 1 2 3 4 5 6 7 8 > > output: > 1 2 > 2 3 > 3 4 > 4 5 > 5 6 > 6 7 > 7 8 > 8 > > Any suggestions? > > Thanks > David > -- > ------ > http://5of4.com >
      -- barry threw composition : sound : programming http://www.barrythrew.com bthrew(at)gmail(dot)com 857-544-3967
      Today, Noise is triumphant and reigns sovereign over the sensibility of men. - Luigi Russolo, The Art of Noises
    • Feb 16 2007 | 6:05 am
      This one's pretty compact. It has a few useful idioms like the trigger/gate combo and the delay line using zl reg.
      wes
    • Feb 16 2007 | 6:23 am
      Nice.
      b
      Wesley Smith wrote: > This one's pretty compact. It has a few useful idioms like the > trigger/gate combo and the delay line using zl reg. > > wes > > #P window setfont "Sans Serif" 9.; > #P window linecount 1; > #P newex 200 257 36 196617 zl reg; > #P newex 243 199 31 196617 t 1 b; > #P newex 150 114 40 196617 t b l 0; > #P newex 243 227 29 196617 gate; > #P newex 200 332 32 196617 print; > #P newex 226 167 27 196617 t i b; > #P newex 243 301 58 196617 pack 0 0; > #P newex 243 256 42 196617 zl reg; > #P newex 268 140 55 196617 zl group 1; > #P message 150 93 163 196617 11 12 13 14 15 16 17 18 19; > #P connect 4 0 9 1; > #P lcolor 15; > #P fasten 4 0 2 1 231 193 280 193; > #P lcolor 15; > #P fasten 1 0 4 0 273 162 231 162; > #P fasten 1 0 3 1 273 162 296 162; > #P fasten 7 0 9 0 155 249 205 249; > #P lcolor 14; > #P connect 9 0 5 0; > #P connect 6 0 2 0; > #P fasten 7 2 6 0 185 223 248 223; > #P lcolor 14; > #P connect 8 0 6 0; > #P fasten 8 1 6 1 269 221 267 221; > #P connect 4 1 8 0; > #P fasten 7 1 1 0 170 135 273 135; > #P lcolor 14; > #P connect 0 0 7 0; > #P connect 2 0 3 0; > #P fasten 3 0 5 0 248 325 205 325; > #P window clipboard copycount 10; >
      -- barry threw composition : sound : programming http://www.barrythrew.com bthrew(at)gmail(dot)com 857-544-3967
      Today, Noise is triumphant and reigns sovereign over the sensibility of men. - Luigi Russolo, The Art of Noises
    • Feb 16 2007 | 9:32 am
      Hello.
      Here's another compact solution which is very similar to Barry's. Uses [int] rather than [zl reg] to store the values.
      Jonathan
      On 16/02/07, Barry Threw wrote: > > Nice. > > b > > > Wesley Smith wrote: > > This one's pretty compact. It has a few useful idioms like the > > trigger/gate combo and the delay line using zl reg. > > > > wes > > > > #P window setfont "Sans Serif" 9.; > > #P window linecount 1; > > #P newex 200 257 36 196617 zl reg; > > #P newex 243 199 31 196617 t 1 b; > > #P newex 150 114 40 196617 t b l 0; > > #P newex 243 227 29 196617 gate; > > #P newex 200 332 32 196617 print; > > #P newex 226 167 27 196617 t i b; > > #P newex 243 301 58 196617 pack 0 0; > > #P newex 243 256 42 196617 zl reg; > > #P newex 268 140 55 196617 zl group 1; > > #P message 150 93 163 196617 11 12 13 14 15 16 17 18 19; > > #P connect 4 0 9 1; > > #P lcolor 15; > > #P fasten 4 0 2 1 231 193 280 193; > > #P lcolor 15; > > #P fasten 1 0 4 0 273 162 231 162; > > #P fasten 1 0 3 1 273 162 296 162; > > #P fasten 7 0 9 0 155 249 205 249; > > #P lcolor 14; > > #P connect 9 0 5 0; > > #P connect 6 0 2 0; > > #P fasten 7 2 6 0 185 223 248 223; > > #P lcolor 14; > > #P connect 8 0 6 0; > > #P fasten 8 1 6 1 269 221 267 221; > > #P connect 4 1 8 0; > > #P fasten 7 1 1 0 170 135 273 135; > > #P lcolor 14; > > #P connect 0 0 7 0; > > #P connect 2 0 3 0; > > #P fasten 3 0 5 0 248 325 205 325; > > #P window clipboard copycount 10; > > > > -- > barry threw > composition : sound : programming > http://www.barrythrew.com > bthrew(at)gmail(dot)com > 857-544-3967 > > Today, Noise is triumphant and reigns sovereign over the sensibility of > men. > - Luigi Russolo, The Art of Noises >
    • Feb 16 2007 | 9:56 am
      On 16 Feb 2007, at 10:32, Jonathan Green wrote:
      > Hello. > > Here's another compact solution which is very similar to Barry's. > Uses [int] rather than [zl reg] to store the values.
      one more: call it "the ancient-sliding-window-technique" or what ever... vb
    • Feb 16 2007 | 11:37 am
      Jonathan Green wrote: > Here's another compact solution which is very similar to Barry's. Uses > [int] rather than [zl reg] to store the values.
      I think that's an ideal solution for this exercise. But the existence of an exemplary solution is no reason to miss out on zl-madness! As a bonus, one of these is very flexible... and I made a cute patch bug...
    • Feb 16 2007 | 11:54 am
      On 16/02/07, dlurk wrote: > > Jonathan Green wrote: > > Here's another compact solution which is very similar to Barry's. Uses > > [int] rather than [zl reg] to store the values. > > I think that's an ideal solution for this exercise. But the existence > of an exemplary solution is no reason to miss out on zl-madness! As a > bonus, one of these is very flexible... and I made a cute patch bug...
      This is a very good point. You are right that my [int] solution is bespoke to the problem. Maybe javascript could offer another solution that works with any data types since it type-casts automatically?
      Jonathan
    • Feb 16 2007 | 12:20 pm
      Hi,
      Here is a 2-objects solution
      get the lobjects first
      Falk
      Am 16.02.2007 um 04:58 schrieb David Morneau:
      > > Hi > > I'm looking for an object (or patch) to perform the following > operation on a list: > > input: 1 2 3 4 5 6 7 8 > > output: > 1 2 > 2 3 > 3 4 > 4 5 > 5 6 > 6 7 > 7 8 > 8 > > Any suggestions? > > Thanks > David > -- > ------ > http://5of4.com
    • Feb 16 2007 | 4:12 pm
      Yes, Lobjects!!! But why just two elements?
      On 2/16/07 7:20 AM, "Falk Grieffenhagen" wrote:
      > Hi, > > Here is a 2-objects solution > > get the lobjects first > > > Falk > > > #P window setfont "Sans Serif" 9.; > #P window linecount 1; > #P newex 504 152 47 196617 zl iter 2; > #P newex 504 121 171 196617 lswap 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7; > #P message 504 92 127 196617 20 21 22 23 24 25 26 27; > #P newex 504 176 32 196617 print; > #P connect 3 0 0 0; > #P connect 2 0 3 0; > #P connect 1 0 2 0; > #P window clipboard copycount 4; > > > > > Am 16.02.2007 um 04:58 schrieb David Morneau: > >> >> Hi >> >> I'm looking for an object (or patch) to perform the following >> operation on a list: >> >> input: 1 2 3 4 5 6 7 8 >> >> output: >> 1 2 >> 2 3 >> 3 4 >> 4 5 >> 5 6 >> 6 7 >> 7 8 >> 8 >> >> Any suggestions? >> >> Thanks >> David >> -- >> ------ >> http://5of4.com >
      Cheers Gary Lee Nelson Oberlin College www.timara.oberlin.edu/GaryLeeNelson
    • Feb 16 2007 | 5:41 pm
    • Feb 16 2007 | 5:48 pm
      Falk Grieffenhagen wrote: > Hi, > > Here is a 2-objects solution > > get the lobjects first
      3rd party is noncompetitive... my attempts including one with 3 standard objects...
      (It seems I can never chime in too late into these competitions... ;-)
      -- Stefan Tiedje------------x------- --_____-----------|-------------- --(_|_ ----|-----|-----()------- -- _|_)----|-----()-------------- ----------()--------www.ccmix.com
    • Feb 16 2007 | 6:47 pm
    • Feb 16 2007 | 6:54 pm
      On 16-Feb-2007, at 18:48, Stefan Tiedje wrote:
      > 3rd party is noncompetitive...
      If you rule out 3rd party externals, you can't use abhaxions either. No Java, no Javascript. Only objects released with Max 2.2 in 1990, and only Uzi's left outlet.
      Let's make this a game for real men (and women).
      -------------- http://www.bek.no/~pcastine/Litter/ ------------- Peter Castine +--> Litter Power & Litter Bundle for Jitter Universal Binaries on the way iCE: Sequencing, Recording & Interface Building for |home | chez nous| Max/MSP Extremely cool |bei uns | i nostri| http://www.dspaudio.com/ http://www.castine.de
    • Feb 16 2007 | 7:11 pm
      Falk Grieffenhagen wrote: > not sure what you mean with element.
      try "other" in the patch...
      or another 3 object version, this time recursive with changable number of elements....
      -- Stefan Tiedje------------x------- --_____-----------|-------------- --(_|_ ----|-----|-----()------- -- _|_)----|-----()-------------- ----------()--------www.ccmix.com
    • Feb 16 2007 | 7:18 pm
      I say we have to solve it using only &&, ||, and !
      b
      Peter Castine wrote: > On 16-Feb-2007, at 18:48, Stefan Tiedje wrote: > >> 3rd party is noncompetitive... > > If you rule out 3rd party externals, you can't use abhaxions either. No > Java, no Javascript. Only objects released with Max 2.2 in 1990, and > only Uzi's left outlet. > > Let's make this a game for real men (and women). > > -------------- http://www.bek.no/~pcastine/Litter/ ------------- > Peter Castine +--> Litter Power & Litter Bundle for Jitter > Universal Binaries on the way > iCE: Sequencing, Recording & > Interface Building for |home | chez nous| > Max/MSP Extremely cool |bei uns | i nostri| > http://www.dspaudio.com/ http://www.castine.de > > >
      -- barry threw composition : sound : programming http://www.barrythrew.com bthrew(at)gmail(dot)com 857-544-3967
      Today, Noise is triumphant and reigns sovereign over the sensibility of men. - Luigi Russolo, The Art of Noises
    • Feb 16 2007 | 7:39 pm
      At 8:11 PM +0100 2/16/07, Stefan Tiedje wrote: >or another 3 object version, this time recursive with changable number of elements....
      Elegant, but seems to have problems with the text list input, although the numbers work fine:
      print: this pure print: pure list print: solution has print: has the print: the advantage print: advantage of print: of working print: working with print: with any print: any data print: data print: 20 21 print: 21 22 print: 22 23 print: 23 24 print: 24 25 print: 25 26 print: 26 27 print: 27
      The text results seem to make the Perl / Max addage "There's always more than one solution" a lie. (There is only one solution in the output)
      -C
      -- Chris Muir | "There are many futures and only one status quo. cbm@well.com | This is why conservatives mostly agree, http://www.xfade.com | and radicals always argue." - Brian Eno
    • Feb 16 2007 | 7:56 pm
      Real men can't even pronounce abhaxions (or chiche).
      On 2/16/07 1:54 PM, "Peter Castine" wrote:
      > If you rule out 3rd party externals, you can't use abhaxions either. > No Java, no Javascript. Only objects released with Max 2.2 in 1990, > and only Uzi's left outlet. > > Let's make this a game for real men (and women).
      Cheers Gary Lee Nelson Oberlin College www.timara.oberlin.edu/GaryLeeNelson
    • Feb 16 2007 | 7:59 pm
      That's a beauty Stefan
      On 2/16/07 2:11 PM, "Stefan Tiedje" wrote:
      > try "other" in the patch... > > or another 3 object version, this time recursive with changable number > of elements....
      Cheers Gary Lee Nelson Oberlin College www.timara.oberlin.edu/GaryLeeNelson
    • Feb 16 2007 | 9:02 pm
      On 16-Feb-2007, at 20:56, Gary Lee Nelson wrote: > Real men can't even pronounce abhaxions (or chiche).
      Then try this one:
      Strč prst skrz krk.
      At least it's a real sentence in a real language.
      -------------- http://www.bek.no/~pcastine/Litter/ ------------- Peter Castine +--> Litter Power & Litter Bundle for Jitter Universal Binaries on the way iCE: Sequencing, Recording & Interface Building for |home | chez nous| Max/MSP Extremely cool |bei uns | i nostri| http://www.dspaudio.com/ http://www.castine.de
    • Feb 16 2007 | 9:15 pm
      ok, Stefan got the cheese....
      falk
      Am 16.02.2007 um 20:11 schrieb Stefan Tiedje:
      > Falk Grieffenhagen wrote: >> not sure what you mean with element. > > try "other" in the patch... > > or another 3 object version, this time recursive with changable > number of elements.... > > #P window setfont "Sans Serif" 9.; > #P window linecount 1; > #P newex 110 129 55 196617 zl slice 2; > #P number 155 107 35 9 1 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0; > #P newex 97 171 33 196617 defer; > #P newex 110 150 32 196617 print; > #P newex 52 129 55 196617 zl slice 1; > #P message 88 85 127 196617 20 21 22 23 24 25 26 27; > #P message 52 63 309 196617 this pure list solution has the > advantage of working with any data; > #P comment 197 108 145 196617 > #P fasten 5 0 3 0 102 193 45 193 45 126 57 126; > #P fasten 5 0 7 0 102 196 41 196 41 122 115 122; > #P connect 2 0 7 0; > #P connect 3 1 5 0; > #P connect 2 0 3 0; > #P connect 1 0 3 0; > #P connect 1 0 7 0; > #P connect 6 0 7 1; > #P connect 7 0 4 0; > #P window clipboard copycount 8; > > > -- > Stefan Tiedje------------x------- > --_____-----------|-------------- > --(_|_ ----|-----|-----()------- > -- _|_)----|-----()-------------- > ----------()--------www.ccmix.com >
    • Feb 17 2007 | 2:18 am
      Stefan Tiedje wrote: > my attempts including one with 3 standard objects...
      Ah, but the same bug persists in your version...
      It is subtle but obvious upon close examination of the output.
      Jonathan - I tried for a while before failing to come up with your solution. It was the one that seemed 'right' to me, but I couldn't quite nail it down for some reason. After yours arrived, I needed to do something different. :)
      Jon
    • Feb 17 2007 | 2:22 am
      That one fixes the bug!
      Stefan Tiedje wrote: > or another 3 object version, this time recursive with changable number > of elements....
    • Feb 17 2007 | 3:10 am
      Chris Muir wrote: > Elegant, but seems to have problems with the text list input, although > the numbers work fine:
      Eating my words... The same patch bug is still there, though in a different way. I would love to see a general standard-object solution that doesn't have problems with the word "list".
      > print: this pure > print: pure list > print: solution has > print: has the > print: the advantage > print: advantage of > print: of working > print: working with > print: with any > print: any data > print: data
    • Feb 17 2007 | 3:13 pm
      Hello all.
      Well here's another 3-object solution. Very similar to Stefan's but uses a [trigger] instead of [defer]. Can control how many values to group and the 'slide' amount. Seems to work with all kinds of lists.
      Well then, after many attempts, I think we have finally reduced this puzzler down to the ideal solution?
      Jonathan
      On 17/02/07, dlurk wrote: > > Chris Muir wrote: > > Elegant, but seems to have problems with the text list input, > although > the numbers work fine: > > Eating my words... The same patch bug is still there, though in a > different way. I would love to see a general standard-object solution > that doesn't have problems with the word "list". > > > print: this pure > > print: pure list > > print: solution has > > print: has the > > print: the advantage > > print: advantage of > > print: of working > > print: working with > > print: with any > > print: any data > > print: data > > > >
      -- Jonathan Green 0777 1680 497 jonathan@jg1983.co.uk
    • Feb 17 2007 | 9:44 pm
      This one still doesn't work with the word "list". The position of the word in your list makes it seems like it works..
      Try putting "list" in other places.
      However, this does nothing to kill my amazement that my behemoth solution was whittled down to something so simple.
      Thanks everybody.
      b
      Jonathan Green wrote: > Hello all. > > Well here's another 3-object solution. Very similar to Stefan's but uses > a [trigger] instead of [defer]. Can control how many values to group and > the 'slide' amount. Seems to work with all kinds of lists. > > Well then, after many attempts, I think we have finally reduced this > puzzler down to the ideal solution? > > Jonathan > > max v2; > #N vpatcher 100 100 460 374; > #P window setfont "Sans Serif" 9.; > #P window linecount 1; > #P message 72 71 182 196617 a few words to test this list operation; > #P newex 72 129 64 196617 t l l; > #P newex 126 175 32 196617 print; > #P message 85 93 142 196617 11 12 13 14 15 16 17 18 19; > #P newex 126 151 51 196617 zl slice 2; > #P newex 72 151 51 196617 zl slice 1; > #P fasten 0 1 4 0 118 176 64 176 64 123 77 123; > #P fasten 2 0 4 0 90 117 77 117; > #P connect 5 0 4 0; > #P connect 4 0 0 0; > #P connect 4 1 1 0; > #P connect 1 0 3 0; > #P pop; > > > > > > > On 17/02/07, *dlurk* > > wrote: > > Chris Muir wrote: > > Elegant, but seems to have problems with the text list input, > although > the numbers work fine: > > Eating my words... The same patch bug is still there, though in a > different way. I would love to see a general standard-object solution > that doesn't have problems with the word "list". > > > print: this pure > > print: pure list > > print: solution has > > print: has the > > print: the advantage > > print: advantage of > > print: of working > > print: working with > > print: with any > > print: any data > > print: data > > > > maxmsp@cycling74.com > > > > > -- > Jonathan Green > 0777 1680 497 > jonathan@jg1983.co.uk > > > ------------------------------------------------------------------------ >
      -- barry threw composition : sound : programming http://www.barrythrew.com bthrew(at)gmail(dot)com 857-544-3967
      Today, Noise is triumphant and reigns sovereign over the sensibility of men. - Luigi Russolo, The Art of Noises
    • Feb 17 2007 | 11:39 pm
      Other keywords can cause problems too - set, clear, dump.
      On 2/17/07 4:44 PM, "Barry Threw" wrote:
      > This one still doesn't work with the word "list". The position of the > word in your list makes it seems like it works.. > > Try putting "list" in other places. > > However, this does nothing to kill my amazement that my behemoth > solution was whittled down to something so simple. > > Thanks everybody. > > b > > Jonathan Green wrote: >> Hello all. >> >> Well here's another 3-object solution. Very similar to Stefan's but uses >> a [trigger] instead of [defer]. Can control how many values to group and >> the 'slide' amount. Seems to work with all kinds of lists. >> >> Well then, after many attempts, I think we have finally reduced this >> puzzler down to the ideal solution? >> >> Jonathan >> >> max v2; >> #N vpatcher 100 100 460 374; >> #P window setfont "Sans Serif" 9.; >> #P window linecount 1; >> #P message 72 71 182 196617 a few words to test this list operation; >> #P newex 72 129 64 196617 t l l; >> #P newex 126 175 32 196617 print; >> #P message 85 93 142 196617 11 12 13 14 15 16 17 18 19; >> #P newex 126 151 51 196617 zl slice 2; >> #P newex 72 151 51 196617 zl slice 1; >> #P fasten 0 1 4 0 118 176 64 176 64 123 77 123; >> #P fasten 2 0 4 0 90 117 77 117; >> #P connect 5 0 4 0; >> #P connect 4 0 0 0; >> #P connect 4 1 1 0; >> #P connect 1 0 3 0; >> #P pop; >> >> >> >> >> >> >> On 17/02/07, *dlurk* > >> wrote: >> >> Chris Muir wrote: >>> Elegant, but seems to have problems with the text list input, >> although > the numbers work fine: >> >> Eating my words... The same patch bug is still there, though in a >> different way. I would love to see a general standard-object solution >> that doesn't have problems with the word "list". >> >>> print: this pure >>> print: pure list >>> print: solution has >>> print: has the >>> print: the advantage >>> print: advantage of >>> print: of working >>> print: working with >>> print: with any >>> print: any data >>> print: data >> >> >> >> maxmsp@cycling74.com >> >> >> >> >> -- >> Jonathan Green >> 0777 1680 497 >> jonathan@jg1983.co.uk >> >> >> ------------------------------------------------------------------------ >>
      Cheers Gary Lee Nelson Oberlin College www.timara.oberlin.edu/GaryLeeNelson
    • Feb 19 2007 | 10:41 am
      Peter Castine wrote: > If you rule out 3rd party externals, you can't use abhaxions either.
      Yes I can, I just have to de-encapsulate, because I made them myself... ;-)
      > No Java, no Javascript. Only objects released with Max 2.2 in 1990, > and only Uzi's left outlet.
      Hey, would be fun as well, I was thinking about that already, though is difficult to keep track when what came up. In that regard an OS 9 (max 4.1 ?) restriction would make more sense...
      > Let's make this a game for real men (and women).
      Yeah, whats your solution? (my second one could run in 2.2 as I believe iter and bucket were available back then...)
      Barry Threw wrote: > I say we have to solve it using only &&, ||, and !
      but ! is jasch and certainly not... (but could be abhaXed with [== 0] ;-) Show your patch with those...
      Stefan
      -- Stefan Tiedje------------x------- --_____-----------|-------------- --(_|_ ----|-----|-----()------- -- _|_)----|-----()-------------- ----------()--------www.ccmix.com
    • Feb 19 2007 | 10:44 am
      dlurk wrote: > Eating my words... The same patch bug is still there, though in a > different way. I would love to see a general standard-object solution > that doesn't have problems with the word "list".
      Standard objects try to be smart, but if you hack list.slice.mxj to not listen to special reserved key words, you should be able to do it... (The other problem, but just in this case, the outputs of zl or mxj list. objects never precede the word list, never...)
      Stefan
      -- Stefan Tiedje------------x------- --_____-----------|-------------- --(_|_ ----|-----|-----()------- -- _|_)----|-----()-------------- ----------()--------www.ccmix.com
    • Mar 06 2007 | 12:37 pm
      "listfunnel" object
    • Mar 06 2007 | 5:13 pm
      sort of, but not quite. still, listfunnel should do what you need, quite simply.
    • Mar 09 2007 | 12:33 pm
      Seejay James schrieb: > sort of, but not quite. still, listfunnel should do what you need, > quite simply.
      Is this referring to the thread from February? (Hard to tell if there are no quotes...)
      But I doubt that its meant like that, this would only work exactly on a list which start with 1 and count on with 1. In this case you don't need a patch at all, you could directly type [1 2, 2 3, 3 4,...] into a message box and bang it, and you would also be able to fit the last element to be singular (as requested)...
      Stefan
      -- Stefan Tiedje------------x------- --_____-----------|-------------- --(_|_ ----|-----|-----()------- -- _|_)----|-----()-------------- ----------()--------www.ccmix.com