1
vote
3answers
123 views

How to ReplaceAll independent of depth?

I have a big list which in principle can be described as this more compact list : ...
1
vote
1answer
73 views

How can I write a function which takes another function of a variable and the variable itself as arguments and gives a list of critical points?

This is an exercise from Power Programming with Mathematica by Wagner. I need a function which takes a function and a variable as arguments, like this: critpts[f_,x_]:= and then on the rhs I've got ...
3
votes
4answers
178 views

Replace all symbols in a matrix with their numbered forms

I have a matrix made mostly from "x" with a few 0's thrown in: ...
1
vote
4answers
110 views

Replacing more than one element from a Sublist

The following expression allows me to extract the value of x and y: ...
2
votes
3answers
155 views

What is the order of faces on a D20? How can I optimize the order of faces on a D-n?

I am creating a customizable D20 for 3D printing using OpenSCAD, with the following code: ...
1
vote
1answer
80 views

Nest Replace Function with different rules

I have a table of data that I want to filter. Any value of zero in the table means that value was not calculated, so it should get populated with the tag "NC". Next the table is filtered for all ...
4
votes
2answers
135 views

Replacing one element of list

I have a list of sequences of x's and y's. I want to switch the last position to the "opposite" symbol - if ...
1
vote
2answers
67 views

Replacing a specific pattern of values at level 2 in a list

I've a list of lists, tl = {{True, False, m12}, {False, m22, m33}, {m32, False, True}} and each nested list has the same length, What is the proper way to ...
2
votes
2answers
144 views

Create Table of replacement rules

I want to create a table of replacement rules. ...
5
votes
1answer
238 views

Apply color function to matrix plot

I want to apply the following color rules to a large table of numbers. I have extracted a part of the table to use as an example. I would like to assign 5 different colors to 5 different ranges of ...
0
votes
2answers
119 views

How to partition three years of data into daily samples

I'm trying to find mean of temperature data list. The temperature data list has 3 hours steps which means I have 365*8=2920 temperature measurements per year. My data are temperatures of 13 years. ...
2
votes
1answer
70 views

Using Total on a list supplied by a rule

I'm confused as to why Total complains about a nonatomic expression here: ...
4
votes
1answer
191 views

replace items in a list with items in a another list

Suppose I have a list A={x1,x2,x3}, a list B={3,4,5}, and a function f[x]=x1+x2+x3. Is there ...
2
votes
2answers
134 views

Generating an editable table that can be used as input

Say I have a number $n_{max}$. I want a command to generate a table like 1 1 2 2 3 3 4 4 ... nmax nmax where the second column is editable, and this table can be ...
0
votes
2answers
102 views

Handling output that was returned unevaluated from a function

When evaluating functions, including those described in this post, how do Mathematica users handle values returned from a function that are unevaluated? For example (based on 1): ...
0
votes
2answers
186 views

Replace all elements of a list

I have a set that looks like: s = {{1, 2, 3} -> 9, {4, 1, 9} -> 9, {3, 7, 3} -> 1}; Now, I want to replace each element of the set by the lhs of "...
2
votes
1answer
72 views

Convert Integer to Numeric with Replacement rules

I have a long list of triples, each looking something like {AGO, 1988, 2345.23}. Some of these, however, have an integer in the third spot, like this: ...
0
votes
1answer
104 views

replace is not happening for specific vector valued expression

Given x[t_] := {Subscript[x, 1][t], Subscript[x, 2][t]} following replace works fine x[t] /. x[t] -> 0 0 but following ...
0
votes
0answers
43 views

is there a way to speed up rule replace? [duplicate]

I am currently doing calculation with 7 parameters, each parameter set corresponding to a value. And I store the data in the format as a list of rule, like following ...
5
votes
4answers
226 views

How to split a list with respect to its nested sublists?

I have a problem with the following task: having some nested list list = {{k6},{k1,k3,k5},{k7}} I would like to replace all sublists by their permutations and ...
0
votes
1answer
96 views

Problem with List Dimension Outer Map [duplicate]

I am currently handling a big list which has the following dimension: {6, 3, 4, 2, 2, 1, 8} where the last number 8 represent a ...
4
votes
3answers
143 views

Appending to sublists using “anchor” values

Say I have a set of lists that look like this: ...
3
votes
1answer
212 views

Replace elements in a list

Suppose that I have a list: ...
0
votes
2answers
219 views

Converting a list of replacement rules into a list of real values [duplicate]

The following command outputs a list of replacement rules. ...
2
votes
2answers
377 views

Replacing values of a function

I have recently starting using Mathematica and have recently come to what seems as an impasse in my understanding of the language. If this is too "tell me how to do it" I would certainly understand. ...
2
votes
2answers
157 views

Modify a sub-part of a sub-list only

I have this list: a = {{{0, 0}, {1, 7}, {2, 0}, {3, 2}, {4, 7}}, {{0, 0}, {1, 0}, {2, 1}, {3, 2}, {4, 7}}} and I'd like to transform it to this: ...
7
votes
4answers
192 views

Generating all matrices with 1 (possibly) replaced by -1

I have a matrix $M$, whose dimension I am unsure of, which has only $\lbrace0,1\rbrace$ entries. I would like to generate all the possible matrices that result from changing (some subset) of the $1$'s ...
0
votes
2answers
79 views

Extract a List of Co-ordinates from a List of Complex Solutions

Let's say I have this list of solutions from a previous computation: ...
6
votes
2answers
307 views

Conditionally replace rows in lists

I have a sequence of matrices/lists ...
5
votes
5answers
1k views

Replace values which obey certain criteria

I'd like to replace all values in a list which obey one or more criteria with another value. Example: Replace all values>30 by 30. data={{3,35},{2,7}} ...
1
vote
2answers
161 views

Using patterns in ReplaceAll to extract elements from tuples at arbitrary depths

Please consider the following: I need to extract from MyList all last parts of each 3-tuple. ...
3
votes
2answers
247 views

Creating a Nearest function programmatically

I've been trying to work out how to create a Nearest function programmatically. My goal is to produce something similar to this, a hand-assembled function: ...
6
votes
1answer
370 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: ...
3
votes
3answers
792 views

How to replace all occurrences of an element in a list?

Consider the following: list={1,2,2,2,3}; I would like to replace all 2 with the string "Test". ...
19
votes
2answers
2k views

Extracting values from nested rules in JSON data

I have been using Mathematica to analyse some data from the StackExchange API. It is conveniently available in JSON form, which Mathematica interprets as replacement rules. However, some of the rules ...