New answers tagged pattern-matching
3
votes
Terms of expressions with non-commutative multiplication that meet the given criteria
I am assuming that out was missing a closing bracket and should look like the following:
...
19
votes
How can a verbal reasoning question be solved with Mathematica?
Riffing off of DanielHuber's answer, and with less user intervention:
...
11
votes
Accepted
How can a verbal reasoning question be solved with Mathematica?
To look for a pattern,we get the character codes:
cc= ToCharacterCode["KDXPNGVNQJTLTM"]
(* {75, 68, 88, 80, 78, 71, 86, 78, 81, 74, 84, 76, 84, 77} *)
...
4
votes
Deleting sublists where an element repeats beyond a repetition threshold
part[m_, n_] := DeleteCases[
IntegerPartitions[m], _?(Max[Tally[#][[All, 2]]] > n &)]
part[37, 2]
{{37}, {36, 1}, {35, 2}, {35, 1, 1}, {34, 3}, {34, 2, ...
5
votes
Accepted
Deleting sublists where an element repeats beyond a repetition threshold
ClearAll[f]
f[m_, n_] := Select[LessEqualThan[1 + n] @* Max @* Counts] @*
Map[Apply[Sequence] @* IntegerPartitions] @* Range @ m;
Examples:
...
4
votes
Deleting sublists where an element repeats beyond a repetition threshold
SeedRandom[1];
n = 2;
plist = RandomSample[IntegerPartitions[37, {6, 7}], 200];
The list is still too large; let's reduce it to 20 entries for better visualization....
6
votes
StringReplace question from "An Elementary Introduction to the Wolfram Language"
Decompose the problem. For example, "Make any 2-letter word uppercase" is a problem that you can probably solve (hint, there is a built in function for that).
Now move on to "Make any 2-...
2
votes
Accepted
3
votes
Accepted
How to make a pattern that matches only when one of the argument's Head is a Plus?
I think that there is some ambiguity in your description, so this probably needs some tweaking, but here goes...
...
5
votes
Accepted
Replacement, PatternTest, Module related Question
The reason your attempt fails is that at the time the Function is applied to its arguments, m has not yet been replaced by ...
3
votes
Accepted
1
vote
2
votes
7
votes
Accepted
Finding words that start and end with same letter
Since you said that the start/end character was specified, you could do this:
StringBookendedQ[char_] := StringMatchQ[char ~~ ___ ~~ char]
and then this:
...
6
votes
Finding words that start and end with same letter
Consider:
AbsoluteTiming[
res = Pick[WordList[], StringMatchQ[WordList[], x_ ~~ ___ ~~ x_]];
]
(* {0.040667, Null} *)
...
3
votes
2
votes
Top 50 recent answers are included
Related Tags
pattern-matching × 1339list-manipulation × 238
replacement × 195
string-manipulation × 159
function-construction × 100
filtering × 65
functions × 59
argument-patterns × 57
rule × 49
expression-manipulation × 42
evaluation × 38
performance-tuning × 33
bugs × 33
core-language × 33
programming × 32
symbolic × 32
simplifying-expressions × 28
associations × 27
hold × 22
sequence × 21
regular-expressions × 21
attributes × 20
expression-test × 19
optional-arguments × 19
calculus-and-analysis × 18