what's the best way to 'interlace' two lists, i.e. turn: 1 2 3 4 and 5 6 7 8 into 1 5 2 6 3 7 4 8 ? thanks, Tim
[sfruit/list-zip]. or you do some fancy list-drip+mix abstraction.
what's the best way to 'interlace' two lists, i.e. turn: 1 2 3 4 and 5 6 7 8 into 1 5 2 6 3 7 4 8 ? thanks, Tim
if you're only using floats, and not symbols, what about just creating two tables, and then just alternating [tabread] between each table, sending the outputs into an accumulating list
[list]x[t a]
?
On Fri, Sep 9, 2011 at 1:13 AM, João Pais jmmmpais@googlemail.com wrote:
[sfruit/list-zip]. or you do some fancy list-drip+mix abstraction.
what's the best way to 'interlace' two lists, i.e. turn:
1 2 3 4 and 5 6 7 8 into 1 5 2 6 3 7 4 8 ? thanks, Tim
-- Friedenstr. 58 10249 Berlin (Deutschland) Tel +49 30 42020091 | Mob +49 162 6843570 Studio +49 30 69509190 jmmmpais@googlemail.com | skype: jmmmpjmmmp
______________________________**_________________ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/** listinfo/pd-list http://lists.puredata.info/listinfo/pd-list
thanks guys, I went with the sfruit/list-zip solution...
2011/9/8 hardoff goes bananas hard.off@gmail.com
if you're only using floats, and not symbols, what about just creating two tables, and then just alternating [tabread] between each table, sending the outputs into an accumulating list
[list]x[t a]
?
On Fri, Sep 9, 2011 at 1:13 AM, João Pais jmmmpais@googlemail.com wrote:
[sfruit/list-zip]. or you do some fancy list-drip+mix abstraction.
what's the best way to 'interlace' two lists, i.e. turn:
1 2 3 4 and 5 6 7 8 into 1 5 2 6 3 7 4 8 ? thanks, Tim
-- Friedenstr. 58 10249 Berlin (Deutschland) Tel +49 30 42020091 | Mob +49 162 6843570 Studio +49 30 69509190 jmmmpais@googlemail.com | skype: jmmmpjmmmp
______________________________**_________________ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/** listinfo/pd-list http://lists.puredata.info/listinfo/pd-list
On Fri, 9 Sep 2011, hardoff goes bananas wrote:
if you're only using floats, and not symbols, what about just creating two tables, and then just alternating [tabread] between each table, sending the outputs into an accumulating list [list]x[t a]
[list]x[t a] is quite slow. But then, so is [sfruit/list-zip] and several others.
they tend to be N² algorithms... that is, for doing work on a list of size 10, they have to do something in 1+2+3+4+5+6+7+8+9+10=55 steps, or anything else in which the time taken increases in such a steep fashion.
It's not about the time it takes for a list of size 10, it's about how quickly it gets worse when you increase the size of the lists you feed them.
| Mathieu Bouchard ---- tél: +1.514.383.3801 ---- Villeray, Montréal, QC
On Thu, 8 Sep 2011, tim vets wrote:
what's the best way to 'interlace' two lists, i.e. turn: 1 2 3 4 and 5 6 7 8 into 1 5 2 6 3 7 4 8 ?
It's usually called interleaving.
If they are all floats, the fastest is something like this :
[list prepend 1 4 f #] | [#join 0]---------------[list prepend 1 4 f #] | [#transpose] | [#to_l]
where the 1 4 f # prefix means you want to make a grid of 1 row and 4 columns of floats. Then in contact with grid-inlets, those prefixed lists become grids of 1 by 4.
[#join] joins them by the dimension 0, which makes a single grid of (1+1=2) rows by 4 columns.
[transpose] swaps the first two dimensions, which makes a grid of 4 rows by 2 columns.
[#to_l] makes a list of 8 elements, row after row.
Of course you can instead use a [list append] and messagebox containing :
$1 $5 $2 $6 $3 $7 $4 $8
and in that particular case, it's more efficient, but the GridFlow solution works for any list length, and is probably more efficient for big lists...
| Mathieu Bouchard ---- tél: +1.514.383.3801 ---- Villeray, Montréal, QC
2011/9/8 Mathieu Bouchard matju@artengine.ca
On Thu, 8 Sep 2011, tim vets wrote:
what's the best way to 'interlace' two lists, i.e. turn:
1 2 3 4 and 5 6 7 8 into 1 5 2 6 3 7 4 8 ?
It's usually called interleaving.
If they are all floats, the fastest is something like this :
[list prepend 1 4 f #] | [#join 0]---------------[list prepend 1 4 f #] | [#transpose] | [#to_l]
where the 1 4 f # prefix means you want to make a grid of 1 row and 4 columns of floats. Then in contact with grid-inlets, those prefixed lists become grids of 1 by 4.
[#join] joins them by the dimension 0, which makes a single grid of (1+1=2) rows by 4 columns.
[transpose] swaps the first two dimensions, which makes a grid of 4 rows by 2 columns.
[#to_l] makes a list of 8 elements, row after row.
Of course you can instead use a [list append] and messagebox containing :
$1 $5 $2 $6 $3 $7 $4 $8
ha good one, I didn't think of that.
In my case the lists are not big but there are many. I may try that solution too, see if it improves speed... thanks, Tim
and in that particular case, it's more efficient, but the GridFlow solution works for any list length, and is probably more efficient for big lists...
______________________________**______________________________** ___________ | Mathieu Bouchard ---- tél: +1.514.383.3801 ---- Villeray, Montréal, QC