Storing numbers in multiple columns

Jul 30, 2008 at 12:50am

Storing numbers in multiple columns

Is there an object like [coll] that can store more than one element in a line? Actually I would need two numbers per line, apart from the index:
1, 56, 0;
2, 57, 0;
3, 58, 1;
4, 9, 0;
etc.

Currently I use [coll] and combine the output of every two lines to a pair. But it would be more “elegant” to store in pairs. [funbuff] does not have an index. I do not understand [pattr] yet – is it probably what I am looking for?

#39062
Jul 30, 2008 at 12:56am

On 30 juil. 08, at 02:50, Peter Ostry wrote:

> Is there an object like [coll] that can store more than one element
> in a line? Actually I would need two numbers per line, apart from
> the index:
> 1, 56, 0;
> 2, 57, 0;
> 3, 58, 1;
> 4, 9, 0;
> etc.

You can store a list with coll, if you need to access the items
individually, you can do that with the nth/sub/nsub messages.

HTH,
ej

#137014
Jul 30, 2008 at 12:57am

Quote: Peter Ostry wrote on Tue, 29 July 2008 17:50
—————————————————-
> Is there an object like [coll] that can store more than one element in a line? Actually I would need two numbers per line, apart from the index:
> 1, 56, 0;
> 2, 57, 0;
> 3, 58, 1;
> 4, 9, 0;
> etc.
>
> Currently I use [coll] and combine the output of every two lines to a pair. But it would be more “elegant” to store in pairs. [funbuff] does not have an index. I do not understand [pattr] yet – is it probably what I am looking for?
>
—————————————————-

You could store this in a coll:

1, 56 0;
2, 57 0;
3, 58 1;
4, 9 0;
etc.

and unpack it.

mz

#137015
Jul 30, 2008 at 1:23am

That easy and obvious!
Many thanks, I need the values as lists, the solution is perfect.

#137016
Jul 30, 2008 at 8:10pm

Quote: Peter Ostry wrote on Wed, 30 July 2008 03:23
—————————————————-
> That easy and obvious!
> Many thanks, I need the values as lists, the solution is perfect.
>
—————————————————-

Hello Peter,

if you deal with lists, I really encourage you to use the [zl] object.

It is no that easy to catch all the different modes at first, but it worth the effort, it is very powerfull.

with zl and coll you can do great things.

#137017

You must be logged in to reply to this topic.