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
4 answers
86 views

How to stop mapping on true results for large lists?

Assuming I have a long list (real data with more than 100k elements). I have a function that I want to apply to the list, for example, EvenQ. I want the mapping to stop once the result for one element ...
internet's user avatar
  • 733
0 votes
1 answer
35 views

Map Integrate onto one single term

This is related to the question (Integrate many simple terms fast) I had before, where Nasser gave me an answer which worked 'most of the time' but not always. Context: ...
Confuse-ray30's user avatar
5 votes
3 answers
212 views

How to highlight top N elements in each table column?

I have tables with column and row headings, similar to this one: table = {{"",0.1,0.01}, {{1,0},1,3}, {{1,1},2,4}} I want to highlight top N elements in ...
homocomputeris's user avatar
6 votes
1 answer
126 views

Want Map function to apply over sum of terms but not product

For a given function F, if I use Map[F,a+b+c d], Mathematica returns, as desired: F[a]+F[b]+F[c d] ; However, for ...
user160385's user avatar
1 vote
0 answers
30 views

Change specific elements of a list [closed]

I have currently looking to change specific elements of a list. I saw that you can apply a fonction to an element if you know it's position as shown in this question : Apply function to specific ...
Doodger24's user avatar
7 votes
7 answers
449 views

Accumulated instance count of each list element

Given a list with repeated elements, for example: list = {m, i, s, s, i, s, s, i, p, p, i} I'd like to determine, for each position in the list, how many times the ...
thecommexokid's user avatar
2 votes
3 answers
188 views

Table with additional conditions for the generated objects

Suppose that I have a function prob[n_] := Table[Subscript[p, i], {i, 1, n}] that generates tuples with n entries that correspond to probabilities. What I would ...
ConfusedCabbage's user avatar
1 vote
1 answer
80 views

How can I make a map to solve in a list of coefficients of an equation?

I have a list list = {{2, -4, 3, 1, -2}, {2, -3, -4, -1, -2}, {2, -3, 4, -1, -4}} and ...
Laurenso's user avatar
  • 1,032
2 votes
3 answers
180 views

How to express a list of lists of rules as functions?

Given a list of lists of rules as follows: ...
Tugrul Temel's user avatar
  • 6,184
3 votes
2 answers
252 views

How to map an unbalanced list of lists as functions?

Given: Map[f, {{a, f, h, m, n, k},{a, b}, {z, d, f, h, k}, {c, d, e}, {c, p}}] I like to have a list of ordered functions as ...
Tugrul Temel's user avatar
  • 6,184
0 votes
0 answers
51 views

Understanding and Fixing Image Encryption Using Henon Map Resulting in Original Image, Not Encrypted Image

I'm reaching out to this community in my quest to understand and improve an image encryption process using the Henon map. I have created the following Mathematica code to encrypt an image: ...
zeraoulia rafik's user avatar
1 vote
2 answers
51 views

Extracting integers from a Dataset containing variables

I want to extract two vectors DataA = {1,0,0,0} and DataB = {0,2,5,0} from a dataset. I tried a few ways including using the dataset and ...
krygh's user avatar
  • 159
2 votes
1 answer
191 views

Python Code to Mathematica for Classical Map of Kicked Top

I am trying to convert this Python code for Classical map of kicked top to Mathematica. For a single trajectory, I am able to ...
user444's user avatar
  • 2,354
7 votes
13 answers
764 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,313
5 votes
4 answers
331 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.5k
4 votes
2 answers
256 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
  • 69
2 votes
1 answer
182 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
63 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
96 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
  • 813
0 votes
1 answer
56 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
  • 2,084
0 votes
0 answers
48 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
51 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,874
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,874
0 votes
0 answers
38 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,874
5 votes
2 answers
309 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
79 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
613 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
  • 767
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
204 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
  • 524
3 votes
1 answer
68 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,513
2 votes
1 answer
103 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
  • 977
3 votes
1 answer
92 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
91 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
769 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
118 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
193 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
  • 2,084
5 votes
3 answers
143 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
  • 13.7k
4 votes
2 answers
217 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.7k
11 votes
2 answers
471 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
  • 17.1k
2 votes
2 answers
93 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
9 votes
5 answers
556 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.6k
5 votes
2 answers
587 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
696 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
929 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
8 votes
6 answers
682 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
91 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
218 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
143 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
546 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
107 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
  • 259

1
2 3 4 5
9