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

start:end:step #764

Open
xushiwei opened this issue Aug 28, 2021 · 4 comments
Open

start:end:step #764

xushiwei opened this issue Aug 28, 2021 · 4 comments
Labels
Milestone

Comments

@xushiwei
Copy link
Member

xushiwei commented Aug 28, 2021

a[start:end:step] = value

for i <- start:end:step {
    ...
}

for i := range start:end:step {
    ...
}

for range start:end:step {
    ...
}

for start:end:step {
    ...
}
@xushiwei xushiwei changed the title for i <- start:end:step for i <- start:end:step Aug 28, 2021
@xushiwei xushiwei modified the milestones: Go+ v1.0, Go+ v1.1 Aug 28, 2021
@xushiwei xushiwei changed the title for i <- start:end:step start:end:step Aug 28, 2021
@xushiwei
Copy link
Member Author

It's awkward that there is a slice syntax a[start:end:cap] in Go.
However, if a is not a slice or array type, we still can use a[start:end:step].

Or usestart:end by step?

a[start:end by step] = value

for i <- start:end by step {
    ...
}

for i := range start:end by step {
    ...
}

@xushiwei
Copy link
Member Author

julia & matlab:

start:step:end

@xushiwei
Copy link
Member Author

xushiwei commented Oct 28, 2021

type Matrix[T Numeric] struct ...

func (m *Matrix[T]) [] (i, j int) T { // getter: x = m[i, j] translates to x = m.[](i, j)
}

func (m *Matrix[T]) []= (i, j int, x T) { // setter: m[i, j] = x translates to m.[]=(i, j, x)
}

From https://medium.com/@rhadar/a-data-scientists-take-on-go-ed408c00ac45, golang/go#41129

@xushiwei
Copy link
Member Author

xushiwei commented Nov 5, 2021

Only implement for range in milestone v1.1

@xushiwei xushiwei modified the milestones: Go+ v1.1, Go+ v1.7 Nov 5, 2021
@xushiwei xushiwei mentioned this issue Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant