@@ -327,9 +327,6 @@ class ReplaceAll(BinaryOperator):
327
327
>> ReplaceAll[{a -> 1}][{a, b}]
328
328
= {1, b}
329
329
330
- #> a + b /. x_ + y_ -> {x, y}
331
- = {a, b}
332
-
333
330
ReplaceAll replaces the shallowest levels first:
334
331
>> ReplaceAll[x[1], {x[1] -> y, 1 -> 2}]
335
332
= y
@@ -761,9 +758,6 @@ class Alternatives(BinaryOperator, PatternObject):
761
758
Alternatives can also be used for string expressions
762
759
>> StringReplace["0123 3210", "1" | "2" -> "X"]
763
760
= 0XX3 3XX0
764
-
765
- #> StringReplace["h1d9a f483", DigitCharacter | WhitespaceCharacter -> ""]
766
- = hdaf
767
761
"""
768
762
769
763
arg_counts = None
@@ -829,9 +823,6 @@ class Except(PatternObject):
829
823
Except can also be used for string expressions:
830
824
>> StringReplace["Hello world!", Except[LetterCharacter] -> ""]
831
825
= Helloworld
832
-
833
- #> StringReplace["abc DEF 123!", Except[LetterCharacter, WordCharacter] -> "0"]
834
- = abc DEF 000!
835
826
"""
836
827
837
828
arg_counts = [1 , 2 ]
@@ -1091,15 +1082,6 @@ class Optional(BinaryOperator, PatternObject):
1091
1082
>> Default[h, k_] := k
1092
1083
>> h[a] /. h[x_, y_.] -> {x, y}
1093
1084
= {a, 2}
1094
-
1095
- #> a:b:c
1096
- = a : b : c
1097
- #> FullForm[a:b:c]
1098
- = Optional[Pattern[a, b], c]
1099
- #> (a:b):c
1100
- = a : b : c
1101
- #> a:(b:c)
1102
- = a : (b : c)
1103
1085
"""
1104
1086
1105
1087
arg_counts = [1 , 2 ]
@@ -1235,9 +1217,6 @@ class Blank(_Blank):
1235
1217
'Blank' only matches a single expression:
1236
1218
>> MatchQ[f[1, 2], f[_]]
1237
1219
= False
1238
-
1239
- #> StringReplace["hello world!", _ -> "x"]
1240
- = xxxxxxxxxxxx
1241
1220
"""
1242
1221
1243
1222
rules = {
@@ -1293,14 +1272,6 @@ class BlankSequence(_Blank):
1293
1272
'Sequence' object:
1294
1273
>> f[1, 2, 3] /. f[x__] -> x
1295
1274
= Sequence[1, 2, 3]
1296
-
1297
- #> f[a, b, c, d] /. f[x__, c, y__] -> {{x},{y}}
1298
- = {{a, b}, {d}}
1299
- #> a + b + c + d /. Plus[x__, c] -> {x}
1300
- = {a, b, d}
1301
-
1302
- #> StringReplace[{"ab", "abc", "abcd"}, "b" ~~ __ -> "x"]
1303
- = {ab, ax, ax}
1304
1275
"""
1305
1276
1306
1277
rules = {
@@ -1350,21 +1321,6 @@ class BlankNullSequence(_Blank):
1350
1321
empty sequence:
1351
1322
>> MatchQ[f[], f[___]]
1352
1323
= True
1353
-
1354
- ## This test hits infinite recursion
1355
- ##
1356
- ##The value captured by a named 'BlankNullSequence' pattern is a
1357
- ##'Sequence' object, which can have no elements:
1358
- ##>> f[] /. f[x___] -> x
1359
- ## = Sequence[]
1360
-
1361
- #> ___symbol
1362
- = ___symbol
1363
- #> ___symbol //FullForm
1364
- = BlankNullSequence[symbol]
1365
-
1366
- #> StringReplace[{"ab", "abc", "abcd"}, "b" ~~ ___ -> "x"]
1367
- = {ax, ax, ax}
1368
1324
"""
1369
1325
1370
1326
rules = {
@@ -1414,16 +1370,6 @@ class Repeated(PostfixOperator, PatternObject):
1414
1370
= {{}, a, {a, b}, a, {a, a, a, a}}
1415
1371
>> f[x, 0, 0, 0] /. f[x, s:0..] -> s
1416
1372
= Sequence[0, 0, 0]
1417
-
1418
- #> 1.. // FullForm
1419
- = Repeated[1]
1420
- #> 8^^1.. // FullForm (* Mathematica gets this wrong *)
1421
- = Repeated[1]
1422
-
1423
- #> StringReplace["010110110001010", "01".. -> "a"]
1424
- = a1a100a0
1425
- #> StringMatchQ[#, "a" ~~ ("b"..) ~~ "a"] &/@ {"aa", "aba", "abba"}
1426
- = {False, True, True}
1427
1373
"""
1428
1374
1429
1375
arg_counts = [1 , 2 ]
@@ -1502,14 +1448,6 @@ class RepeatedNull(Repeated):
1502
1448
= RepeatedNull[Pattern[a, BlankNullSequence[Integer]]]
1503
1449
>> f[x] /. f[x, 0...] -> t
1504
1450
= t
1505
-
1506
- #> 1... // FullForm
1507
- = RepeatedNull[1]
1508
- #> 8^^1... // FullForm (* Mathematica gets this wrong *)
1509
- = RepeatedNull[1]
1510
-
1511
- #> StringMatchQ[#, "a" ~~ ("b"...) ~~ "a"] &/@ {"aa", "aba", "abba"}
1512
- = {True, True, True}
1513
1451
"""
1514
1452
1515
1453
operator = "..."
@@ -1666,26 +1604,6 @@ class OptionsPattern(PatternObject):
1666
1604
Options might be given in nested lists:
1667
1605
>> f[x, {{{n->4}}}]
1668
1606
= x ^ 4
1669
-
1670
- #> {opt -> b} /. OptionsPattern[{}] -> t
1671
- = t
1672
-
1673
- #> Clear[f]
1674
- #> Options[f] = {Power -> 2};
1675
- #> f[x_, OptionsPattern[f]] := x ^ OptionValue[Power]
1676
- #> f[10]
1677
- = 100
1678
- #> f[10, Power -> 3]
1679
- = 1000
1680
- #> Clear[f]
1681
-
1682
- #> Options[f] = {Power -> 2};
1683
- #> f[x_, OptionsPattern[]] := x ^ OptionValue[Power]
1684
- #> f[10]
1685
- = 100
1686
- #> f[10, Power -> 3]
1687
- = 1000
1688
- #> Clear[f]
1689
1607
"""
1690
1608
1691
1609
arg_counts = [0 , 1 ]
0 commit comments