Linked Questions

7 votes
4 answers

Why does my function defined with constraints on patterns not work? [duplicate]

Possible Duplicate: Why doesn't PatternTest work with Composition? My function is something like this, ...
yulinlinyu's user avatar
  • 4,825
3 votes
2 answers

How to apply multiple/complicated requirements for a pattern in a function input [duplicate]

In this question. I suggested that to test whether the input of a function was a matrix of numbers one could create the following test: ...
Jonathan Shock's user avatar
3 votes
1 answer

Why does GreaterThan with pattern test not work [duplicate]

I'm stuck in a seemingly easy question, but I can't figure out why the GreaterThan function and the pattern test do not work. I have tried to debug it for a while, ...
Eric's user avatar
  • 1,191
1 vote
2 answers

A function that only evaluates on lists of pairs [duplicate]

Possible Duplicate: Why doesn’t PatternTest work with Composition? I'd like my function to only evaluate when the argument is a list of pairs. It seems like ...
ArgentoSapiens's user avatar
0 votes
0 answers

Question regarding function definition overloading / argument passing test [duplicate]

It is possible to define function dependently to passed argument type or condition this argument fulfills (somewhat like overloading): ...
Misery's user avatar
  • 2,650
1 vote
0 answers

Behaviour of PatternTest [duplicate]

I was surprised by the following behavior of PatternTest and I think that this may be instructive for other people too. Consider ...
Daniel Huber's user avatar
  • 52.6k
2 votes
0 answers

VertexShapeFunction with string pattern matching [duplicate]

I am trying to visualize a heterogeneous graph which nodes are categorical. Here is a dummy graph for implementation: Input is ...
Wenzhen's user avatar
  • 141
75 votes
7 answers

How to avoid collision between optional arguments and options?

Is it possible to create a function with optional arguments that also takes options? Here is a simple example. I have a function f with option "g". It also has ...
Andy Ross's user avatar
  • 19.3k
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
40 votes
5 answers

How to examine the structure of Graphics objects

One difficulty I'm encountering in studying the structure of Graphics objects is that I have not yet found a way to print or display such structures that are ...
kjo's user avatar
  • 11.7k
30 votes
3 answers

Parentheses in pure functions: # & vs. ( # &)

I've been using Mathematica for years, and over time I have developed the habit of using: Select[data, (# == 1 &)] instead of ...
Eric Brown's user avatar
  • 4,426
30 votes
5 answers

Unexpected behaviors in built-in functions

Existence of this topic is discussed in this mathematica.meta post. I'm sure I am not the only non-beginner in WL who from time to time finds themselves not being able to predict an outcome of a ...
21 votes
4 answers

Replace custom functions, leave built in functions untouched?

I have three expressions a[x, y], b[x, y], c[x, y] that act as placeholders for functions of two variables x,y. Consider the ...
Kagaratsch's user avatar
9 votes
3 answers

Metaquestion: how to find out why (e.g.) MatchQ[42, _?Function[x, True]] is False?

Suppose you run into a bewildering Mathematica result (which happens to me several times per Mathematica session, even after a 20-year acquaintance), such as, for example: ...
kjo's user avatar
  • 11.7k
4 votes
2 answers

Why can't NumberQ be used as the head of a pattern?

Consider the following: list={1/First[{}], 1, 2, 1/First[{}], 3}; DeleteCases[list,_NumberQ] I wanted to remove all cases, which did not match ...
John's user avatar
  • 4,361

15 30 50 per page