# Questions tagged [slot]

The tag has no usage guidance.

55 questions
Filter by
Sorted by
Tagged with
46 views

### Trouble using list of slot variables?

When I run this code: ...
• 5,121
1 vote
62 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 ...
• 2,615
61 views

### Is there a way to refer to the value of another key in the same association?

I have an association like below and want to know how to properly phrase the value for winner. in this example, the answer should be "a". ...
• 331
1 vote
77 views

### Table doesn't work with Slot [closed]

Using Mathematica, I was trying to get {#1,#2,#3,#4,#5}, using Table[#n, {n, 1, 5}] Instead I only got {#n, #n, #n, #n, #n} How can I get {#1,#2,#3,#4,#5},
307 views

### Apply pattern using a Slot (#) to each list element using a second slot

I am trying to find a neat way of applying an operation to each list element, but do not know how to properly use multiple slots or whether it is actually possible to solve this with multiple slots. I ...
155 views

### How to replace a multiple iterator Table to speed up computation

I need to create an array of data which resembles to something like this Table[{i, Sin[j^2*i]}, {j, 2000}, {i, 0., Pi, Pi/10000.}] where each "row" of ...
• 953
110 views

### Defining a general function f with slot-holder arguments #1, #2

I am trying to get a general function $f$ accept slot-holder arguments #1, #2, where the actual arguments are lists {a1, a2,...} and {b1, b2,....}. I thought that this would involve some combination ...
• 309
96 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 : ...
• 1,554
91 views

### Activating part without resolving [[1]]

I'll try to make this question more clear in a little while. In the mean time, I'll ask directly the question which motivated it: Latin Square from submatrix Original Question I want, for instance, ...
• 3,897
90 views

### Defnining a function with a parameter which is not a slot but a constant [closed]

One convenient way to define a function is f[S,x_]:= 3 f[G,x_]:= 7 where the first parameter is not a slot but a constant. This way of constructing functions is ...
• 1,099
313 views

### How to supply argument to pure function when slot is already defined?

Here's an example of a pure function: 3^# > 100 & I can supply any value I please to the function, by placing that value after the prefix. E.g.: ...
• 3,603
62 views

### Slot in the code

I am given the following code in my notes: ...
• 101
165 views

### bind specific 'Slots' to specific 'Map'

Is it possible to construct a pure function using multiple slots, with the following concept :       Binding   specific slot    to    specific apply or map For example : In this example, To ...
• 4,047
1 vote
66 views

### Apply function using level

The following use of Level is documented, without any example. Let's try some simple codes : ...
• 4,047
68 views

### Cannot access ColorFunction in ListVectorDensityPlot

Working on a vector field, I'd like to use a ColorFunction dependent on both the vector direction and its norm. According to the documentation of ...
• 4,698
56 views

### Using slot and application to variable length vector

I have a list of 2D coordinates with a maximum length of 3, e.g. peakdatAB {{1007.81, 8.64842}, {1008.38, 8.19264}} I need to generate something like this ...
• 337
89 views

### Multiple Calculations in a condition

I want to add and subtract 3 from a list. pos = {82,84} If[# > 3, (# - 3) && (# + 3)] & /@ pos the output I want: ...
• 339
367 views

### When applying (@@) a function to a list of potential arguments, how can Slot be used to take the last argument?

I wouldn't be surprised if the title question is confusing, so I'll try to elaborate by way of example. Consider the list ...
• 1,581
487 views

### What is the difference between a variable and a "slot variable"?

Investigating Function[] , I found: What is the difference between using a variable (in the case, $u$) and a "slot variable"? It seems anything can be done ...
• 5,121
1 vote
83 views

### Slot numbers, pure functions [closed]

For the first line of code my function works fine on the list, but when trying to use Map I just keep getting an error (Function::slotn) basically saying there are not enough arguments for it to work, ...
• 199
1 vote
124 views

### Using # and ## in same statement to represent different levels

I am trying to write some codes to judge if each row of a matrix contains any negative numbers. For example mat = {{1, 2, 3}, {-1, 2, 3}, {0, 2, 3}}, and ...
• 1,297
145 views

### What is the first slot value in this expression?

I would like to know what is the first slot value in the following expression ...
119 views

### Using the Range function with the Slot (#) function

I am writing a code to display longitudinal waves. I started with the following, filling the slots using the Range function. ...
• 163
1 vote
105 views

### Is there a good reason why Slot[] is not an atomic expression?

Here's a good reason why I think it should be, Map[ If[AtomQ@#, #->"is an atom", #->"not an atom"]& , {"hello",Range@3, # &} , {-1} ] ...
• 2,040
148 views

### Help me with understanding root objects [duplicate]

I solved an polynomial equation of degree 20 and got root objects as solutions. I cannot understand how to match such output to any standard analytic form. After studying ...
36 views

### Translate Mathematica Output to Latex type font [duplicate]

In solving the inequality $2d^2\ge -(2(1+d)+\frac{4d^3}{1-d})(d-1)$, Mathematica returns something using Slots and Functions: ...
201 views

### Convert a piecewise definition of a single impulse into an impulse train

NOTE: See update at end of question I have a function smoothstep (based on the derivative of a smoothstep function) that gives a single impulse as follows: ...
• 2,141
973 views

### Meaning of ## #

While looking for an answer to a different problem, I came across the following example: In[1]:= Array[Plus[##] &, {2,2}] Out[1]= {{2,3},{3,4}} Having read ...
• 501
90 views

### How I can get only second part of relation?

How I can get only the second part of this relation? I want to get Image of function where R is a relation and ...
361 views

### Drop 1st element of {#a, #b, #c} &

I pass the following to a function: {#a, #b, #c} & These are keys that are used in a list of associations. There are instances where I want to pass only the ...
• 3,676
68 views

### Combination of Scan[] and MapIndexed[]. Using an expression with slots corresponding to different functions [duplicate]

If I want to use slots corresponding to different function, how can I dod that. For example: Scan[MapIndexed[(#1+#2)*#3&,{"a","b","c"}],Range[5]] where I ...
• 101
308 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 ...
• 1,011
297 views

### Applying Function with SlotSequence and Lists

I would like to apply a function to a list of lists, while using each of the 2 elements of the list in a SlotSequence in two different places in the function. What I am working with is ...
1k views

### explanation of #1 and #2 [duplicate]

EDIT: This was marked as a possible duplicate. While the referenced other question does talk about slots, my question is more about how to understand how multiple slots (#1 and #2) work. Also, my ...
• 3,676
45 views

### Missing values vanish from expressions with DateObject and slot-lookup?

Missing value vanishes when adding or subtracting DateObject but only when slot-lookup is used, in an Association query: Given ...
• 15.1k
135 views

### slot assignment to a local variable

Let me start with an example: data = Partition[RandomInteger[50, 40], 3]; s = {10, 50}; I'd like to choose the first element of each sublist subject to the ...
49 views

### Pure function slot delivery [duplicate]

Another novice problem encountered. I am going to need a cardiology surgery. :( For a simple example, a = #1 &; b = #2 &; f = a^2 + b^2; f results in <...
• 355
53 views

### Bug with LinearRecurrence and Slot/SlotSequence?

The code below runs without any error: LinearRecurrence[{##}, {1}, 5] Each term is the previous term squared, times the index of the previous term. If the ...
• 4,644
206 views

### The order of evaluations with nested slots [duplicate]

I tried to join a series of evaluations with nested slots as follows: #^2 & /@ #^2 & /@ Range[10] However, the results were somewhat different from what ...
• 341
1 vote
123 views

### What Does Slot Mean In Root Output and How To Translate It To Code? [duplicate]

I have the notebook below which produces the correct numerical output but the CForm function doesn't appear as though it is working correctly (or I don't know how ...
• 111
35 views

### Understanding solution with slots [duplicate]

I am trying to find eigenvalues of a matrix. It has two symbols $k_1$ and $k_2$. I get this solution from mathematica Reading the doucmentation, I know # is a placeholder, much like an input to an ...
• 303
127 views

### How to generate a series of iterable slots in a template notebook?

How can I generate a seires of iterable slots in template notebook I can later loop over and assign values to? For example: I could generate this manually by typing out each one. However, it gets ...
• 249
299 views

### Application of # for the $n^{th}$ derivative

Let's say that I have x^2+x Is there a way to map $x$ to the first derivative of a function and $x^2$ to the second derivative of the same function? According to ...
• 992
1 vote
97 views

### Applying slots, one after another for a list [closed]

For this function: Fun[x_] := 3 x^3 + 4 x^2 - 2 x - 1 I apply Map: D[Fun[x], {x, #}] & /@ Range@3 and I get this ...
1 vote
156 views

### Explanation required for the Slot function

I have been trying to understand the following function ...
• 1,243
28 views

### Slot representing the key in Association? [duplicate]

Is there a slot representation of the Key in an Association? For instance, I would like to do same transformation with an Association: ...
• 493
228 views

### Writing code which generates a function to append many columns to a dataset

I love datasets in Mathematica. Say I have one that looks like this: ...
• 71
206 views

### Generating a function with named slots

Say I have an association: a = <|"a" -> "albatross", "b" -> "barbecue", "c" -> "champagne"|> And say I want a function with named slots to ...
• 71
421 views

### Query datasets with "variable" named slots

I want to query a Dataset object, e.g. select some entries using ...
• 599