Skip to main content

Questions tagged [slot]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
4 votes
1 answer
96 views

How to shorten the plotting code using slots and table? [closed]

Background Information I have the following Mathematica code: ...
codebpr's user avatar
  • 2,253
3 votes
2 answers
84 views

Multiple append over a Dataset

I have the following association : ...
Jocelyn Minini's user avatar
0 votes
0 answers
30 views

How to programmatically generate Slot expressions for the function in FormFunction?

I am making a FormFunction expression programmatically, based on external lists of questions and possible answers. Here is a toy example: ...
Gareth Russell's user avatar
0 votes
0 answers
47 views

Trouble using list of slot variables?

When I run this code: ...
Red Banana's user avatar
  • 5,391
1 vote
0 answers
64 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
0 answers
65 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". ...
Indiana's user avatar
  • 331
1 vote
2 answers
87 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},
cybervigilante's user avatar
7 votes
4 answers
345 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 ...
michelangelov's user avatar
3 votes
1 answer
161 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 ...
Meclassic's user avatar
  • 1,015
0 votes
1 answer
128 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 ...
user195583's user avatar
0 votes
1 answer
102 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 : ...
user444's user avatar
  • 2,446
2 votes
1 answer
92 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, ...
Adam's user avatar
  • 3,956
4 votes
1 answer
93 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 ...
Denis Cousineau's user avatar
8 votes
1 answer
314 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.: ...
theorist's user avatar
  • 3,633
0 votes
1 answer
69 views

Slot in the code

I am given the following code in my notes: ...
Jack Jack's user avatar
  • 101
5 votes
2 answers
177 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 ...
imida k's user avatar
  • 4,295
1 vote
1 answer
76 views

Apply function using level

The following use of Level is documented, without any example. Let's try some simple codes : ...
imida k's user avatar
  • 4,295
4 votes
0 answers
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 ...
xiaohuamao's user avatar
  • 4,728
0 votes
0 answers
57 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 ...
Mahdi Razaz's user avatar
2 votes
3 answers
90 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: ...
Aryan's user avatar
  • 339
8 votes
6 answers
399 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 ...
user170231's user avatar
  • 1,611
7 votes
3 answers
512 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 ...
Red Banana's user avatar
  • 5,391
1 vote
0 answers
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, ...
12345's user avatar
  • 199
1 vote
1 answer
127 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 ...
nanjun's user avatar
  • 1,307
0 votes
1 answer
146 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 ...
FRANCESCO's user avatar
5 votes
2 answers
123 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. ...
haith's user avatar
  • 163
1 vote
0 answers
107 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} ] ...
Fortsaint's user avatar
  • 2,060
3 votes
1 answer
155 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 ...
Dark Knight45's user avatar
0 votes
0 answers
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: ...
Jay Schyler Raadt's user avatar
0 votes
1 answer
203 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: ...
Richard Burke-Ward's user avatar
16 votes
1 answer
995 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 ...
dzejkob's user avatar
  • 501
0 votes
1 answer
91 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 ...
BlueMan's user avatar
4 votes
2 answers
362 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 ...
Mitchell Kaplan's user avatar
4 votes
1 answer
70 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 ...
Liuba Orlova's user avatar
0 votes
2 answers
315 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 ...
Hauke Reddmann's user avatar
9 votes
2 answers
301 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 ...
user avatar
3 votes
2 answers
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 ...
Mitchell Kaplan's user avatar
3 votes
0 answers
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 ...
alancalvitti's user avatar
  • 15.1k
2 votes
2 answers
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 ...
Amir Jalali's user avatar
0 votes
0 answers
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 <...
Robin_Lyn's user avatar
  • 355
4 votes
0 answers
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 ...
JungHwan Min's user avatar
  • 4,674
0 votes
0 answers
210 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 ...
Satoshi Oota's user avatar
1 vote
0 answers
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 ...
CoryG's user avatar
  • 111
0 votes
0 answers
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 ...
Zero's user avatar
  • 303
0 votes
1 answer
128 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 ...
amasics's user avatar
  • 249
3 votes
2 answers
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 ...
user85503's user avatar
  • 992
1 vote
0 answers
99 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 ...
Ουιλιαμ Αρκευα's user avatar
1 vote
1 answer
157 views

Explanation required for the Slot function

I have been trying to understand the following function ...
no-one's user avatar
  • 1,243
0 votes
0 answers
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: ...
Simon's user avatar
  • 503
7 votes
1 answer
230 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: ...
akrodha's user avatar
  • 71