Questions tagged [map]

Questions about applying functions or operators to expressions, especially constructs that take advantage of Map (/@) functionality.

Filter by
Sorted by
Tagged with
3 votes
2 answers
43 views

Apply function to specific elements in list [closed]

Say I have a list like myData={{1,m1,v1},{2,m2,v2},{3,m3,v3},{4,m4,v4}}. It could be a dataset, where the first and second variables in each tuple is as desired, ...
  • 123
4 votes
5 answers
177 views

Converting specific positions of a List into Sublist

Suppose I have a List of numbers: num = Range[5] I want to combine the second and the third element into a sublist to get the result as {1,{2,3},4,5}. I tried ...
  • 585
5 votes
3 answers
122 views

Complicated double mapping over nested list

I have a list that each term consist of two parts. First part is a graph and second is a list of pairs of vertices that I want to find graph distance of. ...
  • 3,840
4 votes
2 answers
201 views

What should mapping over a number or symbol produce?

I expected it to be an error (i.e., produce an error message), but Map[f,num] is num. Why is this the correct behavior? If it is ...
  • 12.7k
11 votes
2 answers
449 views

How can I create an atomic head or treat some head as atomic during Map?

For example, Map[g, {0, {h[1, 2, 3]}}, {-1}] gives {g[0], {h[g[1], g[2], g[3]]}} I want a ...
  • 16.4k
2 votes
2 answers
81 views

Mapping Part to a List [closed]

I have a list, x, where each member is itself a list of 2 coordinate points. Sometimes a member is a list of only 1 point, sometimes it is a list of more points. Note that the last member below is a ...
7 votes
3 answers
428 views

How do I map a function pairwise?

Given a list of pairs: data = {{a,b},{c,d},{e,f},{g,h},{i,j}} I need the moving map: MapPair[F,data] ...
5 votes
2 answers
409 views

Maps between finite sets

With SageMath, one can do FiniteSetMaps(["a", "b"], [3, 4, 5]) to get all maps from {a,b} to ...
  • 335
14 votes
4 answers
632 views

Monitoring Apply / @@@ over large lists

How to monitor and/or print partial progress of Apply, e.g. f @@@ list? I have found answers using Map (e.g. this nice trick using Echo, or this general trick), but ...
  • 243
6 votes
5 answers
812 views

How can I apply a function only to even-index elements of a list?

