Linked Questions

14
votes
5answers
416 views

Apply multiple functions to parts of a nested list [duplicate]

data = {{1, a, x, "one"}, {2, b, y, "two"}, {3, c, z, "three"}} I want to apply a list of four functions {f, g, h, m} one ...
5
votes
2answers
122 views

Matching each function to each element [duplicate]

Assume that you have two lists of the same size where 1st contains functions for ex. {u,i,o,p} 2nd contains numbers for ex. ...
2
votes
0answers
313 views

Produce {f[x],g[y],h[z]} in as many ways as possible [duplicate]

I have two lists of equal lengths but for my task I will use 3-element lists , namely {x,y,z} and {f,g,h}. The first contains ...
525
votes
19answers
130k 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 ...
38
votes
12answers
3k views

Map a function across a list conditionally

It seems that this is a really basic question, and I feel that the answer should be obvious to me. However, I am not seeing. Can you please help me? Thanks. Suppose I have a list of data ...
22
votes
6answers
3k views

Apply multiple functions to same list

I'd like to get the Min, Max, Median, Mean, etc. for the same list. For now I'm doing the following: ...
16
votes
10answers
742 views

Distributing elements across a list of lists

I have two lists: u = {{1, 3}, {2, 6}, {3, 9}} v = {0, 4} and I want to obtain this list from them: ...
10
votes
6answers
657 views

Join a list with {6, 6, 2} dimensions with a list {6, 6} dimensions

...
11
votes
5answers
756 views

How to sort list of mixed types of elements with each type a specified canonical order?

For example, here is a list {{1, "u"}, {6, "d"}, {3, "u"}, {4, "d"}, {2, "u"}, {5, "u"}, {3, "d"}, {1, "d"}, {4, "u"}, {2, "d"}, {5, "d"}, {6, "u"}} The ...
5
votes
3answers
326 views

Command to insert item into list

Is there a command to insert an item into a list such that they form pairs? In other words to take InsertObject[{a,b,c},d] which will output ...
6
votes
4answers
216 views

Elegant way for element-wise application of a list of functions

For given functions $f,g,\cdots$ I want to define a pure function that, when applied to any list $\{x,y,\cdots\}$ (of the same length as $\{f,g,\cdots\}$), produces $\{f[x],g[y],\cdots\}$. Two ways to ...
7
votes
2answers
189 views

Is there a built-in function to map a list of heads to a list of data?

Assume that this built-in function is called func. What I want is func[{f,g},{a,b,c}] will return the following result: <...
3
votes
3answers
141 views

Using Through on functions that take multiple arguments

I want simple syntax that results in this: {{f[1, 2], g[1, 2]}, {f[3, 4], g[3, 4]}} though I'm willing to settle for: ...
4
votes
2answers
137 views

How to apply a function to an expression? [duplicate]

What is the name for the function #1[#2]&? I would call it Apply, so that Apply[Sin,2] ...
3
votes
1answer
78 views

Best way to apply a list of functions to a list of values?

This question is closely related to questions 83720, 17460, and 11298. How would you write the operator F = Through[#1[#2]] & in the prettiest, fastest, or ...

15 30 50 per page