Linked Questions
22 questions linked to/from How to remove redundant {} from a nested list of lists?
4
votes
1
answer
697
views
Removing Outer Brackets [duplicate]
I am getting this: {{{{{{1, 1}}, {2, 4}}, {3, 9}}, {4, 16}}, {5, 25}}
I want it like this: {{1, 1}, {2, 4}, {3, 9}, {4, 16}, {5, 25}} so that I can use this as coordinate points in ListPlot to ...
23
votes
0
answers
1k
views
Strip waste braces in nested list [duplicate]
I have nested lists wherein there are a lot of waste levels which looks like
l = {{{{{{2, 2}}, 3}, 2, {{2, 33}}, 4, 5}}};
I would like to reduce it to somthing ...
0
votes
1
answer
131
views
How to take single item out of List? [duplicate]
I often get Lists that contain a single item, like {name} or {{2,3,4}}.
Is there a function ...
33
votes
5
answers
2k
views
How to perform a depth-first preorder traversal of an expression?
Mathematica provides functions that perform a depth-first postorder traversal, or which use such a traversal, including: Scan, ...
17
votes
7
answers
3k
views
How to Flatten {1, {2, {3, 4}, 5}, 6} into {1, {2, 3, 4, 5}, 6}?
I've tried 3 methods but all failed to do that.
1st Method
Apply[Flatten, {1, {2, {3, 4}, 5}, 6}, {2}]
2nd Method
...
13
votes
7
answers
3k
views
Brackets around each item in matrix
I have a matrix where every item in the matrix has its own brackets that I do not want. How can I remove the brackets around each item?
24
votes
2
answers
5k
views
Determine whether some expression contains a given symbol
Given a symbol t and an expression expr, how can I determine whether or not the symbol t ...
9
votes
4
answers
1k
views
Delete efficiently rows of empty list elements inside a list
What is the most efficient method for deleting a row of empty list elements? For example, here is a list with one row of empty list elements:
...
7
votes
2
answers
3k
views
Using ReplaceAll to replace a head
Why would this work to replace the head b with newHead:
...
7
votes
5
answers
934
views
How to Apply Functions to Lists with Many Curly Brackets?
For example, consider the list defined below.
samplelist = {{{1,2,3,4}}, {{5,6,7,8}}};
How would I apply the Times operator ...
3
votes
2
answers
20k
views
Is there a function in Mathematica which removes brackets wrapping an expression?
Is there a function in Mathematica which removes brackets from an expression?
RemoveBrackets[ {3} ]
3
Note: inspired by @garej's answer to this question :...
9
votes
5
answers
278
views
Prevent testing Head with ReplaceAll
I have a list of strings list. I am trying to get rid of some elements that match string pattern patt:
...
9
votes
4
answers
684
views
What is shorthand way of Reap list that may be empty because of zero Sow
Sometimes because of conditionals, you cannot guarantee that Sow will be called at least once.
Reap[Sow[1]][[2,1]] results in <...
7
votes
3
answers
572
views
Obtaining the number of iterations used in ReplaceRepeated
ReplaceRepeated has an option MaxIterations which indicates Mathematica is keeping track of the number of iterations. Is there ...
10
votes
2
answers
266
views
Unexpected behavior using `ReplaceAll[]` for nested lists [duplicate]
ReplaceAll[] might lead to unexpected behavior (at least it surprised me).
I use ReplaceAll[] to convert a list (basically data ...