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: [mg28697] Re: [mg28688] list of bits to string
  • From: "Mark Harder" <harderm at ucs.orst.edu>
  • Date: Thu, 10 May 2001 07:54:43 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

O.K.  Here's a recursive solution.

In[156]:=
Clear[ToBinPolyString];
ToBinPolyString[{}] := "";
ToBinPolyString[a_List] :=
  ToString[First[a] ] <> ToBinPolyString[Rest[a ] ] ;

In[162]:=ToBinPolyString[binList]
Out[162]="01101"

-mark harder

-----Original Message-----
From: Mark Harder <harderm at ucs.orst.edu>
To: mathgroup at smc.vnet.net
<mathgroup at smc.vnet.net>
Subject: [mg28697] Re: [mg28688] list of bits to string


>Murray,
>    This will do it:
>
>binList = {0, 1, 1, 0, 1};
>
>binString = ToString[binList[[1]] ];
>Do[
>  binString = StringJoin[binString, ToString[binaryList[[i]] ],
>{i, 2, Length[binaryList]} ]
>
>In[124]:=binString
>Out[124]= "01101"
>
>But I wonder if there is a more functional approach?  Seems like there
>should be.
>-mark harder
>
>
>-----Original Message-----
>From: Murray Eisenberg <murray at math.umass.edu>
To: mathgroup at smc.vnet.net
>To: mathgroup at smc.vnet.net <mathgroup at smc.vnet.net>
>Date: Wednesday, May 09, 2001 1:32 AM
>Subject: [mg28697] [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
>>
>



  • Prev by Date: Re: list of bits to string
  • Next by Date: Re: Urgent!! Help about NDSolve
  • Previous by thread: Re: list of bits to string
  • Next by thread: Re: list of bits to string