17
$\begingroup$

fixed in 10.1 (windows)


According to the documentation there's an operator form for StringCases

?StringCases

Mathematica graphics

Here is the normal form

 StringCases["abcadcacb", "a" ~~ x_ ~~ "c"]
{"abc", "adc"}

Now, the operator form:

 StringCases["a" ~~ x_ ~~ "c"]["abcadcacb"]

Mathematica graphics

Can anyone reproduce this in Version 10.0.1? I'm on Windows 8.1.

$\endgroup$
  • $\begingroup$ ditto on Windows 7 and the RPi $\endgroup$ – bobthechemist Sep 29 '14 at 0:41
  • $\begingroup$ @bobthechemist. Thanks for confirming. $\endgroup$ – RunnyKine Sep 29 '14 at 0:41
  • $\begingroup$ Same on OS X with V10.0.1. It seems the operator form really isn't available. $\endgroup$ – m_goldberg Sep 29 '14 at 1:00
  • 4
    $\begingroup$ The documentation should have been set to a later version (in this case, by me). Sorry about that. $\endgroup$ – Daniel Lichtblau Sep 29 '14 at 15:25
9
$\begingroup$

Indeed, StringCases does not have an operator form in 10.0.1. The documentation and usage message appear to be in error.

StringCases does not appear on the list TypeSystem`$OperatorForms -- although that is by no means conclusive as discussed here. I would argue that it should have an operator form, in symmetry with Cases. In any event, there is a bug here either in the documentation or in the implementation of StringCases.

Note that operator forms for functions like StringCases and Cases pose some problems. For StringCases, there are two arguments that could credibly be curried: the pattern and the occurrence count. But if the caller specifies two arguments, it is ambiguous whether it means StringCases[patt, n] or StringCases["string", patt]. Such are the pitfalls of idiomatic currying when the arguments lists were not designed with currying in mind.

None of this reasoning conclusively argues against the single argument operator form which has reasonably unambiguous meaning. Further more, WRI have already elected to give Cases an operator form even though the currying situation there is even worse, with three arguments that could be curried (pattern/rule, levelspec, occurrence count).

$\endgroup$
4
$\begingroup$

fixed in 10.1 (windows):

Mathematica graphics


Mathematica graphics

code:

StringCases["abcadcacb", "a" ~~ x_ ~~ "c"]
StringCases["a" ~~ x_ ~~ "c"]["abcadcacb"]
$\endgroup$
  • 3
    $\begingroup$ Thanks for all your work on checking bug status in 10.1! :-) $\endgroup$ – Mr.Wizard Apr 2 '15 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.