Re: Programming Fail
- To: mathgroup at smc.vnet.net
- Subject: [mg132035] Re: Programming Fail
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Wed, 20 Nov 2013 06:24:10 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-outx@smc.vnet.net
- Delivered-to: mathgroup-newsendx@smc.vnet.net
On 11/19/13 at 2:58 AM, akrasnov at cory.eecs.berkeley.edu (Alex Krasnov) wrote: >Your solution is similar to my second one but fails given leading >zeros: >In: ToExpression[Characters["0123"]] Out: {0, 1, 2, 3} >In: IntegerDigits[ToExpression["0123"]] Out: {1, 2, 3} >You can provide a length argument if known: > >In: IntegerDigits[ToExpression["0123"], 10, 4] Out: {0, 1, 2, >3} You can avoid the issue with a leading zero without knowing the number of digits you need by first changing the string to a list of characters, i.e., ToExpression@Characters["0123"] will return the 4 integers {0,1,2,3}