It seems that

include_string("[1,2,3]")

also works.  Is there any reason to prefer one or the other of these 
techniques over the other?

Thanks,
Peter

On Monday, August 31, 2015 at 2:52:09 AM UTC-7, René Donner wrote:
>
> Hi, 
>
> yes, it works almost the same: 
>
> julia> eval(parse("[1,2,3]")) 
> 3-element Array{Int64,1}: 
>  1 
>  2 
>  3 
>
>
> parse parses the string into an expression (abstract syntax tree, AST), 
> and eval, well, evaluates ;-) 
>
> But take care, any valid code inside the string will get executed. 
>
> Rene 
>
>
>
>
> Am 31.08.2015 um 11:48 schrieb Ali Rezaee <arv....@gmail.com <javascript:>>: 
>
>
> > How can I convert the string representation of an array, such as the 
> following string, into an Array? 
> > 
> > 
> > s = "[1,2,3]" 
> > 
> > I am reading these strings from a file and I am looking for an easy way 
> to have them as a list. 
> > In Python I would use eval function. Is there an alternative in Julia? 
> > 
> > Many thanks, 
> > 
> > Ali 
> > 
>
>

Reply via email to