Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #16258

Re: Programming Fail

From Bill Rowe <readnews@sbcglobal.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Programming Fail
Date 2013-11-20 10:46 +0000
Message-ID <l6i3tv$822$1@smc.vnet.net> (permalink)
Organization Time-Warner Telecom

Show all headers | View raw


On 11/19/13 at 2:58 AM, akrasnov@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}

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Programming Fail Bill Rowe <readnews@sbcglobal.net> - 2013-11-20 10:46 +0000

csiph-web