New answers tagged list-manipulation
1
vote
Determining size of the list top level
You can use attribute HoldFirst and functions Level and Hold.
...
- 40.5k
5
votes
Finding positions of sublists matching a criterion
The following will solve your problem:
Flatten@Position[z, _?(#[[2]] == #[[1]] + 1 &), {1}, Heads -> False]
The more idiomatic solution has been written by ...
- 28.6k
6
votes
HoldForm not working with Map
You have a problem with the pre-existing definitions for f and g. You can temporarily over-ride these, using ...
- 15.8k
4
votes
HoldForm not working with Map
You can make an auxiliary function which maps HoldForm over all elements of the list.
...
- 11.8k
7
votes
HoldForm not working with Map
Another question about evaluation control. The keypoint is, if a function doesn't have a Hold* attribute, its argument(s) will always be evaluated before going into ...
- 59.5k
6
votes
Accepted
Finding position of a list in a nested list for which elements are equal
Using Round with the second argument:
...
- 28.6k
1
vote
Listsorting and ContourPlot from list of number:
The documentation center in mathematica is your friend. If you check the documentation of either ContourPlot and ListContourPlot you will see that there are two basic differences:
...
- 852
1
vote
Accepted
1
vote
Splitting list into sublists based off string value
Using Reap/Sow:
Last@Reap@Scan[Sow[First@#, Last@#] &, MyDataList, {2}] // Map[Total]
...
- 28.6k
0
votes
One-way "cross" of function between two matrices
You get almost the right thing using Map and Outer, but it has an extra { } around it.
...
- 67k
0
votes
One-way "cross" of function between two matrices
You can use Intersection and Tuples.
With
...
- 40.5k
6
votes
Splitting list into sublists based off string value
You can use GroupBy. Note GroupBy returns an Association.
With
...
- 40.5k
2
votes
5
votes
Splitting list into sublists based off string value
Your list is wrapped in another list, so you can use First to remove the outer list.
...
- 11.8k
0
votes
Values of counting functions
You can use Sort with Split. This method works for both positive and negative integers.
With
...
- 40.5k
3
votes
Values of counting functions
accumulatedBinCounts = Rest @ Accumulate @ BinCounts[#, 1] &;
Using Daniel's input examples:
...
- 356k
0
votes
Extract complex lists
Is there a reason for using indexed variables? There are several syntax errors in the code.
...
- 9,873
2
votes
3
votes
3
votes
Values of counting functions
Here is an alternative method which should work well even if negative numbers are present.
Let's generate some input data. Note this is about 8GB of data just for the starting list, so if you have ...
- 9,203
4
votes
Accepted
Replacing elements of one table with the elements of another table for common grid
Something along these lines might work:
tab2Rules = Thread[ReplacePart[3 -> _] /@ tab2 -> tab2];
tab1 /. tab2Rules
...
- 15.5k
5
votes
Values of counting functions
Here is another way to go if the list is only nonnegative integers.
...
- 57.3k
7
votes
Values of counting functions
You can use SparseArray and Accumulate to assemble a vector cvec so that ...
- 101k
2
votes
Accepted
How to make the plots update when I adjust parameter in Manipulate?
The form of Manipulate is
...
- 127k
5
votes
4
votes
Accepted
Apply pattern using a Slot (#) to each list element using a second slot
An alternative to the function that @Bill created for applying to more complex arrays is as follows:
...
- 7,989
6
votes
Apply pattern using a Slot (#) to each list element using a second slot
As requested, Use function definition to separate the two applications of #
...
- 11.1k
1
vote
How to replace Indeterminate with NaN in a list and ignore it?
How you want to do this probably depends on what you want to do with the list later. In Mathematica, Indeterminate is a kind of NaN. But if the intent is to remove the offending value, you can do ...
- 67k
3
votes
Extracting list elements following a specific marker
Cases[Partition[MyList, 2, 1], {100000000, _}][[All, 2]]
(*{241, 234, 202, 247, 245, 215, 243, 246, 249, 259}*)
- 1,643
3
votes
Extracting list elements following a specific marker
Another way using SequencePosition and Take:
...
- 7,989
10
votes
Extracting list elements following a specific marker
Pick[Rest@MyList, Most@MyList, 100000000]
(* {241, 234, 202, 247, 245, 215, 243, 246, 249, 259} *)
- 11.8k
6
votes
Extracting list elements following a specific marker
Using SequenceSplit:
SequenceSplit[MyList, {100000000}] // Map[First]
Using Split:
...
- 28.6k
7
votes
Extracting list elements following a specific marker
Extract[MyList, Position[MyList, 100000000] + 1]
- 101k
1
vote
Extracting nth value from an imported text file
Assuming that data consists of a list of lists of strings Like e.g.:
...
- 37.5k
2
votes
Accepted
When running code to compute a sequence, loop variable gets set to a constant
To understand what's going on, consider what happens every time sequence is called. It runs a for loop, and that for loop sets the value of ...
- 15.5k
1
vote
Fastest way to check if array is zero
You can try the following
AA = {{0, 0}, {0, 0}};
AllTrue[Flatten[AA], PossibleZeroQ]
- 11
3
votes
How can we get/calculate all the available FinancialIndicators outside TradingChart and InteractiveTradingChart?
It seems there's a way to do it, luckily :)
...
- 1,516
2
votes
Accepted
Interpolation with replacing start and end values;
I hope I understand your question correctly. You want to rescale the y data. This can be done with the function "Rescale". We first need to determine the max and min of the original data:
<...
- 37.5k
2
votes
Interpolation with replacing start and end values;
You can choose the domain on the second argument of ListInterpolation:
...
- 19.5k
1
vote
Accepted
How to perturb data along a midline?
For an example, I will take the following positions of inflexion points:
inf={161, 505, 952, 1107, 1216, 1358, 1529, 1723, 1867, 1898};
Then we define a linear ...
- 37.5k
2
votes
Accepted
3
votes
How to correctly identify a series of adjacency matrices in a text?
The zeros are not lost, the reason they disappear is, that you read the input as numbers and 00110 is simplified to 110.
To prevent this, read the input as a string:
...
- 37.5k
1
vote
Best way to make a list of a specified length of binaries with a specified number of True members
Here is a (comparison of two) solutions for relatively small x+y, that I can think of.
...
- 28.6k
3
votes
Accepted
Extracting N elements of the table satisfying the given condition
Using Position, Extract and PadRight:
...
- 28.6k
3
votes
Extracting N elements of the table satisfying the given condition
Clear["Global`*"]
A more direct and more efficient approach for generating tab is
...
- 139k
1
vote
Accepted
Can I use Table or something else instead of While in this case?
Here's something resembling your problem in a functional programming form: a complicated function f which takes a vector as input, ...
- 18.3k
4
votes
Accepted
Nested sequence evaluation seems to fail
Explanation
It's not about nesting, it's about the argument. You are doing {a,b,c}[[0]].
...
- 35.2k
1
vote
1
vote
1
vote
Plot discrete points as curves with crossing
Your data has a simple structure with some flaws. The main feature is that there is always one point of one curve and then a point of the other curve. Therefore, I think one should exploit this ...
- 37.5k
Top 50 recent answers are included
Related Tags
list-manipulation × 9032plotting × 788
matrix × 743
performance-tuning × 511
functions × 424
filtering × 398
replacement × 277
pattern-matching × 258
function-construction × 249
string-manipulation × 209
programming × 205
data × 192
equation-solving × 186
map × 176
sorting × 161
graphics × 150
import × 140
combinatorics × 131
export × 118
functional-style × 113
conditional × 106
associations × 105
manipulate × 103
output-formatting × 103
differential-equations × 102