78 views

### The difference between ? and /; [duplicate]

I can do the following Cases[Range@10, x_ /; OddQ[x]] But why cannot I do x_?OddQ[x] instead of ...
1k views

### Quick way to use conditioned patterns when defining multi-argument function?

I have a simple function that is supposed to only accept numeric values (i.e. complex/real numbers and constant symbols e.g. Pi, E). $$f(a,b,c)=a+b+c$$ Edit: I should have chosen a less simple ...
167 views

### Weird behaviour of HoldPattern

I'm still thinking about how to implement Condition with anonymous patterns. And now I think I've found a way to implement it, but again, a suspected unclear ...
3k views

### Implement the Bisection algorithm elegantly and easily

Description: Rencently, I have finished my course Numerical Analysis, so I'd like to implement many algorithm that I have learned from that course.By this practice, I hope that I can improve my ...
68 views

### Condition in a replacing function [duplicate]

Because of "Thou shalt not copypaste", I'd like to change my pair of replacements F[foo_,foo_+1]:=bar;F[foo_,foo_-1]:=bar; (it's MUCH longer, so it actually ...
77 views

### How to use Strings and Functions With Conditions

Very new to Mathematica so this might be really simple. I have the function pow[x_,r_]:= x^r where r is rational due to ...
4k views

### How to restrict the domain of a function

I realize this question has been asked many times, but I am fairly new at Mathematica and the other answers are very complex, and certainly too complicated for this simple code I am trying to write. ...
144k views

### 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 ...
6k views

### 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 ...
950 views

### Assessing argument type in set delayed function definitions

I'm wondering how to properly assess the type of arguments passed to functions defined with :=. I want my functions to be the most efficient, unambiguous and clear ...
3k views

### Match patterns on list of Strings

Consider the following: data={"AB","CD","AF"}; Now I would like to delete all String from data which starts with "A". Result:...
233 views

### Why the pattern match don't work as expected

When I try to figure out this problem,I write such code: ...
275 views

### Why is there a difference when formulating patterns for Select and FirstPosition?

Select[{1, 2, 4, 7, 6, 2}, # > 2 &] Gives {4, 7, 6}. OK! So one should think that the following would work: ...