Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2001

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

Search the Archive

Re: list of bits to string

  • To: mathgroup at smc.vnet.net
  • Subject: [mg28719] Re: [mg28688] list of bits to string
  • From: Murray Eisenberg <murraye at mediaone.net>
  • Date: Thu, 10 May 2001 07:55:03 -0400 (EDT)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <OFC620A1C1.BF42A889-ONC1256A47.00308304@icos.be>
  • Sender: owner-wri-mathgroup at wolfram.com

Thank you all for suggesting the same solution that I came up with after
sending my original inquiry.  In my situation, I actually had a list of
such lists of binary digits (arising, in fact, as the Gray code of order
4):

   gCode[1] = { {0}, {1} } ;
   gCode[n_] := With[{g = gCode[n - 1]}, 
      Join[Map[Prepend[#, 0] &, g], Map[Prepend[#, 1] &, Reverse[g]]]]

So to convert the result of gCode[4] to the list of 4-character strings
I needed (to label the vertices in a Hamiltonian circuit of the "4-cube"
graph), I used:

   Map[Apply[StringJoin, Map[ToString, #]] &, gCode[4]]

The preceding expression still seems overly complicated to me: did I
miss some simplification?


maarten.vanderburgt at icos.be wrote:
> 
> Murray,
> 
> StringJoin[ToString/@{0,1,1,0,1}] does what you need.
> 
> regards
> 
> Maarten van der Burgt
> Leuven
> Belgium
> 
> murray at math.umass.edu (Murray Eisenberg) on 09-05-2001 10:20:08 AM
> 
> To:   mathgroup at smc.vnet.net
> cc:
> 
> Subject: [mg28719]  [mg28688] list of bits to string
> 
> I have a list consisting of binary digits, of a given length, e.g.,
> {0, 1, 1, 0, 1}.  I wish to convert this to a _string_ consisting of
> those digits: "01101".  How can this be done?
> 
> --
>   Murray Eisenberg                       Internet:  murray at math.umass.edu
>   Mathematics & Statistics Dept.            Voice:  413-545-2859 (W)
>   University of Massachusetts                       413-549-1020 (H)
>   Amherst, MA 01003                           Fax:  413-545-1801

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.       phone 413 549-1020 (H)
Univ. of Massachusetts                     413 545-2859 (W)
Amherst, MA 01003-4515


  • Prev by Date: NotebookPath problem under Windows 2000
  • Next by Date: Re: Urgent Message Link --- Sample J/Link Projects
  • Previous by thread: Re: list of bits to string
  • Next by thread: Re: list of bits to string