You may be remembering a way that I sometimes write function definitions or replacement rules using what I call vanishing patterns, using Alternatives (short form |). Some examples:
This technique can considerably condense some code, but at the expense of clarity for those not familiar with it, and often a slight decrease in performance. I do not see any (simple) way to apply it to the example in the question, and shoehorning the method into code where it does not naturally fit (for one accustomed to it) surely hurts clarity and should be avoided outside of "code golf" games.
To provide a simple example of the method where I believe it does fit consider:
f[a_Real, x_] := x*a
f[b_Integer, x_] := x^b
This could instead be written:
f[a_Real | b_Integer, x_] := (x*a)^b
Whichever pattern (a_Real or b_Integer) does not match is left out of the right-hand-side, and because of the single-argument behavior of Times and Power this is handled correctly.
Another place the method works very well is inserting elements into an expression at specific places based on pattern. For example, suppose you want an function than takes a list and an integer, and appends the integer if it is odd and "prepends" the integer if it is even. This can be written cleanly as:
g[{x___}, e_?EvenQ | o_?OddQ] := {e, x, o}
Test:
Fold[g, {}, Range@10]
{10, 8, 6, 4, 2, 1, 3, 5, 7, 9}
More simply you can use Alternatives to match different input forms, e.g.:
Condition? (look it up in the docs) – Szabolcs Mar 15 '14 at 14:00Alternativesin the top-level function definitions is not allowed. – Leonid Shifrin Mar 15 '14 at 14:01f[1, x_] | f[3, x_] := x^2is not allowed, butf[1 | 3, x_] := x^2is allowed. (It's not clear to me which the OP is trying to recall, if either.) – Michael E2 Mar 15 '14 at 14:23Alternativesto work. I don't know what was the rationale behind this limitation / design decision, but probably there was some good reason for this. – Leonid Shifrin Mar 15 '14 at 14:42f[PatternSequence[1, x_] | PatternSequence[3, x_]] := x^2? – Michael E2 Mar 15 '14 at 15:07f[x_]|g[x_]:=...- this I anticipated before. But this does not explain why not to make an exception for things likef[patt1]|f[patt2]:=.... – Leonid Shifrin Mar 15 '14 at 15:11f[1,x_]|f[2,x_]:=x^2. – Leonid Shifrin Mar 15 '14 at 15:11PatternSequencemethod suit some cases for you. But I think we may be drifting away from the present question? – Michael E2 Mar 15 '14 at 15:13PatternSequencedoes cover some cases, but not all. I don't remember now whether those needs I had in the past would've been satisfied withPatternSequence. Re: drifting - I guess so... – Leonid Shifrin Mar 15 '14 at 15:19