> I suppose this is related to + and - being unary operators?

Ding ding. Unfortunately space being the horizontal concatenation operator 
means some operations parse very differently and in highly 
whitespace-sensitive ways depending whether they are inside or outside an 
array literal. Would be nice if that were not the case, but I think we'd 
need another delimiter character aside from , or ; to really separate 
horizontal concatenation from vertical concatenation from list construction.

julia> j=2; [ 1 +j ]
1x2 Array{Int64,2}:
 1  2

julia> j=2; [ 1 + j ]
1-element Array{Int64,1}:
 3

julia> j=2; 1 +j
3

julia> j=2; 1 + j
3


On Thursday, March 5, 2015 at 4:56:20 PM UTC-8, Amuthan A. Ramabathiran 
wrote:
>
> Not sure if this has been discussed earlier... can someone explain whats 
> happening here?
>
> julia> b = [ 1 +j for j = 1:5 ]
> ERROR: syntax: invalid comprehension syntax
>
> julia> b = [ 1 + j for j = 1:5 ]
> 5-element Array{Int64,1}:
>  2
>  3
>  4
>  5
>  6
>
>
> This happens with both + and -, but not with * or /. I suppose this is 
> related to + and - being unary operators?
>
> Thanks!
> Amuthan.
>

Reply via email to