Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use same range specification in for loop as for matrix indexing #906

Open
m-birke opened this issue Nov 12, 2024 · 0 comments
Open

Use same range specification in for loop as for matrix indexing #906

m-birke opened this issue Nov 12, 2024 · 0 comments

Comments

@m-birke
Copy link
Collaborator

m-birke commented Nov 12, 2024

When a matrix is indexed like A[:4,], it returns four values (0..3)

It is confusing that the same does not apply to for loop ranges,
for (i in 0:4) iterates five times/ five values 0..4
a single iteration needs for (i in 0:0) which is unintuitive

A = as.matrix([0,1,2,3,4,5,6]);
print(transpose(A[:4,]));

for (i in 0:4) {
    print(A[i,]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant