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
4 votes
2 answers
338 views

Maps between finite sets

With SageMath, one can do FiniteSetMaps(["a", "b"], [3, 4, 5]) to get all maps from {a,b} to ...
user avatar
  • 315
13 votes
4 answers
589 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 ...
user avatar
  • 233
6 votes
5 answers
794 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, ...
user avatar
  • 61
7 votes
5 answers
389 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: ...
user avatar
4 votes
1 answer
68 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 <...
user avatar
7 votes
1 answer
159 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 ...
user avatar
5 votes
1 answer
133 views

A Naive Prime Test Implementation - Problem with Table

I tried to write a simple function which implements a naive primality test. ...
user avatar
  • 153
5 votes
2 answers
299 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, ...
user avatar
0 votes
0 answers
35 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 ...
user avatar
1 vote
1 answer
63 views

ReplaceAll command using 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 ...
user avatar
0 votes
1 answer
63 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 : ...
user avatar
  • 319
3 votes
0 answers
58 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 ...
user avatar
  • 28.9k
2 votes
4 answers
249 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. ...
user avatar
  • 2,451
0 votes
1 answer
30 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 ...
user avatar
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 ...
user avatar
  • 4,801
0 votes
2 answers
49 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 ...
user avatar
  • 4,801
1 vote
1 answer
45 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 ...
user avatar
  • 340
0 votes
1 answer
68 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 ...
user avatar
0 votes
0 answers
45 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 ...
user avatar
  • 723
0 votes
0 answers
37 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 ...
user avatar
  • 723
0 votes
0 answers
28 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%...
user avatar
0 votes
0 answers
26 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 ...
user avatar
  • 723
1 vote
0 answers
56 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 ...
user avatar
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 ...
user avatar
  • 1
5 votes
1 answer
259 views

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

The @ and /@ functions do the same thing: ...
user avatar
1 vote
0 answers
84 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 ...
user avatar
2 votes
2 answers
111 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,...
user avatar
  • 675
2 votes
0 answers
81 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 ...
user avatar
1 vote
0 answers
72 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 ...
user avatar
  • 45
1 vote
0 answers
135 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 ...
user avatar
  • 57
0 votes
0 answers
69 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 ...
user avatar
0 votes
0 answers
40 views

How to map the outputs to different output lines?

I have the following code GraphIt[n, n2, IR, #] &/@ vanishpts where the function GraphIt print something, and returns a graph. I don't want my outputs to be ...
user avatar
  • 65
2 votes
1 answer
83 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 ...
user avatar
2 votes
2 answers
96 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. ...
user avatar
3 votes
1 answer
70 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. ...
user avatar
  • 107
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 ...
user avatar
  • 563
3 votes
0 answers
71 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)...
user avatar
4 votes
2 answers
79 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 ...
user avatar
0 votes
0 answers
90 views

Iteration limit exceeded

I am trying to adapt the following piece of code (coming from this answer): ...
user avatar
  • 6,114
1 vote
1 answer
85 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 ...
user avatar
  • 1,350
0 votes
1 answer
64 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 ...
user avatar
  • 2,020
5 votes
2 answers
136 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 ...
user avatar
  • 2,451
2 votes
2 answers
135 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 : ...
user avatar
  • 2,451
0 votes
0 answers
43 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 ...
user avatar
0 votes
1 answer
43 views

How to prevent small locations from being plotted as points when using GeoListPlot?

When a location is too small, GeoListPlot marks that location using a point on the map. For example, ...
user avatar
1 vote
1 answer
70 views

Manipulate mapping on lists

For some function f, consider the following expression: ...
user avatar
  • 883
15 votes
1 answer
973 views

Metropolis-Hastings Algorithm - Significantly slower than Python

I would like to code a Metropolis Hasting algorithm and thought I would get the general scheme of things going with a toy example. I think I got it running but my Mathematica code runs significantly ...
user avatar
0 votes
0 answers
48 views

How to change Point options when using Map?

I want to change the point size of the points I am plotting in the code below, but wherever I place the PointSize[] option it doesn't like it. The code is part of a larger program, which generates a ...
user avatar
1 vote
1 answer
53 views

loop execution time difference after Map operation

I am box filtering data from a DNS simulation. When filtering the original data read from a file, this is fast. When filtering a function of these data after applying Map, it is 10 times slower. If I ...
user avatar
1 vote
1 answer
106 views

Optimal way to evaluate a function over many points

This piggy-backs on my previous question: Parameter space search routine is too fast? I am looking for a fast way to evaluate a symbolic list over many points. So lets say I have a list of symbolic ...
user avatar
  • 413

1
2 3 4 5
8