Questions on the manipulation of List objects in Mathematica, and the functions used for these manipulations.

learn more… | top users | synonyms (3)

0
votes
3answers
107 views

How to get the indices of values in a list which are NOT an specific integer?

I got a real array A, where Dimensions[A] == {5000, 5000, 5}. Some of the values in A are ...
-5
votes
1answer
300 views

Split dataset based on the first column [duplicate]

I have a dataset which I want to split based on the first column. The data looks like this ...
12
votes
4answers
385 views

Equivalent Nested Loop Structure

Consider the following examples: ...
9
votes
3answers
232 views

Truncating a list once all members of a set have appeared?

Consider if you would the case where we have some list of elements: list0 = {54, 4, 7, 9, 3, 54, 4, 20, 2, 456, 2, 3}; And we have some target list: ...
9
votes
6answers
419 views

Performing Computations on Sets

I would like to find a permutation of $\quad S=\{\frac{1}{10}, \frac{1}{2}, \frac{4}{7}, \frac{3}{5}, \frac{2}{3} \}\quad$ that maximizes the sum of theses elements raised to unique powers: ...
9
votes
4answers
1k views

How to sum up subelements of a list of unknown length

I'm simply looking for the {}+{} function for sublist elements of a list: (Parallel sums of elements) ...
8
votes
10answers
354 views
8
votes
5answers
301 views

Wrapping a function in count

I am working through the Programming Paradigms via Mathematica (A First Course) and am attempting to answer the following: Use recursion to count how many times the argument can have its square ...
8
votes
3answers
848 views

How can I get a running sum for a list?

I've got following data I'm reading from a file: ...
7
votes
5answers
337 views

How to display operations on list elements

When applying some arithmetic operation on two lists, I'd like to display the actual operations between the elements of each list. For example, {1, 1} + {1, -1} ...
7
votes
5answers
195 views

Selecting terms from a matrix

There are similar questions to this on the forum but none fit the purpose here: I would like to extract certain elements of a matrix depending on whether a factor is present or not, and create ...
7
votes
5answers
239 views

Better way to make a certain list with palindromic sublists

Here is my code, which works, but seems a little too long, I think might be a more refined version. ...
6
votes
4answers
162 views

Duplicate mapped elements in Riffle

What is the best way to do this? in: {a, b, c} {d, {e, f}, g} out: {{a, d}, {b, e}, {b, f}, {c, g}} ...
6
votes
3answers
187 views

Mapping a function over the parts of a deeply nested Array

