# Questions tagged [map]

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

314 questions
Filter by
Sorted by
Tagged with
436 views

### Map vs. Table for index-specific operations on 2D arrays

Many experienced users on this site tend to use Map (and its variants, MapAt, MapIndexed, etc.) rather than Table. When applying the same operation to every element of an array, Map does seem more ...
109 views

### Creating a new Dataset column using a map from a second Dataset

Say I have two datasets: one is a detailed list of events, and one is a coarse list of events. I want to add a column to the detailed list from the coarse list (for the purposes of sorting). For ...
73 views

### A map function in a simulation problem

This is a continuation development of another post by @Dr. Wolfgang Hintze and deserves credit for the code work presented here. My modification was to include simple mapping to allow compare the ...
62 views

### Moving map with non-overlapping window

How can I apply a function to a list with non-overlapping window. E.g. $data = \{x_1, x_2, ...., x_n\}$ and we apply f with window size 2 to get $\{f(x_1,x_2), f(x_3, x_4), ...., f(x_{n-1}. x_n)\}$. ...
201 views

### How to find the positions of replaced elements in a list

I have two sets of elements a={3, 4.8, 5, 4.2, 3.6, 2.3, 4.5, 3.7} b={2.8, 4.7, 5.3, 3.5, 4.7, 2.8, 4.2, 3.4} and I create ...
2k views

### Simplify the code

I have a function that grabs the second part of the list and change it to times, ...
173 views

Consider a function f and a list p={a,b,c}. I want to get a list of ...
37 views

### Summing up elements of nested lists based on conditions from another list

Here is a simplified version of my question, nothing that I have a much larger dataset. I have a list of samples of proportions: ...
211 views

### List of lists elementwise greater/smaller than

I have two lists a = {{3,1,2},{5,1,3},{4,1,1}} b = {{4,0,3},{4,2,2},{5,0,2}} And would like to compare each element within ...
79 views

### Mapping a function with levelspec vs. Mapping over a flattened list

I have borrowed the following cyclic permutations list making function from here. ...
85 views

### Arrays, Mapping, and Convolutions

I'm trying to create a function that convolutes a 3D Normal Distribution to the points listed below. However, I think I'm going about it in the wrong way. When I try and convolve it with the points, ...
61 views

### Replace second derivative with product rule

Suppose that after some calculations, I find a[x]*D[g[x],x,x]+b[x]*D[h[x],x,x]+c[x]*D[j[x],x] What sort of operations do I need to do in Mathematica such that ...
40 views

### Mapping the FindMinimum function over a matrix

I'm quite new to Mathematica and so still trying to work out how to use some of its syntax and functions. I have a function for the free energy of a generic system with two order parameters. I am then ...
36 views

### Create a list to Plot from a list returned by Solve

I have a list of 8 items the form: ...
79 views

### How can I iterate across a list of triples?