A = {1, 2, 3, 4, 5} and, Dd[P_] := P + 1 How can I map "Dd" into "A" such that the outcome is: {1, 3, 3, 5, ...
  • 61
7 votes
5 answers
433 views

Smart way to remove rules from lists, leaving just values, specifically from FindMinimum output

I would like to know if there is a direct way to remove the rules from a list of rules. I know that, simply, this can be done with: ...
4 votes
1 answer
77 views

Mathematica replaces list of zeros with zero [closed]

Consider the following functions: f[x_]:= {{Im[x], Re[x]}, {Re[x], Im[x]}}; g[x_]:= {{Im[x],0},{0,0}} When applying each of the functions to the list of lists <...
7 votes
1 answer
173 views

How can I do "Map" on a binary function?

If there is a one-variable function, we can f/@{a,b,c} to get {f[a],f[b],f[c]} What to do with it if it comes to a binary ...
5 votes
1 answer
135 views

A Naive Prime Test Implementation - Problem with Table

I tried to write a simple function which implements a naive primality test. ...
  • 153
5 votes
2 answers
330 views

Map a two argument function to every element on list

I'm new to use the amazing map function in Mathematica, and I've found it really elegant to program in simple lines of code. However, I'd like to perform more elegant stuff. I've found this question, ...
0 votes
0 answers
39 views

Trying to map SparseArray over a defined list, the SparseArray defined with 3 subvalues i want to map the 3rd. subValue(list) over the defined list

I have a SparseArray already defined as following ...
1 vote
1 answer
87 views

ReplacementAll with list elements

I'm trying to define a function that replaces certain expressions that appear when calculating scattering amplitudes (not important). Basically, I have a function ...
  • 209
0 votes
1 answer
71 views

How to use map and slot effectively?

I want to change my code from : f[n_, x_] := n Sin[x ] Table[{x, f[0, x], f[1, x], f[2, x], f[3, x]}, {x, -\[Pi], \[Pi],1.0}] // Chop with OUTPUT : ...
  • 664
3 votes
0 answers
66 views

Video processing: Efficient way to apply function to pixel time stack (FIJI's Intensity Z-projection)

Starting from a Video, I would like to apply a function f to the stacks of intensity values, over time, for each pixel. In FIJI ...
  • 31.2k
2 votes
4 answers
259 views

Applying f for a part of list (MapAt is slow)

Suppose that there are 2000 stones in a row. You should grind 1000 of them to make beads. The time loads(making beads) for each stone are similar. But which 1000 stones? case1) the first 1000 stones. ...
  • 3,231
0 votes
1 answer
33 views

Private variable issue in a function environnement

I have the following matrix which represents an input from a .txt file. The first column gives the name of the random variable, the second the probability law, the third the parameters related to the ...
0 votes
2 answers
58 views

How to construct a function that picks elements of the kind $\{-1,\{\}\}$?

I am trying to do the following: Given the list {{-1,{}},{2,{1,2}},{-7,{}},{a,{}}}, I am trying to construct a function that throws out all elements with anything ...
  • 4,911
0 votes
2 answers
51 views

How to apply a function to the elements of a list with the "L /. x_ ->f[x]" notation? [closed]

Suppose we have a list: {5,6,7} Suppose I have a function like GCD[x,10] and I want to apply it to the given list. I'm trying ...
  • 4,911
1 vote
1 answer
47 views

How to separately pass elements of a 3D list as part of the arguments of a function

Hi I have a function which its arguments have the form F[a,b,c,d,e] but the 2nd to 4th arguments are in a list of the form R={{{b,c,d},{e,f,g}},{{h,i,j},{k,l,m}}} how can I pass these elements as ...
  • 350
0 votes
1 answer
106 views

Contour plot with x, y and z values?

I have x , y and z as x = List[1.355, 1.357, 1.359, 1.36, 1.357, 1.355]; and ...
0 votes
0 answers
52 views

Converting 1D map into first order differential equation for bifurcation diagram code

I have existing code to plot bifurcation diagram for coupled first order differential equations. It seems to work for coupled differential equations. To test the code further, I use the simplest ...
  • 863
0 votes
0 answers
44 views

Trouble with bifurcation of differential equation

The code for bifurcation is written in such a way that it will allow plot bifurcation for any number of differential equation. Thus I am trying to avoid maps and iterations. Unfortunately it does ...
  • 863
0 votes
0 answers
29 views

How to make a manipulatable map that can change color?

I want to color the world map differently according to how much the number of each country. For example, USA using renewable energy for 20% should be colored lighter than Canada using renewable for 50%...
0 votes
0 answers
28 views

Adaptation of existing code to multivariable system

I am trying to adapt the existing code from "Mathematica package for analysis and control of chaos in nonlinear system" by Gutierrez. This existing code calculates the Lyapunov Exponent by ...
  • 863
1 vote
0 answers
62 views

How to find N most populous cities in each state with TakeLargest and Entity Functions without waiting forever using Caching?

I am interested in using Entity Functions such as EntityValue, FilteredEntityClass, EntityFunction, EntityClass, EntityList, and GeoEntities to help me find N most populous cities in each state. I ...
0 votes
1 answer
62 views

Mapping data from 2 files imported

I'm not in prog major. This course is needed as an elective for another major. Thus any help is appreciated. DataA and DataB ...
  • 1
5 votes
1 answer
264 views

What's the difference between @ and /@? [closed]

The @ and /@ functions do the same thing: ...
1 vote
0 answers
88 views

compiled function not mapable

I am currently working on speeding up a larger project and thus using FunctionCompile. I have come across the issue that a manual input of list elements produces a valid results, however if I try to ...
2 votes
2 answers
120 views

How to split many controls in Manipulate into multiple columns (saw some potential bugs)

I need to use Manipulate[] with many controls, because I have around 40 parameters which I want to be able to alter. Since the number is too large, I want to split these controls into multiple columns,...
  • 675
2 votes
0 answers
96 views

How to use Select and MemberQ together with Map correctly?

I have a list with quite a few elements. Each element is a rule of the type vector-> number such as {1,2,3,4}->1.435 and ...
1 vote
0 answers
92 views

Map a function that uses the lists indices as arguments

Suppose I have a function f[x_] that I want to Map over somelist (assumed to be one ...
  • 45
1 vote
0 answers
170 views

How to limit the cpu usage of Mathematica?

I am runing mathematica with ParallelMap[], on a win10 computer with 8 physical cores. The cpu usage always rocks up to 100%, though ...
  • 57
0 votes
0 answers
85 views

Evaluate a function with 3 different variables for the whole list of each variable

I have a function with 3 variables f[t1,t2,t3] Each function has a list of values ...
2 votes
1 answer
90 views

Considerations for Compiling and Parallelizing Code Outside or Inside Map[]

Assume f as well as Map[f,list] are parallelizable and compilable, such that parallelization and compilation give significant ...
2 votes
2 answers
101 views

Mapping list elements without using Table function

How could I generate the following list of points using some function or mapping without using the table function. ...
3 votes
1 answer
74 views

How to Map over a BlankSequence? [closed]

I would like to replace any function f[x, y, ...] in a certain expression with the same function with all its arguments squared, i.e. ...
  • 117
4 votes
3 answers
160 views

Curious about Mapping over multiple multiple arguments [closed]

To my shame, I have discovered the power of Map quite recently and since then I have been using it more and more. But increasingly I find myself trying to use ...
  • 573
3 votes
0 answers
75 views

How to digitize a vector field?

Is there some way that I can digitize both the direction and the magnitude of a vector field accessible in JPEG format? To clarify what I mean, I want to have the numerical value of: 1)magnitude and 2)...
4 votes
2 answers
81 views