I have two tensors: tensorS = Array[Subscript[s, #1, #2, #3, #4] &, {2, 16, 16, 19}]; tensorR = Array[Subscript[r, #1, #2, #3] &, {2, 16, 19}]; ...
6
votes
6answers
497 views

Convert a list of rules into 2 lists of integers

If I have a list of n number of rules, what is a concise way of breaking the data into 2 lists of the first and second part of the rule? This works, but seems like an unnecessary amount of code to ...
6
votes
2answers
125 views

Get brief help for a set of functions

When we are in console mode or working with a notebook we can get brief help about a function just by shift-entering ?function I would like to have a list like ...
6
votes
5answers
259 views

Removing reverse versions of lists from a nested list [duplicate]

I need to remove the reverse versions of lists from list of lists. I.e.: {{1,2},{2,2},{2,1},{a,1,2},{2,1,a}} I need to reduce to ...
6
votes
7answers
352 views

Sum of two functions, list processing

I am creating some simple graphs of functions defined by ordered pairs. Students are learning about "operations on functions", in this case, adding functions. If I have two functions defined by ...
6
votes
1answer
496 views

ReplaceAll inside an Iterator

I'd like to apply a set of rules to an expression defining the iterators of the table, like this: ...
5
votes
4answers
221 views

How can I get a list of the positions of the running minima in a list?

I want the positions of the (sequential) running minima in a list, that is, the positions of entries that have the minimum value of all the elements in that list, up to and including that entry. For ...
5
votes
4answers
193 views

Signed power set of a list

Given {a, b, c, ...} with $n$ elements generate a list with $2^n$ elements. For example, if the list were {a, b, c}, then the ...
5
votes
3answers
274 views

Element-wise list operation on list of lists [closed]

Suppose a function F operates on list A: $$A=\{a_1, a_2,\cdots, a_n\}$$ I have a list of lists, B: $$B=\{A_1, A_2,\cdots,A_m\}$$ Is there a syntax to specify that F should operate on members of B, ...
5
votes
5answers
418 views

Counting 'False' values at the ends of a list

I have table like this: t = {False, False, False, 4.5, 6.789, 1.23, 0.98, False, False} and I want to know how many False values I have at the beginning and at ...
5
votes
6answers
304 views

Convert array from {{…}} to “[[…]]”

I have made this function: conv01 = Map["["<>StringJoin@@Riffle[#,","]<>"]"&,Map[ToString,#,{2}],{0,1}]& to convert: ...
5
votes
4answers
193 views

How to delete mirror symmetric point pair efficiently

Look at following pic There are five points, I can generate the following point pairs ...
5
votes
2answers
237 views

Ranking a vector containing ties

How can I rank a vector such that the ties are replaced by their middle ranks. For example, {1, 2, 2, 3}. I want to rank this vector but the ties must be replaced ...
5
votes
1answer
233 views

Selecting a list from a list of lists

In working through Programming Paradigms Via Mathematica (A First Course) I have come across this two part question: A permutation of length "n" is a list of the first n positive integers in ...
5
votes
1answer
177 views

What is the fastest way to maintain a large set of expressions?

In my algorithm I need to maintain a set (an unordered list of distinct elements) of expressions supporting two operations: Test an expression for membership in the set Adding a new expression to ...
5
votes
5answers
2k views

How to sum over a List

list = {11.5575, 11.397, 5.52734, 4.0878, 2.54815, 1.86652, 2.55028, 2.14952, 1.6242, 1.34117} I have a list of numbers. How do I make a function that creates a ...
5
votes
1answer
457 views

Numbering element in descending order

How can I numbering the elements in descending order of second elements of sublists? For example, if I have the list which is ...
5
votes
6answers
328 views

Creating sums of elements from a list

I have a list $(d_1, d_2, .. d_k)$ and I want to create all sums that I get for adding only two elements for my list $(d_1+d_2, d_1+d_3,...d_{k-1}+d_k)$. The ...
5
votes
2answers
2k views

Converting numbers to integers

I've read the available documentation but I still haven't found an NumberForm -> Integer function yet. No result in this site's search, either. Does it exist? ...
4
votes
1answer
93 views

Better method to swap the values of two 2-D arrays

I have two 2-D matrices $A$ and $B$(owns same dimentions) which have the style written as below: $ \begin{bmatrix} a_{11} & a_{12} & \cdots & a_{1k} &\cdots &\cdots & ...
4
votes
1answer
98 views

Parsing string with nested information

I am trying to parse a string, but I have no idea how to solve the following problem ...
4
votes
2answers
75 views

How to keep first observation and delete other observations of each group in unbalanced Panel data

I have a huge panel data. I want to create a new data keeping only first observation of each group. How can I achieve it? For illustrative purpose; ...
4
votes
3answers
141 views

Extracting columns from multidimensional list

Perhaps a very easy question but I posted this on the Wolfram Community and didn't get any answer.. Suppose I have data like: ...
4
votes
2answers
139 views

Sorting out atom types in an XYZ file

I am trying to rewrite the output of "VertexCoordinates" such that instead of a hybrid list of atoms and coordinates that result from using the following input program, I want all coordinates of the ...
4
votes
3answers
269 views

How can I change a list to a sequence without destroying nested list

I defined a function f like f[x___, y_] := something; and if xs and ...
4
votes
2answers
598 views

What is the Mathematica way of joining two tables?

Is there a special Mathematica way of joining tables of data together, so that I would get similar functionality as if I was running a database with sql? For example, I have one particular table ...
4
votes
1answer
175 views

How do I randomly select 'k' positions in a list and shuffle their respective elements without effecting the other elements?

Imagine I have some list: listA = {"a","b","c","d","e","f","g","h","i","j"}; I'd like to randomly select k positions in the ...
4
votes
3answers
539 views

Finding elements from a sparse matrix

I am dealing sparse matrices of very large dimensions. I need to locate the positive and negative elements of the matrices and make lists of their corresponding positions. Of course I can write a ...
4
votes
2answers
127 views

How to constrain the generation of all possible orderings?

Here is code from Simon Woods' answer for getting all possible weak (equal ranks allowed) orderings for $N=3$ objects: ...
4
votes
1answer
132 views

Timing Total crashes kernel

Here is a simple test function test[n_] := Module[{i = 0}, Total[Nest[{++i, #}&, {0}, n], -1]] On my system V9.0.1 running OS X 10.6.8 and with a clean ...
4
votes
1answer
175 views

List manipulation - various

Update OK, Please forgive the messiness of this, but I am working with something like: ...
4
votes
7answers
723 views

Finding the midpoints of an ordered list of numbers

Suppose that I have an ordered list of numbers. The numbers in the list may be evenly spaced, but they may not be. Here are two examples, list1 and ...
4
votes
2answers
557 views

Removing not-a-number entries from an array of numbers

I have a list of {x, y, z} coordinates from a wavefront sensor I'm working with. However, not all of the imported points have actual values, but they still get ...
4
votes
1answer
410 views

Create a table with inline conditions

I am trying to create a table with conditionals inline. For example, I'd like to create a 2 dimensional table like this: ...
4
votes
3answers
408 views

Preparing data for making an ErrorListPlot

I often have the following notebook in Mathematica, which I use to make a dataset and associated errors: ...
4
votes
2answers
273 views

Partition a set into $k$ non-empty subsets

The Stirling number of the second kind is the number of ways to partition a set of $n$ objects into $k$ non-empty subsets. In Mathematica, this is implemented as ...
4
votes
1answer
281 views

Use single ListPlot for multiple sets of data (on separate graphs)

This is the code I have working for a single set of data. Is there a way I can structure this to have multiple sets of data? ...