gop
gop copied to clipboard
`start:end:step`
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 {
...
}
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 {
...
}
julia & matlab:
start:step:end
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, https://github.com/golang/go/issues/41129
Only implement for range in milestone v1.1
- https://github.com/goplus/gop/issues/865