MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

StringReplace with empty list (Mathematica wish list)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71578] StringReplace with empty list (Mathematica wish list)
  • From: "Ingolf Dahl" <ingolf.dahl at telia.com>
  • Date: Thu, 23 Nov 2006 05:41:51 -0500 (EST)

To MathGroup,
In the Help:
"StringReplace[{s1, s2, ... }, srules] gives the list of results for each of
the si."

This works perfectly well if the number of strings in the first argument
list is 1 or 3 or 57. But if we try with a list of length zero, we get an
error message:

StringReplace::"strs": "String or non-empty list of strings expected at
position 1 in StringReplace[{},{"a"->"b"}]. More..."

Why is it done in this way? Why are not empty lists accepted? Zero is also a
number, and I would expect StringReplace to simply return an empty list.
Now, if I use StringReplace in a context where a variable number of strings
can occur, I have to check for the number zero. This is quite easily done
(in a number of ways), but I feel it  superfluous. I suspect that there are
more analogous cases around, but I am not aware of any more just now.  

It would be even better if StringReplace could accept any expression, and
replace inside any string in that expression. One could also think of some
kind of seemless integration of Replace and StringReplace. Something for
Mathematica 6?

Ingolf Dahl
Sweden



  • Prev by Date: Re: number not fitting in
  • Next by Date: Re: ComplexityFunction affects set of transformations tried by Simplify
  • Previous by thread: Re: Special decomposition of a rectangular matrix
  • Next by thread: Bookmarks in Mathematica ????