Group Abstract Group Abstract

Message Boards Message Boards

1
|
17.4K Views
|
4 Replies
|
7 Total Likes
View groups...
Share
Share this post:
GROUPS:

How to get rid of the outermost curly brackets of a Table?

Posted 11 years ago
POSTED BY: Gernot H
4 Replies
Posted 11 years ago

And more to the point:

In[11]:= ranges = {{x, 1, 7, 2}, {y, 2, 8, 2}};

In[13]:= Table[{x, y}, Sequence @@ ranges // Evaluate]

Out[13]= {{{1, 2}, {1, 4}, {1, 6}, {1, 8}}, {{3, 2}, {3, 4}, {3, 
   6}, {3, 8}}, {{5, 2}, {5, 4}, {5, 6}, {5, 8}}, {{7, 2}, {7, 4}, {7,
    6}, {7, 8}}}

;-)

POSTED BY: David Keith
Posted 11 years ago
POSTED BY: David Keith
Posted 11 years ago

But this only works if i want to Apply the whole list as argument, right?

What for example if I have something like

Table[ something , {i1,n1},{i2,n2},{i3,n3}]

I want to generate {i1,n1}},{i2,n2},{i3,n3} as a sequence, and use it as such.

POSTED BY: Gernot H
Posted 11 years ago

Apply ( @@ ) can be used to replace the head List with Sequence, which is the head for a sequence of items as used for arguments.

In[1]:= Range[1, 10, 1]

Out[1]= {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

In[2]:= Range[Sequence @@ {1, 10, 1}]

Out[2]= {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
POSTED BY: David Keith
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard