The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
0answers
40 views

How to apply Map to level 2 elements in a list [closed]

I am new to Mathematica so this might be a trivial question but i've been stuck on it for an hour and any help would be greatly appreciated. I want to Map a ...
2
votes
2answers
90 views

Why is Nearest not giving me expected result

I have the following list: numbers={0.,0.6,0.8,1.,1.2,1.4,1.8} Then I calculate the midpoints: ...
0
votes
1answer
39 views

Elegant ways of solving this file batching task

There are a batch of data files in a folder (dir = "D:\\Documents\\datadir"), each of which consists of a list of data items, one per line. Each data item is a pair ...
2
votes
3answers
78 views

How to test a condition for a list and output all the expression that is true?

Suppose that I have a list lis={x-y,x+y,x*y}; and a function f[a_,b_]:=#/.{x->a,y->b}& I want to output all the ...
4
votes
2answers
63 views

Count the number of element repeats at various distances

I have a function of x: f[x_] := Abs[Extract[list, x + n] - Extract[list, x]] I then apply this: ...
1
vote
1answer
56 views

For loop with MapIndexed and If [closed]

I have a for loop that uses MapIndexed and If to build a a list called avald1. The problem ...
2
votes
2answers
148 views

How to Map each cell in a matrix to another and solve the system?

tab1 = {{a1, a1 + a2}, {b1, b2*b2}} tab2 = {{2, 5}, {5, 2}} I want to map like this ...
4
votes
1answer
55 views

How can Map be given access to the keys of a Dataset?

Consider an example Dataset: ...
0
votes
1answer
20 views

MapThread with incompatible length (How to Map twice in the same line)

l and b are two lists of vectors with different length. I need the list of vectors that is constructed by adding each member of ...
5
votes
2answers
240 views

Mathematica periodic moving map

I am pleased to have MovingMap in Mathematica 10. But, today, I encountered the problem that needs MovingMap with a periodic boundary condition. To be specific, Consider the following example. ...
2
votes
1answer
113 views

Excluding cases from Map

I'm doing operations of the form: PowerMod[#, -1, 126]+# & /@ Range[1, 125] When a number is not invertible, I don't want it to be included in the result ...
2
votes
3answers
65 views

How to manipulate one column of a table using the value in another column

Let's imagine I have the following table structure data = {{a, b}, {c, d}, {e, f}}; and I want to transform it into the following table ...
3
votes
1answer
42 views

Mapping also for one element (or telling it how to do so if head got changed)

Some code generates a polynomial, and has the form: expr = Plus[a[i],b[i],c[i],d[i]] I need to apply f to each term. To do ...
2
votes
2answers
59 views

Partial application of MapThread

Suppose that I have f[a_, b_, x_] := ... I'd like to create a list of n pure functions ...
8
votes
3answers
311 views

Operate over list of pure functions

I have list of pure functions (All functions are InterpolatingFunction) i.e {{a, b}, {c, d}, {e, f}, ...} and I would like ...
2
votes
3answers
113 views

MapAt a function at specific positions

I'm trying to solve for $p3$ in 3p3-5 = p1 + p2 at positions where p1*p2 == 0: ...
1
vote
0answers
75 views

Elementwise operation, part deux [closed]

There are many answers to this question: which are forms of Mathematica's map, but languages like Scheme (I think also Python in recent years) also provide a ...
5
votes
1answer
124 views

Mapping over an association producing an unexpected result

The documentation for associations says that the keys of an association are transparent for many operations. Map is one such operation. However, I am confronted ...
6
votes
3answers
169 views

Mapping a function over the parts of a deeply nested Array

