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

learn more… | top users | synonyms (3)

6
votes
3answers
278 views

Finding all sublists or substrings of a given list/string

Given a list or string, how do I get a list of all (contiguous) sublists/substrings? The order is not important. Example for lists: ...
2
votes
4answers
136 views

accessing elements of nested list

I have a list of the form: toy = {{a, {b, c}}, {d, {e, f}}, {g, {h, j}}, {k, {m, n}}}; and would like to create the list ...
1
vote
1answer
69 views

How to use a list of rules as a data set

I have a file of models that I have saved that I want to be able to call in another program to be solved with NDSolve. Can I use ...
0
votes
1answer
52 views

How to use MemberQ for such Variables?

This is NOT the desired out come. I want this test to fail: ...
1
vote
2answers
67 views

Insert an element to AdjacencyGraph

I'm not able to insert an element to mine AdjacencyGraph. I suppose that i should modify my AdjcencyMatrix: ...
2
votes
2answers
92 views

How to rearrange structure and type of an imported dataset?

I have a bigger dataset imported from Excel. Its elements have a form of {time, data}. Day is irrelevant and I would like to have the time in decimal form e.g. 10:30 is 10.5 ...
2
votes
2answers
107 views

How to efficiently get a list like this?

I want a function myfun that generates list like this ...
10
votes
5answers
344 views

For a given expression: if it appears, remove it, but if it is absent, add it

While reformatting Szabolcs's code from (42660) I noticed this interesting operation: ...
3
votes
1answer
130 views

linear combination of successive elements in a list

Say I have a list $E$ and want to build a list $F$ with the entries $F_j=E_j-2E_{j-1}+E_{j-2}$. I know that this happens to be achievable by iterating the function ...
0
votes
1answer
57 views

Correcting a gap in ListPlot

This is a small sample of my data ...
0
votes
0answers
45 views

Generating a list of overlapping end coordinates [duplicate]

I'm a very new user to mathematica so this may be a silly question. i'm trying to evaluate some integral between end coordinates of some evenly spaced range. my range is defined by the number of ...
1
vote
1answer
59 views

How to delete more than one (specific) elements in a list

lst = {a, b, c} DeleteCases[lst, a] Delete one specific element a. How do I delete elements ...
3
votes
1answer
64 views

Converting path list to the nested list

I'm trying to convert the plain path list to the nested tree list like the following codes. ...
3
votes
3answers
228 views

Use map on a different level

I have just started to get used to Mathematica's Map, Apply, and related functions, and I can't figure out how to do maps that require working "one level down". For example, I am currently trying to ...
2
votes
2answers
140 views

How to apply # on different lists? [duplicate]

