Skip to main content
18 votes
Accepted

How can I view the minimal required arguments of a Wolfram Language function?

You can use SyntaxInformation: SyntaxInformation /@ {Sin, Replace} // Column
kglr's user avatar
  • 399k
17 votes
Accepted

Define function that behaves almost identically to Mathematica function

If you want to constrain it to only options from ListPlot, you could use OptionsPattern in combination with ...
chuy's user avatar
  • 11.2k
16 votes

How to define a function reminding of names of the independent variables?

You can get the behavior you ask for if you define your function to work with an association. The key-value paradigm provides syntax close but not exactly as you describe. Simple approach ...
m_goldberg's user avatar
  • 108k
14 votes
Accepted

How to pass arguments to the list of functions?

f[x_, y_] = x + y; g[x_, y_] = x^3 + y^2 + 2 x; functions = {f, g}; Using Map ...
Bob Hanlon's user avatar
  • 161k
14 votes
Accepted

Map a two argument function to every element on list

Since you're looking to learn more about functional style, I'll elaborate rather than just provide an answer. We start with our table: ...
lericr's user avatar
  • 31.7k
12 votes
Accepted

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

If you don't want to follow some suggestions made in comments and use the Function with named arguments (and there may be valid reasons to be willing to avoid that),...
Leonid Shifrin's user avatar
11 votes

How to define a function reminding of names of the independent variables?

If this is just to help entering values in the correct order (and not to be permanently visible), you can possibly use a Placeholder. Reevaluating ...
Jean-Pierre's user avatar
  • 5,222
9 votes

Define function that behaves almost identically to Mathematica function

The usual way to define a Wolfram Language function that takes n arguments and an arbitrary number of options is like this: ...
rafalc's user avatar
  • 1,369
9 votes
Accepted

Make a function work by the keyword instead of argument position while evaluating

It is possible to do with Options: ...
I.M.'s user avatar
  • 3,116
7 votes
Accepted

Testing if list elements are numerical

TestFun[listArg_?(VectorQ[#, NumericQ] &)] := Sum[listArg[[k]], {k, 1, m}] TestFun2[{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}] 55 or ...
kglr's user avatar
  • 399k
6 votes

Mapping between lists and Mapping Formats

Partition[connectionsOrder, 2, 1, {1, -1}, {}, Rule] ...
kglr's user avatar
  • 399k
6 votes
Accepted

What Does this Syntax Mean in Ouput from DSolve?

$c_1$ is a function that takes $x$ and $\frac{1}{2}(y^2+z^2)$ as its arguments. I do not know why it shows it this way. In Maple, same solution is shown as $f \left(x , y , z\right) = F1 \left(x , y^{...
Nasser's user avatar
  • 149k
6 votes
Accepted

Define a function with sparsearray

I corrected some of the syntax issues in your code. While this can likely be improved, I think it is beneficial to see what precisely can be changed to make your code able to run. Please find it below,...
CA Trevillian's user avatar
6 votes

Collect the coefficients through the Cos argument

One way, assuming expr is a linear combination of cosines: ...
Michael E2's user avatar
  • 241k
5 votes

How do I pass a "list of lists" as the argument to a function of the form F[x,y]?

Apply at Level 1: F @@@ list {F[a1, b1], F[a2, b2], F[a3, b3], F[an, bn]}
kglr's user avatar
  • 399k
5 votes

How to make functional rules not depend on an argument?

It's just like defining a function. Make x the name of a pattern, not a literal symbol: ...
John Doty's user avatar
  • 13.9k
5 votes

Keep irrelevant variables outside function arguments

Clear["Global`*"] f1[x_, y_ : y] := x^2 + y f2[x_, y_ : y] := (1 + x) f1[x, y] f3[x_, y_ : y] := Derivative[1, 0][f1][x, y] + f2[x + 1, y] In each case, ...
Bob Hanlon's user avatar
  • 161k
5 votes
Accepted

Mapping between lists and Mapping Formats

BlockMap can do more of the work than you are allowing it to: BlockMap[Apply[Rule], connectionsOrder, 2, 1] ...
Mr.Wizard's user avatar
  • 273k
5 votes
Accepted

What is the usefulness of adding a colon ":" to arguments in the declaration of a function?

It is useful when your pattern does not start with _. Suppose your pattern is a list of integers, ...
Jason B.'s user avatar
  • 69.7k
5 votes

Map a two argument function to every element on list

One way would be to use Inner: ...
user1066's user avatar
  • 21k
4 votes
Accepted

How can I fix my Simpson's rule integration code?

I can recommend more practical for numerical calculations next definition: ...
Alex Trounev's user avatar
  • 47.8k
4 votes
Accepted

Defining function with arguments in a specific pattern similar to Graphics[]

ClearAll[f1, f2] f1[gr_, clr_] := Graphics@Style[gr, clr] f2[args : __, opts : OptionsPattern[Show]] := Show[f1 @@@ Partition[{args}, 2], opts] Example: ...
kglr's user avatar
  • 399k
4 votes

Make a function work by the keyword instead of argument position while evaluating

You could use associations as follows: f[in_:<||>]:=With[{m=Merge[{in,<|a->1,b->2,c->3|>},First]}, m[a]+m[b]+m[c] ]; Examples: ...
user293787's user avatar
  • 11.9k
4 votes
Accepted

Expression as parameter to function that evaluates it, best way to do it?

...
xzczd's user avatar
  • 67.7k
3 votes
Accepted

How to represent functions values Table in a form of columns with arguments and values?

You can use TableForm: ...
kglr's user avatar
  • 399k
3 votes

Pass arguments to a function within a function within a function

Perhaps you can use ParametricNDSolveValue instead. For your example: ...
Carl Woll's user avatar
  • 131k
3 votes

How can I fix my Simpson's rule integration code?

The function MyPlot, which is the model for your implementation, is specialized to a certain argument pattern and won't evaluate when given ...
m_goldberg's user avatar
  • 108k
3 votes
Accepted

How to extract arguments of color spaces and determine brightness of said colors?

RGBColor and GrayLevel are just semantic wrappers. FullForm[Orange] RGBColor[1,0.5,0] ...
lericr's user avatar
  • 31.7k
3 votes

How to extract arguments of color spaces and determine brightness of said colors?

You might try working in the hue, saturation, and brightness color space for this. Suppose I have a RGB color with red value 0.1, green value 0.8 and blue value 0.7 ...
Rudy Potter's user avatar
  • 2,590
3 votes
Accepted

How to modify the argument of a specific function below?

I don't think it's a good idea to set variables in the way you're doing it. Passing variables "by reference" is an idea that comes from other programming languages (C and C++, for example). ...
Roman's user avatar
  • 49.3k

Only top scored, non community-wiki answers of a minimum length are eligible