Skip to content
This repository has been archived by the owner on Dec 3, 2019. It is now read-only.

Bug in vector assignment #143

Open
jembrown opened this issue Jan 28, 2019 · 1 comment
Open

Bug in vector assignment #143

jembrown opened this issue Jan 28, 2019 · 1 comment

Comments

@jembrown
Copy link
Member

Something about the way vectors and vector elements are created and/or assigned leads to a bug when reassigning a vector to a variable name. In this example, testVec[1] should be 0 at the end.

> testVec = v(0,0)
> testVec[1] += 1
> testVec
   [ 1, 0 ]
> testVec = v(0,0)
> testVec
   [ 0, 0 ]
> testVec[1]
   1
@jembrown
Copy link
Member Author

jembrown commented Oct 5, 2019

I'm following up on this, because I just ran into it again. In this case, I was trying to sort a vector, reassign the sorted vector to the original variable name, and access individual elements in the sorted vector. This works properly when the vector is defined all at once. But it fails when the vector is created by assigning to individual indices.

> myVec <- [1.2,6.7,4.5]
> myVec
   [ 1.200, 6.700, 4.500 ]
> myVec <- sort(myVec)
> myVec
   [ 1.200, 4.500, 6.700 ]
> myVec[2]
   4.5
> myVec[3]
   6.7
> myVecTwo[1] <- 1.2
> myVecTwo[2] <- 6.7
> myVecTwo[3] <- 4.5
> myVecTwo
   [ 1.200, 6.700, 4.500 ]
> myVecTwo <- sort(myVecTwo)
> myVecTwo
   [ 1.200, 4.500, 6.700 ]
> myVecTwo[2]
   6.7

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant