Linked Questions
12 questions linked to/from Is there a faster way to Map an Association?
608 votes
19 answers
161k views
Where can I find examples of good Mathematica programming practice?
I consider myself a pretty good Mathematica programmer, but I'm always looking out for ways to either improve my way of doing things in Mathematica, or to see if there's something nifty that I haven't ...
20 votes
4 answers
3k views
Fastest way to check for list membership
I have a set of say 100 numbers {1,3,7,11,19,...3971}. All elements are previously determined. I want to check whether ...
16 votes
3 answers
9k views
Assigning values to a list of variable names
As part of a calculation I need to do something like this Evaluate[{aaa, bbb, ccc}[[ index]]] = {1, 2, 3, 4, 5} so if index is ...
20 votes
5 answers
766 views
Is there a faster way to create a matrix of indices from ragged data?
I have data that is given as a list of ordered pairs mixed with scalars. The pairs can contain infinite bounds. My goal is to convert the data into an index used in future computations. ...
16 votes
4 answers
740 views
ReplaceAll with Associations instead of Rules
I have just noticed that x /. <|x -> 123|> evaluates to 123 In other words, the association seems to behave as a ...
9 votes
6 answers
443 views
Is there a better way to add a "key" for the list of GatherBy?
In ruby , 1.upto(10).to_a.group_by{|x| x%3} gives {1=>[1, 4, 7, 10], 2=>[2, 5, 8], 0=>[3, 6, 9]} I would like use ...
5 votes
2 answers
385 views
ParallelMemberQ
I tried to make a parallel version of MemberQ for use with a large list, but failed miserably in terms of performance. I used Partition to subdivide the list and ParallelMap to perform the MemberQ ...
9 votes
1 answer
420 views
Why is `Block` significantly faster than `ReplaceAll` for inputting variable values
Given that the documentation for FindMinimum uses ReplaceAll for its various examples of what to do with the found solution to ...
-1 votes
4 answers
279 views
Partitioning lists by length of sublists
Suppose we have the following list data = {{1, 2, 3}, {4, 3, 2, 1, 0}, {6, 7, 8}, {-5, -4, -3, -2, -1}, {-2, -3, -4}, {1, 1, 1, 1, 1}} As we can see, ...
3 votes
3 answers
2k views
Use map on a different level
I have just started to get used to Mathematica's Map, Apply, and related functions, and I can't figure out how to do maps that require working "one level down". For example, I am currently trying to ...
3 votes
3 answers
277 views
Replace For with If in Mathematica way
I have this code: ...
6 votes
1 answer
331 views
Force Dispatch to generate dispatch tables
Dispatch creates hash tables only for lists of length larger than 3. Is there any way to force MMA to create hash tables even for lists of length smaller than 4? ...