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
6 votes
10 answers
135 views

How to write a duplicate mapping function?

I need a function MapDuplicate that maps a function on all the duplicates in a list. Consider the following list: ...
user13892's user avatar
  • 9,033
0 votes
0 answers
62 views

Around with multiple Slots and Map [closed]

I use the following code to produce a list of Around from data: ...
OpticsMan's user avatar
  • 560
5 votes
4 answers
327 views

Applies f to all locations other than the specified location

MapAt[f, <|"a" -> 1, "b" -> 2, "c" -> 3, "d" -> 4|>, Except["b"]] I want to apply the function <...
yode's user avatar
  • 26.1k
4 votes
2 answers
244 views

Enumeration of a nested list

My problem is consisting of following: I have a nested list of following form: {{B, v ** v, b ** B}, {b, B ** b}, {b ** B, v ** v}, {}} And I want to enumerate ...
George's user avatar
  • 67
2 votes
1 answer
165 views

Efficient way to MapApply for Tensor

I need to Map a function with certain arguments $f(\alpha,\beta,\gamma,\delta)$ onto a whole tensor. My current approach looks like ...
mathetronaut's user avatar
1 vote
0 answers
60 views

get the first from a list using slots [closed]

Problem. I work with a list and want to get the first element. For specific reasons I want to use # in combination with Map For example ...
Michiel van Mens's user avatar
2 votes
2 answers
89 views

Map, applying list in a defined function

Suppose I have defined some function (This is arbitrary) F[alpha_,a_,b_,c_]:=List[alpha,a+b+c] I want to apply this F for a given huge list of sets ...
phy_math's user avatar
  • 801
0 votes
1 answer
54 views

How to combine multiple plots via Table when a map is being applied? [closed]

This question is based on this answer ...
codebpr's user avatar
  • 899
0 votes
0 answers
47 views

Creating a heat map in a circle according to positions on x and y axes [duplicate]

I would appreciate advice on writing code. I need to draw a heat map according to positions, it indicates object trajectory so the order is matter. The positions are saved in a nested list. An inner ...
erez's user avatar
  • 297
1 vote
0 answers
49 views

Comparing performance of `ParallelMap` with pure function

Test data are here: q = CloudGet[ "https://www.wolframcloud.com/obj/874e3b18-808a-404a-aaa0-4e3ad1ac4668"]; I construct interpolation and an equi-...
atapaka's user avatar
  • 3,703
0 votes
0 answers
21 views

`ParallelMap` on `TimeSeries` not working properly, operations on `TimeSeries` extremely slow

I have this data: CloudObject["https://www.wolframcloud.com/obj/25f4b06e-2c89-4909-841d-83b7888b6ed8"] which you can get by ...
atapaka's user avatar
  • 3,703
0 votes
0 answers
36 views

Parallel constructs and automatic kernel starting

