Best way to do this?

Best way to do this?

Post by pineappl » Fri, 19 Dec 2008 13:48:09


I have an array of arrays. Example (representation 1):

1 1 2 1 2 3 1 2 3 4

or (representation2):

1
1 2
1 2 3
1 2 3 4

I would like to append a number to each of the enclosed arrays - say a
5. In other words, I'd like to end up with this:

1 5 1 2 5 1 2 3 5 1 2 3 4 5

But it isn't as easy as simply saying "array is array,5". It seems
that the difficulty is the fact that each of the enclosed arrays is of
a different length, but this is a necessity of my application.

Now, of course I could brute force it and do a typical loop, but I
don't want to do that. I did find that something like this works
quite well (recalling from memory - hope it is correct):

array is {omega,5} each array

And I don't mind this particular solution at all, and am happy to use
it. My question is whether there is anything better?
 
 
 

Best way to do this?

Post by Paul Houl » Fri, 19 Dec 2008 13:56:05


array,{each}5