i just started to use Mathematica and I`m completely new to programming. So i'm some kind of noob in the purest form.. I'm trying to transform a coordinate system into a different one. I'm using <...
82 views

### How to properly Abort from within a ParallelMap?

If a condition is met within a sub-kernel in the function being mapped, how does one cancel the whole ParallelMap operation? ...
127 views

### Using elements of list to solve a differential equation

I have created a list as shown in picture. the digits inside f are values of a and q respectively. I want to solve the Mathieu equation.....
64 views

### Map a function at the lowest level [closed]

How do I map a function to the lowest level of any given nested list? As an example, how do I create output from input in the ...
122 views

### Fast and Listable Piecewise function

I am writing a simulation where I have an array with ten columns and on the order of millions of rows, for which I need to iterate on the order of ten thousand times, making computation time a major ...
31 views

### Help with weird behaviour of Map[Take… on large lists

Lets say I create a giant list: tmp=RandomReal[{1,10},600000000]; Now I want to take 10 random sublists of length 150000: ...
152 views

### Apply Max to each element of a list [duplicate]

I have a list a = {1, 8, 0, 6, 5, 3, 5, 2, 2, 5} I want to generate a new list whose elements are the same of a if it's bigger than 5, or 5 elsewhere. I managed ...
144 views

### How to compute Maximum Drawdown faster and highlight data-list-line on the plot?

Given a list as ...
84 views

### How to caculate Position Cost Price in given trading list quickly?

Given a simulated trading list as ...
24 views

### Table of convolutes

Inputs Start with a vector $x\in\mathbb{R}^{n}$, and a vector-valued function $f:\mathbb{R}^{n}\mapsto\mathbb{R}^{n}$. Output Given some $k\in\mathbb{Z}^{+}$, what are elegant ways to produce the ...
115 views

### Parallelize[MapIndexed[…,Association[…]]] returns broken result

Bug introduced in 10.0.2 or earlier and persisting through 12.0 Confirmed: CASE:4041910 Consider the following example: ...
70 views

### Mapping over a piecewise function

This is a followup to a question I posted earlier today. Suppose you have a piecewise function such as "snap=max[x,0]= x if x>0, 0 otherwise". Then you would think that it must be straightworward to ...
68 views

### Using Map function with NDSolve

I would like to solve a set of differential equations but vary one parameter, KieP, between 900 and 1100. The solution for a given parameter has many peaks. I would then like to interpolate between ...
57 views

### How to map a function to a specfic level spec

I'm rewriting a function into a manipulatable graphic and while I'm happily surprised with how concise functional programming can be, I'm having trouble mapping the anonymous function ...
539 views

### Project map to a particular shape

I want to project a map to a particular shape, like a circle or ellipse. For example, let's imagine we want to project a map of the continental United states so that its outline is that of a circle. ...
122 views

### Operation on sublists with multiple arguments

I have a list and add only the values which are > 0 with: Total[Cases[mylist, x_ /; x > 0]] How to do this if I now have a list of sublists? ...
82 views

### Run function as loop over two matrices

I'm still wrapping my head around Mathematica syntax. I have a matrix clustersAll that looks like ...
110 views

### How to give a function multiple variables in a mapped and nested list?

I come from python (not advanced tho), and have been learning mathematica. I'm currently struggling with the following code: This is a basic version of what i wanted to implement: ...
173 views

### @ and Sequence ( and /@ ) [duplicate]

list = { {a,b}, {c,d}, {e,g} } How to efficiently get { f[a,b], f[c,d], f[e,g] } I tried various combinations using ...
258 views

### Clear variables inside Module

I have a function that uses Module. The function takes as input a .csv that can have as many columns as it wishes to, and it ...
54 views

### Can I Use a List To Position An Arbitrary Number of Graphic Objects?

I can use a function to compute the positions of individual nodes of a neural network based on how many there are in each layer (nodesPerLayerList below). Now I want to display them all in position. ...
267 views

### Applying functions to lists

I have a few expressions $f(\theta,x)$, $g(\theta,x)$, $h(\theta,x)$ in terms of two variables, an angle and a length. The angle goes from $-\pi/2$ to $\pi/2$ and the length from 200 to 1500. This is ...
154 views

### Mapping slots over lists

In the meantime I'm accustomed to write special character orgies like D[%,#]&/@L (to quickly fish out the coefficients of the last input with respect to ...
33 views

### Color filling by GDP in a map

I would like to have a tool where one can type in a minimum GDP level and then every country that has this minimum level gets filled with color.
89 views

### How to I use Map to apply a defined function to a list?

Problem: How to map a function onto a list. My (example input: mylist = {{1, 2}, {3, 4}} gg[x_, y_] := {N[x + y], N[x y]} Map[gg, mylist] Expected output: ...
66 views

### Angle between one vector and a list of vectors [closed]

I have one vector v1 and one list of vectors v2. I want to find the angle between them (see below): ...
135 views

### How to Parallelize a simple MapAt?

I have a simple map I would like to parallelize (4x speedup for my 4 cores): ...
105 views

### Extracting the graph of Keys in nested Associations

Related to this q: Extract all Values from nested Association How to extract the direct graph of all Keys in nested Associations...
77 views

### Multivariate map

I have a multivariate function that I want to map into a triple of variables. ...
327 views

### MapThread Not Mapping on Ragged Array [duplicate]

Update: WRI Support has considered this a missing feature of MapThread instead of a bug. A request to update MapThread to ...
97 views

### Removing outer concentric circle picked up by ComponentMeasurement

So I have performed EdgeDetect and ComponentMeasurements on my images and obtained a pretty good elliptical fit. However, the black shadow of the beads in the image is being picked up by ...
49 views

### Error when using Map in Pure Function [closed]

I'm trying to solve Project Euler 21 My solution is as follows: ...
241 views

### Setting each “curve” on a 3D plot to be of different colour similar to that of its 2D plot

Consider the functions ...
41 views

### Apply all possible permutations into a function [duplicate]

I need to create a function that returns all possible trebles of integers that sum up to a given number. For example, is n=2 then I need something like this: ...