The help gives an example on ParallelMap: ParallelMap[(Pause[1]; f[#]) &, {a, b, c, d}] // AbsoluteTiming I tried it and it ...
atapaka's user avatar
  • 3,703
5 votes
2 answers
296 views

Can I exit a Map over a list of data pairs?

I've written a function, which I intended to Map over lists of some 8,000 element pairs. I created the "toy" code below to illustrate my problem. ...
Jagra's user avatar
  • 14.3k
3 votes
0 answers
74 views

Creating a mesh map with river cross-profiles

I am trying to create a type of 3D mesh map using multiple cross profiles/cross-sections of a river. I have the longitude, latitude, and elevation imported, with two examples shown below: ...
Andrew Bowsher's user avatar
8 votes
4 answers
602 views

How can I "multiply" nested lists?

Given two nested lists alist={{a,b,c},{d,e,f}} blist={{r,s,t},{x,y,z}} How can I get ...
1729taxi's user avatar
  • 737
5 votes
3 answers
142 views

Substituting the element of a list into a list that contains the index position

I see similar questions for lists and indexes and manipulating with Thread, MapIndexed,etc., but I do not see how to do a substitution. I have a list of coordinates for a geometric object and a list ...
jacobian's user avatar
7 votes
2 answers
184 views

Map function with evaluated and unevaluated parameters

Let's consider a function with evaluated and unevaluated arguments inside: list1 = {1,2,3} list2 = {x,y,z} fun[list_]:={list,ToString@Unevaluated@list} When I use ...
Lechuu's user avatar
  • 392
3 votes
1 answer
63 views

Trouble Mapping a Geometric Transformations over a List of different types of Graphics Objects

I am working on some code that allows me to auto-rotate graphics (including ParmetricPlot3D and Plot3D graphics) objects while preserving mouse dragging in a smooth fashion. It works great. The code ...
B flat's user avatar
  • 5,377
2 votes
1 answer
85 views

Simplify Map on a list of lists

I have the following example list of matrices: a = {p Table[RandomComplex[], {2}, {2}], q Table[RandomComplex[], {2}, {2}]} where p and q are real variables. I ...
Sid's user avatar
  • 957
3 votes
1 answer
81 views

MapAt with pure functions

Consider expr = Hold[1 + a + x + b + c + y + z]; idxes = {{1, 3}, {1, 4}}; Q1. I don't understand why ...
Nicola's user avatar
  • 572
1 vote
2 answers
90 views

Specify index of array for Map operation

I want to calculate the determinant along the last slice of a 3-dimensional array. So for I do this by slow the Table command. I know that for time reasons I should ...
granular bastard's user avatar
8 votes
6 answers
733 views

How to create a matrix of paired values from two matrices?

I have two matrices. They are, m1={{a,b},{c,d}}; m2={{w,x},{y,z}}; I want to create a matrix of paired values that looks like this, ...
desla.slade's user avatar
3 votes
2 answers
82 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, ...
Jens's user avatar
  • 143
4 votes
5 answers
186 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 ...
codebpr's user avatar
  • 899
5 votes
3 answers
141 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. ...
azerbajdzan's user avatar
  • 7,044
4 votes
2 answers
208 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 ...
Alan's user avatar
  • 13.5k
11 votes
2 answers
464 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 ...
matheorem's user avatar
  • 16.9k
2 votes
2 answers
92 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 ...
user2686410's user avatar
7 votes
3 answers
468 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] ...
QuantumDot's user avatar
  • 19.5k
5 votes
2 answers
571 views

Maps between finite sets

With SageMath, one can do FiniteSetMaps(["a", "b"], [3, 4, 5]) to get all maps from {a,b} to ...
Thrash's user avatar
  • 395
14 votes
4 answers
675 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 ...
JohnA's user avatar
  • 243
6 votes
5 answers
890 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, ...
Ito's user avatar
  • 61
7 votes
5 answers
599 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: ...
Joshua Salazar's user avatar
4 votes
1 answer
86 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 <...
miniplanck's user avatar
7 votes
1 answer
201 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 ...
Patchouli Nine's user avatar
5 votes
1 answer
141 views

A Naive Prime Test Implementation - Problem with Table

I tried to write a simple function which implements a naive primality test. ...
Benjamin's user avatar
  • 153
5 votes
2 answers
451 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, ...
Joshua Salazar's user avatar
1 vote
1 answer
100 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 ...
Marcosko's user avatar
  • 239
0 votes
1 answer
91 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 : ...
user84456's user avatar
  • 1,502
3 votes
0 answers
77 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 ...
rhermans's user avatar
  • 35.8k
3 votes
4 answers
286 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. ...
imida k's user avatar
  • 4,037
0 votes
1 answer
36 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 ...
Jocelyn Minini's user avatar
0 votes
2 answers
60 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 ...
Red Banana's user avatar
  • 5,121
0 votes
2 answers
53 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 ...
Red Banana's user avatar
  • 5,121
1 vote
1 answer
56 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 ...
Alex97's user avatar
  • 370
0 votes
1 answer
178 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 ...
a019's user avatar
  • 811
0 votes
0 answers
91 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 ...
Aschoolar's user avatar
  • 883
0 votes
0 answers
34 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%...
Jenjira Kitwakin's user avatar
1 vote
0 answers
77 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 ...
Peter Burbery's user avatar
0 votes
1 answer
63 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 ...
Jenny's user avatar
  • 1

1
2 3 4 5
8