user2820579
user2820579

Reputation: 3451

error while trying to define a vector in julia, parsing

Perhaps is in older versions of julia, mine is Version 0.5.0-dev+2007 2016-01-05 18:26 UTC), but if you define:

julia> [1 +2,1]
ERROR: syntax: unexpected comma in matrix expression
in eval at ./boot.jl:265

Yo have to either define [1+2,1] or [1 + 2, 1]. Is this on purpose?

Upvotes: 1

Views: 144

Answers (1)

sbromberger
sbromberger

Reputation: 1026

This is because Julia is parsing the +2 as the number "positive 2" and not treating the + as the addition operator. Since vectors of the form [a b,c] are invalid, you get the error.

Upvotes: 4

Related Questions