Group Abstract Group Abstract

Message Boards Message Boards

1
|
17.1K 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

Hi,

say I have a table

{a,b,c,d}

How can I get rid of the outermost brackets here, so that I have and expression of the form

a,b,c,d

I would need this very often in order to construct a list of arguments, which a function should take.

StringReplace does not do the job in most cases, since the elements a,b,c,d might be lists their selves, i.e. they might contain curly brackets as well.

Thanks for help!

POSTED BY: Gernot H
4 Replies
Posted 11 years ago
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