I have two tensors: tensorS = Array[Subscript[s, #1, #2, #3, #4] &, {2, 16, 16, 19}]; tensorR = Array[Subscript[r, #1, #2, #3] &, {2, 16, 19}]; ...
4
votes
2answers
116 views

Is there a built-in function to map a list of heads to a list of data?

Assume that this built-in function is called func. What I want is func[{f,g},{a,b,c}] will return the following result: ...
16
votes
4answers
346 views

Make MapIndexed listable

My goal is to apply MapIndexed to every element of a nested list without destroying the arithmetic operations within the elements. For example, let's start with ...
4
votes
4answers
114 views

Plot range of a 2-dimensional function as a function depending on one variable

I want to plot a function of 2 variables x and y, for discrete values of y, like: ...
0
votes
1answer
74 views

Map Elements of a list to be Index of matrix

I have a sublist from Tuples[{1, 2, 3}, 2], say for example L={{1,2},{2,1},{2,2}}, and a 3 x 3 matrix ...
6
votes
2answers
270 views

Apply function to every element of list regardless of depth

I want to apply a function to every element of a list without taking braces into account (depth level), but with the same form of output. Here is an example : ...
0
votes
1answer
86 views

ParallelMap returns incorrect results over Map

I've written a function to pull in the useful column of a large data file: ...
24
votes
3answers
461 views

Changing Values in an Association using Map

I am trying to change the value of one key in an association based on the value of another key in that association. So if my association starts as: ...
2
votes
2answers
122 views

Map 2 list to a function

Im playing around with CountryData and I want to pass it 2 lists as argument, listCountries = {...} and ...
4
votes
1answer
497 views

Why is there a huge performance gap using Map with more than 100 List entries

im using Map on a List like this: cube= {{1, 1, 1}, {1, 1, 2}, {1, 1, 3}, {1, 1, 4}, ... , {5, 5, 4}, {5, 5, 5}} Mapping the whole List with 125 entries takes ...
2
votes
1answer
87 views

Can I use Map here rather than Table?

I've got something that works, but it seems like it would be "nicer" if I didn't have to use Table (or For, etc.). I've got 3 Excel files, each with multiple sheets. Each file also has a sheet ...
1
vote
4answers
203 views

Unexpected result from Map [closed]

I'm using Mathematica 8.0. Is the following output a bug or do I miss something? f[a_] = 2 a; Map[f,1+x] gives $2+2x$ as expected, but ...
3
votes
4answers
146 views

Correct slot assignment when mapping from different lists using pure function

Given expr = u == a1 + a2 x + a3 y; and uRep = {u1, u2, u3}; xyRep = {{x1, y1}, {x2, y2}, {x3, y3}}; I'd like to generate ...
0
votes
1answer
43 views

Testing a certain function over multiple levels

I regularly want to test if a certain function, here foo, gives the expected result when mapping it over n - level - matrices. My naive approach is to write: ...
2
votes
1answer
152 views

Loop in solving multiple matrix calculation

I am wondering is there a way to use loop, like Do, For, to rewrite the last line in the code. I tried to use ...
0
votes
1answer
117 views

Mapping a function over n levels

I want to map a function over a matrix of rank n, for example: ...
0
votes
1answer
98 views

How do you add options to a function that is being mapped?

Simple example: Normally: ListPlot[list, Joined->True] If I want to map ListPlot how do I keep the ...
5
votes
1answer
83 views

MapIndexed stops at levelspec 1 if only the index is passed?

If the function passed to MapIndexed references the first (or data) argument, the following performs as expected: ...
1
vote
1answer
64 views

alignment of plots [closed]

I want to align my plots like I did with Gird[]. But you cracks here are using these short forms all the time. So, is there a way to achive this result in a better ...
9
votes
2answers
568 views

Scan vs Map vs Apply

I cannot understand the difference between Apply, Scan, and Map. I have tried to play with ...
2
votes
1answer
119 views

Country borders and grids with CountryData plot?

I am coloring several countries in the manner of the following: ...
0
votes
2answers
145 views

Apply Eigenvalues to a list of matrices

I would like to apply Eigenvalues[] to a list of matrices as in the following ...
3
votes
2answers
254 views

Mapping multiple functions over an array

I am looking for an elegant way to Map multiple functions over an array. My problem looks something like this: Consider a list of functions: ...
0
votes
0answers
31 views

Using Map with functions that take a parameter [duplicate]

I have a list l={{0, 0, 0, 3}, {0, 0, 0, 3}, {0, 0, 1, 2}} And I would like to obtain the number of zeros in each sublist: ...
3
votes
4answers
349 views

How to apply a function of several arguments to a list?

I have a list of triplets: list = {{1, 3, 5}, {4, 5, 1}, {4, 9, 2}} How can I apply a function f to the last element of each triplet when f the last and ...
0
votes
0answers
31 views

Use Map with OptionValue [duplicate]

Trying to map OptionValue to a list of option names doesn't work. ...
0
votes
1answer
55 views

Function output of two lists are only diagonal elements

I'm having a little crysis over here. What I basically want to do is some sort of 3D-Plot, but I'm only interested in the resulting values. I have two vectors x and p: ...
4
votes
1answer
93 views

Parallelize[Mapindexed[]], level={-1}? Sal Mangano's 《Cookbook》

It is easy to Parallelize[] Map[] & MapIndexed[], as having been shown in MMA9 Help for ParallelMap[] and Parallelize[]. For MapIndexed[], the default levelspec is {1}. However there are many ...
1
vote
3answers
176 views

Distinguishing slots in a function mapping Position across a list

Suppose that I have a list myList that has more than one level. Here is an example of such a "data structure": ...
1
vote
1answer
219 views

MapThread multiple functions onto multiple lists

I'm trying to learn the functional style which seems to prevail in Mathematica. I'm having trouble accomplishing the following: Let's say I have multiple lists of arbitrary data (using two lists ...
0
votes
1answer
59 views

Mapping a function of two arguments where the 2nd arg has a fixed value

I create three random images: i1 = Image[RandomReal[1, {8, 12, 3}]]; i2 = Image[RandomReal[1, {8, 12, 3}]]; i3 = Image[RandomReal[1, {8, 12, 3}]]; I can scale a ...
2
votes
0answers
104 views

Want explanation of when different looping constructs are appropriate [duplicate]

For example when would you use a Do loop over a For loop? For which tasks would you use Map, ...