Applying transformation rule for corresponding indices?

I have two lists, that looks like below list1 = {a, x, b, x, x, c}; list2 = {2, 3, 4, 5, 6, 7}; Any time there is an x in the ...
0 votes
0 answers
112 views

Iteration limit exceeded

I am trying to adapt the following piece of code (coming from this answer): ...
  • 6,214
1 vote
1 answer
95 views

how I should use `MovingMap` on a `Dataset`?

I am aware of How would I use Map on a Dataset column? still I cannot see how I should use MovingMap on a Dataset. Even the ...
  • 1,350
0 votes
1 answer
79 views

Recursive addition of vector list to last elements of vector lists

This question refers to an extension of Add list of vectors to list of vectors recursively . I tried hard to complete the problem but now I got stuck. I have vectors ...
  • 2,030
5 votes
2 answers
139 views

bind specific 'Slots' to specific 'Map'

Is it possible to construct a pure function using multiple slots, with the following concept :       Binding   specific slot    to    specific apply or map For example : In this example, To ...
  • 3,231
3 votes
2 answers
138 views

Restrict kinds of heads when dealing with level concept

In[1] Map[(# + 7) &, {a, 3 b, {c, d}, e}, {2}] Out[1] {a, 10 (7 + b), {7 + c, 7 + d}, e} But I want feature like ListMap : ...
  • 3,231
0 votes
0 answers
44 views

calculate differences of a list using slots

I want to calculate the differences between the numbers of a list. One way to do that is using 'Differences'. For example: L = {1, 3, 6, 9}; Differences[L] this ...

1
2 3 4 5
8