Linked Questions

11 votes
3 answers

Functions with both optional arguments and options [duplicate]

I have the following codes: ...
Physicist's user avatar
  • 987
4 votes
2 answers

How to prevent an Optional parameter from taking an OptionsPattern parameter without multiple function definitions? [duplicate]

I have function the needs to enable some Optional parameters and an OptionsPattern. The issue I am facing is that the options ...
Edmund's user avatar
  • 42.4k
2 votes
1 answer

Issue using optional argument before options [duplicate]

I have a problem using optional arguments before an OptionsPattern: ...
M.R.'s user avatar
  • 31.6k
602 votes
19 answers

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 ...
84 votes
4 answers

Using a PatternTest versus a Condition for pattern matching

My last question to the site resulted in several answers that involve using pattern matching in Mathematica, a feature I wasn't very familiar with at the time. I am currently reading Mathematica ...
Alfred Fazio's user avatar
  • 1,175
45 votes
4 answers

Can a function be made to accept a variable amount of inputs?

I have a function that takes two inputs and processes them for a single output. What I need is one that can take a varying number of inputs. and process them to a single output. Is this possible in ...
Nothingtoseehere's user avatar
29 votes
1 answer

Why doesn't PatternTest work with Composition?

While playing around with the solutions to this question, I've found some very strange behaviour: ...
celtschk's user avatar
  • 19.1k
12 votes
4 answers

Is it possible to separately call the default value of a variable which isn't at the end of the sequence?

After reading this post I recalled an old question I once met. We know that we can set default values for variables of a function: ...
xzczd's user avatar
  • 66.9k
10 votes
1 answer

define a function with optional arguments

I have defined a function as follows: ...
Dimitris's user avatar
  • 4,824
8 votes
2 answers

Weird behavior of conditions when using OptionsPattern and OptionValue

I'm trying to define a function that is evaluated differently depending on its options. This code ...
vsht's user avatar
  • 3,527
7 votes
2 answers

How to translate and scale an image via ImageTransformation

Is there a way to translate and scale a 2D image simply by using ImageTransformation[] and TransformationFunction[]? I know how ...
David Roberts's user avatar
8 votes
1 answer

Attributes with Pattern test

Probably this question has no application but it helps understand basic issues about Attributes and functions. I was writing a piece of code where I accidently ...
Basheer Algohi's user avatar
9 votes
1 answer

How can a function know in which function it was evaluated?

Hello my second question here might be very hard. I am asking for something "magical", if i define a function g and i call it inside a function f, how can g have information about the outer function ...
sacratus's user avatar
  • 1,566
11 votes
1 answer

Except @ OptionsPattern[] affects OptionValue

The background This example works as expected, small function with a special case rule: ...
Kuba's user avatar
  • 137k
12 votes
1 answer

Practice notebook for Pure Functions & Rules-Patterns

Are there practice notebooks or exercises for practising using pure functions and rule-patterns? I've completed "An Elementary Introduction to the Wolfram Language" and "Fast Introduction for ...
I should change my Username's user avatar

15 30 50 per page