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

learn more… | top users | synonyms (4)

1
vote
1answer
237 views

DeleteCases that match partially [duplicate]

Say I have a list of strings L , L2= "some_text-to-delete" and I want to delete all the Li that match with "text" or "delete" DeleteCase only gives the ones that match exactly...
0
votes
3answers
110 views

Positions of a string in a list [duplicate]

Sorry for the bad title..Didn't know how to describe this, feel free to change it to be more specific. I have a list in this form: ...
0
votes
1answer
48 views

Module using for creating a table [closed]

I want to have a 4 tables with using of module. Unfortunately I don't know why doesn't it work ...
-2
votes
3answers
82 views

Applying a function to a list with fixed intervals and fill the resulting list [closed]

I want to apply a function f to a list with fixed intervals, and then fill the gaps of the resulting list, as shown in the following picture. Since it will be run ...
2
votes
1answer
61 views

List of list to list of rules

I have a list of this type p = {{y, 1, 3}, {x, 2, 0}, {z, 3, 1/(k + 1)}} I can use a Do loop that is ...
6
votes
8answers
778 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 ...
7
votes
1answer
98 views

Converting a Table to a Dataset

I feel like this is a simple task, and there may be a built in method to doing this (but I can't find it if there is). I would like to be able to take a table and convert it into a structured Dataset. ...
1
vote
4answers
106 views

Difficulties with list manipulation

I have a list of five elements. For example, list1 = {a1, a2, a3, a4, a5}; I'm trying to get a list: ...
0
votes
0answers
20 views

Specifying plot markers (filled diamonds or squares) [duplicate]

I can plot my list data and I can use of specifying circle to show my plot-markers. I used of Mr.Wizard comments on that page. But I don't know how can I fill the circles of those plot-markers with ...
1
vote
1answer
73 views

Factor terms by kets

I have an expression that contains several kets with numerical factors. I would like to retrieve the individual kets and store each individually as a list element. The expression is as follows: ...
5
votes
3answers
208 views

how to concatenate a list of a list of strings

I have two lists of lists, La and Lb that I want to concatenate so that every element of a list n in La is concatenated with the corresponding element of list n in Lb. For example: La = {{P, O, O, ...
3
votes
6answers
550 views
1
vote
1answer
52 views

Adding another looping element with a list

I have code that is looping on to elements and is working shown below ...
3
votes
1answer
49 views

Use a part specification as the argument to a compiled function

I have some code that needs to generate a large matrix based on some complicated combinations of smaller matrix elements. I find that if I write a function for the element of the larger matrix, and ...
2
votes
3answers
111 views

Given a list of triangle vertices, how to find the neighbors for each vertex?

A triangle is represented by {a,b,c}, indicting that its vertex IDs are a, b, and ...
9
votes
5answers
227 views

Find all the possible ways of partitioning a list into a set of pairs of element

I have a list {x1,...,xN} where N is even, and I need to find all the possible ways to split it into pairs of elements, e.g. the ...
2
votes
1answer
104 views

Why is there a difference when formulating patterns for Select and FirstPosition?

Select[{1, 2, 4, 7, 6, 2}, # > 2 &] Gives {4, 7, 6}. OK! So one should think that the following would work: ...
2
votes
1answer
62 views

How to solve an equation given certain parameters?

I am new to Mathematica so please bear with me. I have an equation that has around 7 parameters and one unknown. I was able to use FindRoot to solve it; however, I ...
1
vote
5answers
124 views

Select using MemberQ

I want to make a selection on this list ...
2
votes
0answers
28 views

Basic Question: Split Nested list into respective elements [closed]

New to Mathematica, just have a very basic question to ask. I have a table of results like so: ...
6
votes
3answers
172 views

On a strange pattern of triangular numbers in Ulam's spiral

In this MSE post, user GeMir noticed that, where the green dots are the triangular numbers, $$T_n = \frac{n(n+1)}{2} = 1,3,6,10,15,21,28,36,45,55,66,78,91,105,120,136,\dots$$ in the Ulam spiral ...
2
votes
3answers
66 views

An extra { when importing a file [closed]

I am trying to import data from a file. {k0,{a0,b0,c0},{e0,f0,g0}} {k1,{a1,b1,c1},{e1,f1,g1}} MyList = Import[file, "Data"]; But I get a list with an extra "{" ...
0
votes
2answers
58 views

Company headquarters for each cell in a spreadsheet

I have an Excel spreadsheet column with hundreds of company names on it. I need to find the address (or just city if that's easier) The operation for this is simple in wolfram alpha. i.e. typing ...
0
votes
1answer
29 views

Creating a custom list [closed]

This is the first list lts1 = Table[i, {i, -1.8, 5.8, 0.1}] 1st question: In the interval between -1.8 and 5,8 how can I choose the step beforehand so as the ...
9
votes
3answers
1k views

Why don't * and ^ work as I expected on matrices?

For example, this input... {{1, 2}, {3, 4}}*{{1, 2}, {3, 4}} produces this output... {{1, 4}, {9, 16}} and this input... ...
7
votes
1answer
101 views

How to select a submatrix containing similar elements from a matrix? [closed]

( This question is related but does not ( fully ) answer my questions. - Finding the position of similar elements in a matrix ) I have not written code yet, I am in the design phase of code for the ...
0
votes
3answers
70 views

Confusing “Part::pspec” and “Part::partw” following call to ParametricPlot3D

The problem I'm having is that the function definition given below continually gives me baffling error messages. I'm trying to turn a list of 3D points into a function that approximates a curve by ...
3
votes
2answers
79 views

Output matrix with common elements

Given lists of lists like a and b, I want to obtain an output like c. a = {{2, 1, 0}, {1, 2, 1}}; b = {{2, 2, 0}, { 2, 2, 1}}; c = {{2, 0, 0}, {0, 2, 1}} If ...
0
votes
1answer
54 views

Applying corresponding elements of a list to a list of functions

I found this post which applying a function to a list of functions and arguments. I thought I could change my code with a table to something more elegant. I am not wedded to the ...
2
votes
1answer
76 views

Using and replacing sequential elements of a list

Very simple question but I am an absolute beginner, so apologies if this has already been answered. I need to pick sequential elements of a list, excluding t=1 and t=T, and use them in a function. ...
15
votes
4answers
2k views

Semi prime numbers

The high school textbook I am using has the example of semi-prime numbers. They wanted students to find (by "perspiration") all the semi-prime numbers less than $50$ (for a question on set theory). ...
4
votes
3answers
263 views

Efficiently test membership for a list of values

I have two lists: excluded and values. I would like to efficiently determine whether ...
15
votes
2answers
1k views

How do I split up a curve into chords of equal length?

I have a curve that is defined as f[x] and what I'm attempting to do is to divide the curve into equal straight lengths for a number of segments of my choosing that I've defined as nSeg. I've created ...
1
vote
4answers
92 views

GatherBy output with given Shape

I would like to group items in a binary list according to some property like in the following simple example. ...
3
votes
1answer
59 views

Count two or more equal consecutive elements in a list and create histogram

I have a list generated by: list = RandomInteger[{1}, 100] it contains only 0's and 1's ...
3
votes
1answer
49 views

Remove cases where region specified incorrrectly

I am using MeshPrimitives to get a list of 3D components of a Mesh Region. Within that list, I normally get some incorrectly specified regions, such as ...
1
vote
0answers
48 views

Apply ListPlot to various data sets [duplicate]

Assume that I have data in the form: list = {{{1, 2, 3}, {10, 10, 10}}, {{4, 5, 6}, {20, 20, 20}}} I want to plot ...
1
vote
2answers
58 views

Combining data sets by adding y values [duplicate]

Suppose I have the following list of data {{1,2},{1,5},{6,1},{1,3},{2,1},{2,2},{2,3},{5,4},{5,2}} This is similar to my actual data in that each x value has ...
2
votes
3answers
112 views

Positions of elements in a list [duplicate]

I have two lists: list = {1, 2, 3, 4, 5} slist = {3, 5} I want to find the positions of the elements in slist in list. I tried it like this and I dont understand ...
-1
votes
0answers
46 views

Mixing tensorial calculation

I would like to know if there is solution of this problem: Let \begin{align*} a & := \left(1,x(t),\int_0^t\int_0^{s_1}dx(s_2)\cdot dx(s_1)\right)\\ b &:= ...
5
votes
2answers
209 views

What is the idiomatic way to shift and extend a list by a number of elements?

I have a lists, list, and want shift it right by a given number of elements, m, extending the list by repeating the last ...
4
votes
2answers
66 views

How to delete blank valued keys from nested association?

Considering we have: acs = <|"A" -> <|"a" -> " ", "aa" -> "asd"|>, "B" -> <|"bb" -> " "|>|> How can we come to have a result ...
3
votes
2answers
69 views

Retaining relative sizes of local maxima using MaxDetect[List]

I would like to be able to find the position of the two greatest local maxima in a list. For the example: list={1,2,3,4,2,1,2,6,5,4,3,2,} I would like to return ...
4
votes
3answers
70 views

Replace values in a list based on conditions

I have a list with negative and positive numbers list = {-1, -2, 1, 2} and I want to replace all negative values with 0 and all positive values with 1 ...
3
votes
1answer
129 views

Programming for matrix manipulation

I want to write a programme which operates on nd x nd matrices. The programme looks the matrix as a n x n block matrix where ...
19
votes
3answers
3k views

Data interpolation and ListContourPlot

I am fairly new to Mathematica and I have two quick questions on using it for a Hydrology and Hydrogeology class. One is about data interpolation and interpolating without any data defined in an area. ...