MathGroup Archive 2001

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

Search the Archive

Re: Working with strings

  • To: mathgroup at
  • Subject: [mg31966] Re: [mg31940] Working with strings
  • From: BobHanlon at
  • Date: Fri, 14 Dec 2001 04:21:35 -0500 (EST)
  • Sender: owner-wri-mathgroup at

In a message dated 12/13/01 2:31:11 AM, bghiggins at writes:

>I have a list of string characters that I would like to group in a
>particular way. The list has the following structure:
>{n UpperCase Characters, x, m UpperCase Characters}
>Here is an example:
>myString={"S", "T", "M", "x", "R", "K", "P", "G"}
>Now I would like to form the following groupings:
>{"SxR", "SxK", "SxP", "SxG", "TxR", "TxK", "TxP", "TxG", "MxR", "MxK",
>"MxP", \
>A brute force way of doing this is
>subString[n_] := Split[myString, UpperCaseQ[#2] && UpperCaseQ[#1]
>Flatten[Outer[StringJoin, Outer[StringJoin, subString[1],
>    subString[3]]]
>Does anyone have any elegant way of doing this with perhaps using
>replacement rules?



{"SxR", "SxK", "SxP", "SxG", "TxR", 
  "TxK", "TxP", "TxG", "MxR", 
  "MxK", "MxP", "MxG"}

Bob Hanlon
Chantilly, VA  USA

  • Prev by Date: Re: Syntax errors in autogenerated packages
  • Next by Date: Re: Working with strings
  • Previous by thread: Re: Working with strings
  • Next by thread: Re: Working with strings