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

learn more… | top users | synonyms (3)

9
votes
2answers
462 views

How do I prune a list of pairs of numbers so that each number occurs on only one pair?

How do I select only the first pair of numbers in which a number occurs from a list of pairs of numbers? For example, I have ...
1
vote
2answers
52 views

Filling a matrix with a list of lists

I have a list of lists with different lengthes: {{a1,a2},{b1,b2},{c1,c2,c3},...} Now I want to create a matrix the following way: ...
3
votes
2answers
257 views

Convert a list of hexadecimal numbers to decimal

I know that to change a single number from hexadecimal representation to decimal, you can use: base^^digits. However, if you have a list of numbers, Mathematica ...
0
votes
1answer
49 views

Elements inside arrays seem to be strings rather than signed numbers

When I have code like b = Array[Subscript[be, #] &, {3, 1}] b = b /. {Subscript[be, k_] :> Subscript[-be, k] /; k > 1} I am noticing that Mathematica ...
2
votes
2answers
60 views

How to apply list of values to a list of functions

I have the following: first= {1+a,2+a,3+a,4+a} and a list t={0,1,2,3} I want to evaluate the first element of "first" at ...
4
votes
2answers
91 views

Select sub-lists of common length from a list

Revised Question I have a list with nested lists with the following format: ...
1
vote
1answer
50 views

Delete duplicates from list of pairs

I'm fairly new to Mathematica, and I've finally stumbled upon something that's beyond my googling powers. I have a list of pairs, where each pair contains in its first entry a matrix and in its ...
3
votes
2answers
84 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
25 views

How to combine two or more groups while selecting form the unbalanced panel data if the number of obs is less than a scalar in certain groups

I have an unbalanced panel data. I want to calculate group statistics for each group. However, if ith group has less than K obs, then I want to combine ith and (i+1)th groups to calculate group ...
4
votes
5answers
258 views

How do I write a condition for Position that uses both the current and previous element?

For example, given {57, 3, 40, 94, 9, 84, 81, 93, 76, 5, 7, 76, 38, 9, 23, 95, 49, 0, 30, 3} I'd like to get all the indices at which the elements cross from ...
4
votes
1answer
77 views

Output function control and manipulation for efficient computation

I have taken note of a similar post related to modifying function parameters. I tried to adapt Kuba's solution to this post but I can't get it to work. I will illustrate my problem using a similar ...
1
vote
1answer
88 views

What are the terms of the sequence generated by Zeta(3s)/Zeta(s)?

The LiouvilleLambda function has Dirichlet generating function of Zeta[2s]/Zeta[s]. I am curious about an analogous function with Dirichlet generating function of Zeta[3s]/Zeta[s]. Can Mathematica ...
8
votes
3answers
369 views

Turning a set of random walk data 45 degrees

I have a set of data that is just a "random" (generated by me, not by computer) sequence of length 2000 of 1's and (-1)'s. I used it to plot a 1-D random walk where +1 is step up, (-1) is step down, ...
6
votes
2answers
129 views

How can I generate a $2n$-point moving maximum of a list as efficiently as MaxFilter?

This is based on the prior question, Moving maximum function?, where @rasher provided two winning solutions (i.e. clearly the most efficient): MaxFilter[list, 1] ...
0
votes
4answers
80 views

Find all disjoint subsets of equal length

Suppose that $A$ is a list with $n$ elements where $n$ is even. I want to write a function that returns all pairs $(A_1,A_2)$ where the sets $A_1$ and $A_2$ each have length $\frac{n}{2}$, $A_1 \cap ...
0
votes
3answers
69 views

How to iterate through a list of rules?

Let's consider I have a list of rules: {Aa -> 1/2, Av -> 2/5, Bx -> 3/7, Ce -> 4/9, ...} I want to find all keys that contain the letter "A" and ...
4
votes
2answers
107 views

How can I insert an element every $n$th position in a list?

How can I insert an element every $n$ positions in a list? For example, inserting a zero as every 4th element to turn {1, 2, 3, 4, 5, 6, 7} into ...
5
votes
2answers
287 views

Can someone explain this code for joining two lists by the first element of each sublist?

Background (which may be skipped, unless context is needed) I've recently begun learning Mathematica (and only up to chapter 3 of Wellin), but wanted to write some code to get a better feel for ...
1
vote
3answers
61 views

Selective data append to nested list

I have a list of database id and stock indicies which I use to withdraw the related price data. lis = {{4470, "^AEX"}, {4471, "^AFLI"}, {4472, "^AORD"}} I use ...
0
votes
0answers
23 views

Returning multiple results from compiled functions in M10 [duplicate]

I have found a similar question from 2012 here. It has been 3 years now and we have version 10. Have there been any attempt to solve this problem either by Wolfram or by the community - how to return ...
1
vote
1answer
40 views

Change date format in nested lists

I have a list of index symbols and data as follows: ...
2
votes
1answer
50 views

Evaluate recursive funtion as a whole before computing a recursive step

I'll try to make a basic example of my problem with $n$ being an array of elements, ex. $\{1,2,2,3,3,3\}$: If i have a sum which needs a computed value i would like to compute it beforehand and store ...
0
votes
2answers
71 views

Sorting non-numerical lists [duplicate]

The Sort function will by default sort from lowest to highest. In[1]:= Sort[{3, 1, 4}] Out[1]= {1, 3, 4} However, if the list ...
11
votes
5answers
313 views

Make a ragged list rectangular by trimming instead of padding

I have a ragged list ragged = {{a,b,c,d,e},{x,y,z}} that I would like to trim (on the right) to be rectangular. The desired result is ...
0
votes
4answers
65 views

Delete data were y = “NS” in a list with elements {x, y} [duplicate]

I have a list of data {x, y}and not all of them have actual values. They show as {x, "NS"} or ...
0
votes
1answer
36 views

operating lists [closed]

I have 2 lists 25 items, as I do so that data entering this formula ...
9
votes
6answers
539 views

Flatten nested lists

I have a list as follows lis= {a, {{{b}, {c,d,e}}, {{f}, {g,h,i}}}} which I would like to flatten to ...
14
votes
12answers
614 views

Join lists with nested list

Is there a way of smarter way of joining list of the form l1 = {a,{b,c}}; l2 = {d,{e,f}}; l3 = {g,{h,i}}; To obtain ...
1
vote
3answers
134 views

Deleting one of each chosen elements in a list containing duplicates [duplicate]

I want to delete one of each (and not all) selected element in a list containing duplicates. For example i have the list: $\{1,1,1,2,2,3\}$ and i want to delete $\{1,3\}$ so the leftover should be ...
2
votes
2answers
35 views

Count elements between matching opening and closing parentheses?

Suppose I have a List of the form: lst={"(", "x1", "x2", "(", "(", "x3", ")", "x5", "(", "x6", ")", ")", ")"} For each pair ...
7
votes
4answers
463 views

Filter list based on date

What I would like to do is remove entries from a list of instrument data when it is in maintenance. The maintenance data I have is a series of dates which look like this; ...
14
votes
8answers
877 views

DeleteCases on list of Strings

Consider the following: data={"AB","CD","AF"}; Now I would like to delete all String from data which starts with "A". ...
11
votes
3answers
680 views

Specifying string patterns in DeleteCases

It seems that DeleteCases is not compatible with string patterns, at least directly (see, for example, this question). Is this true? If so, why is this the case? ...
0
votes
1answer
31 views

Selecting from a list [duplicate]

OK, I know this must be a simple problem, but right now I'm just stuck and need some advice with this :). I have the following list: ...
6
votes
6answers
443 views

Find (longest) overlapping elements between two lists

I am trying to write a function f that returns the overlapped sublist where A ends with this sublist while ...
2
votes
3answers
97 views

Creating sublists based on the first column

I have Excel file consisting of two columns such as: ...
0
votes
2answers
71 views

Block anti-diagonalize a square matrix?

In Mathematica there is a very convenient function called JordanDecomposition[]. It takes a square matrix A as an argument and ...
4
votes
1answer
113 views

Map at a subsequence of a list

I'm trying to construct a function somewhat similar to MapAt. A basic usage example should look like this: ...
1
vote
1answer
55 views

How to extract a contiguous s_1 x s_2 x … x s_d subarray from an n_1 x n_2 x … x n_d array, where the dimension d is a variable

Given a multidimensional array, such as the 3-dimensional 2 x 2 x 3 array { {{a,b,c},{d,e,f}}, {{g,h,i},{j,k,l}} } How can I extract an arbitrary 3-dimensional ...
2
votes
2answers
82 views

Replace missing data

I have vectors of equal lengths where I want to replace the zeroes (missing data) with their preceding values. So far I have written: ...
0
votes
1answer
38 views

Writing a math formula to order results in a certain way [closed]

I am not very well educated in math and I have a math puzzle that I'm trying to solve. I have the following list and each object has 3 numbers. The first 2 numbers are better when they are as high as ...
1
vote
2answers
99 views

Checker rut for over 7 digit numbers

In Chile the RUT identifier identity, every rut has a check digit module 11 is used, I made this code to 7 digits, but not me 8 digits, a number of 7 digits is the abcdef- form (check digit ) and ...
0
votes
1answer
229 views

How do I plot results of complicated calculations in Mathematica?

I am new to Mathematica and am struggling with making plots of how features of solutions vary with parameters. For example, I can find the eigenvalues and zeroes of a Sturm Liouville problem (showing ...
1
vote
2answers
141 views

How to generate a range of numbers

Is there a quick and dirty way to generate a list of numbers from 1 to some arbitrary large number in order such that the digits of each number are only 0's, 1's, and 2's? I tried doing ...
0
votes
0answers
16 views

Sublist position? [duplicate]

Suppose I have a list of the form: lst = {a,b,c,d,e,f,a,1,5} If I want to find the position of d in ...
0
votes
1answer
51 views

Length of Union Incorrect?

I am having a problem with the Union of sets not giving me the correct Length. ...
4
votes
1answer
144 views

MovingMap maps to second level unexpectedly

I'm trying to build a financial indicator in mathematica. I import some historical data ...
0
votes
2answers
96 views

Exporting a table to Excel in CSV format

I am trying to create a table which when exported in a .csv format and opened in MS.Excel has the following form; ...
1
vote
1answer
41 views

How do you hide/show a dynamic element in a list?

Here is the simplified version of the problem: THIS: {1,2,##&[],4,5} RETURNS: {1,2,4,5} ...