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

learn more… | top users | synonyms (3)

-1
votes
2answers
24 views

Select sub-lists of common length from a list [on hold]

I have a list with nested lists with the following format: {{{},..10 elements...,{}},{{},...44 elements...,{} aso. I would like to cut all nested lists on the ...
0
votes
1answer
20 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 ...
12
votes
6answers
381 views

How to sort digits in a string while keeping other characters untouched?

Now there is a string with digits and letters, for instance, "95uge678r3gi89hgfe30kgh063d51". And the expected output is ...
4
votes
5answers
245 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 ...
8
votes
3answers
335 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, ...
0
votes
4answers
76 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
56 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
96 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 ...
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
3answers
57 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 ...
2
votes
1answer
47 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 ...
5
votes
2answers
124 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
1answer
34 views

operating lists [on hold]

I have 2 lists 25 items, as I do so that data entering this formula ...
8
votes
1answer
81 views

Unexpected slowness checking for empty list?

I thought I had a firm understanding of the differences between Equal and SameQ, but this has me puzzled: ...
3
votes
5answers
520 views

Can Mathematica delete some of the 0's from a list?

I have a list: {1,2,3,0,0,4,5,0,0,0}. I want to delete the 0's occurring after the last positive integer. In other words, I ...
1
vote
1answer
40 views

Change date format in nested lists

I have a list of index symbols and data as follows: ...
1
vote
3answers
125 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
34 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 ...
0
votes
4answers
57 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
0answers
34 views

Using lists for creating another list [closed]

I have list ("F") of numbers of length n. asthma = ((A - B)/A)/Sqrt[XXX], where "A" and "B" are also lists of numbers of length n. The thing I need is that "asthma" will also be a list of numbers ...
8
votes
6answers
509 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 ...
2
votes
3answers
88 views

Delete rows based on specific periods

I have data (.xlsx format): two columns - data in first column imported as DateObject (dates with specific time), data in second column are numbers (113388.28, 865165.98 etc.). I want to delete the ...
0
votes
1answer
30 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: ...
2
votes
2answers
79 views

Dynamic arrays and lists with compile (Append, Linked lists etc.)

I have a code that I need to compile. The code contains a loop in which I need to gather data into a list. The question is how to best gather data so that the code works inside Compile. The following ...
0
votes
2answers
70 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 ...
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 ...
6
votes
6answers
431 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 ...
6
votes
0answers
71 views

TimeConstrained[Delete[Range[1],1]] causes kernel crash

Run these two samples of code here (AFTER SAVING YOUR CURRENT WORK): Do[ TimeConstrained[ While[True, Delete[{1}, 1]; ];, 0.1];, {100}] ...
1
vote
2answers
135 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 ...
1
vote
2answers
90 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 ...
2
votes
2answers
75 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
0answers
14 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
50 views

Length of Union Incorrect?

I am having a problem with the Union of sets not giving me the correct Length. ...
1
vote
1answer
85 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 ...
0
votes
2answers
73 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
39 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} ...
2
votes
3answers
90 views

Creating sublists based on the first column

I have Excel file consisting of two columns such as: ...
1
vote
1answer
53 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 ...
4
votes
0answers
64 views

FindPeaks finds Minima, but not all of them

I have 10 sets of data, which are the result of measuring the way of a mass falling down over time, bringing a wheel into rotation when the mass hits the ground and then the wheel lifts the mass up ...
3
votes
3answers
87 views

Selecting sublists of different length if at least one element of the sublist fulfills a criterion

I have the following list, containing sublists with 1,2 or 3 elements. ...
5
votes
2answers
256 views

Is there an inequality operator (Less, Greater) for lists of elements (as opposed to elements)?

Like multi-column sorting. For example, {1,3,5} > {1,2,5} would return True, while ...
1
vote
0answers
37 views

Disease Network Model Using NDSolve

I have a basic disease model using NDSolve: ...
1
vote
2answers
92 views

Evaluate a list

I have a function $f(x_1,\cdots,x_n)$ that takes $n$ arguments, and I would like to evaluate it using a list of lists $\lbrace\lbrace x_1,\cdots,x_n \rbrace,\cdots,\lbrace x_1',\cdots,x_n' ...
-1
votes
1answer
40 views

Null before each element in a list [closed]

I have a list of colors that I am trying to use to color another list, I have a function that makes the list and I call that function and set it to a variable in another function. If I try to print ...
4
votes
1answer
109 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: ...
17
votes
7answers
474 views

Faster position list construction from a “take instructions” list

Take some list, e.g., {1,2,3,4,5}, and a "take instructions" list, say {1,1,2,1,1}. The latter is read as "take the first ...
4
votes
1answer
131 views

Slow exponential evaluation over lists

This question,which is still unanswered, might be relevant because it involves NIntegrate over lists and it also has Exp. In ...
0
votes
2answers
74 views

Convert Range to List of Strings

I need to generate the result given by ...
9
votes
2answers
339 views

What is the fastest way to get the nth distinct permutation of a list?

What is the fastest way to write a function nthPermutation[xs_List, n_Integer] which is equivalent to Permutations[xs][[n]] but ...
4
votes
1answer
91 views

Last Position function

The FirstPosition[] function can be use to locate the first position of an occurrence in a list. For example ...