716 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 ...
• 226
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 ...
• 3,491
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 ...
• 1,732
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, ...
• 272k
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 ...
• 1,671
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?
• 131
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 ...
• 1,859
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: ...
• 534
3k views

### Using ReplaceAll to replace a head

Why would this work to replace the head b with newHead: ...
• 5,101
944 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 ...
• 505
21k 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 :...
• 7,449
285 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: ...
• 637
685 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 <...
• 1,057
575 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 ...
• 804
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 ...
• 287

15 30 50 per page