If I have list1 = {1, 2, 3, 4} list2 = {5, 6, 7, 8} How can I do so, that function[#1, #2] takes ...
4
votes
1answer
91 views

Parsing string with nested information

I am trying to parse a string, but I have no idea how to solve the following problem ...
2
votes
1answer
88 views

Filtering outliers [duplicate]

I have a question. My data is: ...
1
vote
1answer
90 views
4
votes
3answers
157 views

Selective threading of the Rule

How can I change form1 to form2 form1 {10000, 10004} -> {2, 2, 637} form2 ...
0
votes
0answers
73 views

How to accumulate elements in a list using Reap and Sow [duplicate]

Does anybody know how to rewrite this fragment using Reap and Sow instead of AppendTo. I need to reduce the execution time. Thank you. ...
4
votes
4answers
487 views

All binary sequences with length n

I don't know if there is a built-in function for this, but I'm thinking about something like this Outer[List, Table[{0,1},{n}] ] But ...
8
votes
3answers
302 views

Generalization to AllTrue, AnyTrue and NoneTrue

I am wondering if there is a natural Mathematica way to generalize those functions. To be specific, All three functions AllTrue, ...
2
votes
3answers
144 views

Plot a bunch of lines in 3D from point data

I have a 12*25 array, wherein each entry is of the form $\{x,y,z\}$. So 12 different $x$ values, 25 different $y$ values and 12*15 $z$ values in all. I'd like to plot 12 curves of various $x$ values ...
1
vote
2answers
62 views

Incomplete Parallel Mapping

I am still struggling on how to nicely handle list operations in Mathematica, and perform simultaneously parallel computation. We consider a tab of the form ...
9
votes
6answers
525 views

The longest run of at most k different elements in a list

I have a long list with ca. 500K elements. The list contains about 10K different elements. For simplicity let’s assume the list is of the following form: ...
3
votes
1answer
137 views

Calculate efficiently an expensive hermitian matrix

I want to compute a matrix $M_{pq}$, for which the calculation of each coefficients $M_{pq} = f(p,q)$ is an expensive function. I know that my matrix is hermitian, so that $M_{qp} = M_{pq}^{*}$. As a ...
4
votes
2answers
162 views

Finding the Position of the Minimum Neighbor for Each Element in a Large Matrix

I have a large matrix ($6020\times 8452$), and I want to create a new matrix where the relative position of the minimum neighbor is each element in the matrix. For example, if I had the matrix ...
2
votes
1answer
101 views

How get repeated elements from two lists

How to write a code that takes an certain element related to a given subset in a LIST 2, that occurs also in a LIST 1? for example, there are two lists: ...
1
vote
1answer
54 views

Compute the evolution of percentages from a data file

My data is stored in external .out files which contain six columns and a large number of rows. I know that I have to provide a small sample but the structure of my data is so unique, so I provide the ...
4
votes
2answers
184 views

Generate lists that satisfy a condition in an efficient way

The following code produces lists of sublists with maximum length 5 that shuffle zeros around an ordered list (here {1,2}). It produces all permutations while ...
2
votes
2answers
141 views

How to produce a table with column and row headers included?

I have searched and have not found a solution. n = Table[i^2 + j*3, {i, 3}, {j, 7}] // TableForm Export["stuck.xls", n] ...
0
votes
1answer
53 views

How to split (large) arrays like this?

I want to split this table (list/array) ...
0
votes
1answer
85 views

Extracting parts of a list subject to a condition

I've got a list like following: ...
1
vote
1answer
33 views

Select equation in a list of conditions

I have an equation list {a'[t]==b[t],c'[t]==d[t],x'[t]==y[t]} and upon running FullSimplify[] it becomes ...
0
votes
1answer
47 views

convert list to equation form

Suppose I have a list condition={f'[t]-3,g'[t]-f[t]} and now I want to use DSolve on it so I need to convert the list to ...
5
votes
2answers
110 views

How to use Manipulate to cycle through a list of lists over a function

So I can do something like this which I like: Manipulate[i, {i, {1,2,3,4}}] It lets me pick which specific values I want to allow to be chosen for my function. ...
1
vote
1answer
228 views

Lookup construction using data matrix and Reap/Sow versus AppendTo`s

I am a user of MMA9 and made my own kind of Lookup, which is now a standard command in Version 10. In my program there is a section in which by means of a StringReplace[ ]-command containing a lot of ...
1
vote
2answers
130 views

How to join several list interleaving with some fixed list between?

How to join several list putting some fixed list between? Like this MyJoin[{{a,b},{c,d},{e,f}},{x}] giving ...
0
votes
1answer
49 views

Organizing and displaying list-like result

This is most likely a piece of cake for you guys, but it is difficult for me. Related to a math problem, I examine if ...
2
votes
2answers
73 views

Replacing members of a list with elements sampled without replacement from another list

I have a list of element pairs: pairList = {{1,2}, {2, 3}, {3, 4}, {4, 5}}; I'd list to pick a subset of the elements in this list: ...
0
votes
1answer
47 views

Help for properly writing simple derivative expression

I need help to write the following expression (only 1 iteration): f(x) = ...some basic function... f[X0,...,Xp] = f(p)(x0) / p! What I have so far: ...
10
votes
1answer
202 views

Max element of a list with a custom ordering function

I need a function to find max element of a list according to some custom ordering function, assuming that the function implements a total order (elements being compared might not even be numbers). ...
4
votes
4answers
181 views

Extract Specific Dates from DateList

Hopefully this is an easy question but I couldn't find an easy answer anyway. Surely there is some simple way to splice this... I want to take a large datelist in the format of {{2014,12,31}, value} ...
8
votes
6answers
289 views

Adding list of list to a list

Hello I need some help on how to add a list to a list of list. The program would have to do as below: {{0,0}, {0}, {0,0,0}}+{1,2,3,4,5,6} will give ...
3
votes
2answers
111 views

Counting the total number of instances of some collection of objects in a list

I have a list of some sort list = {"l1","l2","l3","l4"} and I'd like to count the sum total number of occurrences of n of the ...
1
vote
1answer
142 views

How to specify x axis values in the ListPlot[] [closed]

I am using ListPlot[] to plot a list of 1000 values. I need to specify the value shown in x-axis.It seems that is a classic question but I have looked for in this forum but I did not get any response ...
2
votes
2answers
179 views

Trying to Figure Out how to work with datasets & Classify[] and Predict[]

I'm new to Mathematica and I'm a bit overwhelmed. I have always used R for my statistics problems. Now that I'm trying to replicate what I do in R in Mathematica I'm making little progress. For ...
5
votes
3answers
263 views

Multiplying block matrices

I have a 2*8 matrix A, and a 2*8*2 matrix B. So B[[1]] and B[[2]] are both 8*2 matrices. I need a neat way to multiply A by B so that the first list in the result is A.B[[1]] and the second list ...
2
votes
2answers
100 views

Using `Fold` to show stages of Euler product formula

I would like to recursively replicate each stage of the Euler product proof. This does it: ...
2
votes
3answers
262 views

Picking items from a list

There's probably a Mathematica primitive to do this, but I don't know what it is...suppose I wanted to construct a list of all integers from $1$ to $n$ that were not divisible by $12$, and that were ...