Re:list of bits to string
- To: mathgroup at smc.vnet.net
- Subject: [mg28701] Re:[mg28688] list of bits to string
- From: Ranko Bojanic <bojanic at math.ohio-state.edu>
- Date: Thu, 10 May 2001 07:54:46 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Murray Eisenberg <murray at math.umass.edu> wrote in [mg28688]: >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? There will be probably many answers to this question. Here is one: g[{x_,y_,z___}] := { StringJoin[ToString[x], ToString[y]], z } f[ lst_ ]:=Nest[g, lst, Length[lst]-1] lst = {0,1,1,0,1} f[lst] {01101} Regards, Ranko Ranko Bojanic bojanic at math.ohio-state.edu