array: remove redundant index method in array.v (#7523)
parent
fdf6927585
commit
775d16cce3
|
@ -597,51 +597,6 @@ pub fn (a []string) index(v string) int {
|
|||
return -1
|
||||
}
|
||||
|
||||
// index returns the first index at which a given element can be found in the array
|
||||
// or -1 if the value is not found.
|
||||
pub fn (a []int) index(v int) int {
|
||||
for i in 0 .. a.len {
|
||||
if a[i] == v {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
// index returns the first index at which a given element can be found in the array
|
||||
// or -1 if the value is not found.
|
||||
pub fn (a []byte) index(v byte) int {
|
||||
for i in 0 .. a.len {
|
||||
if a[i] == v {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
// index returns the first index at which a given element can be found in the array
|
||||
// or -1 if the value is not found.
|
||||
pub fn (a []rune) index(v rune) int {
|
||||
for i in 0 .. a.len {
|
||||
if a[i] == v {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
// index returns the first index at which a given element can be found in the array
|
||||
// or -1 if the value is not found.
|
||||
// TODO is `char` type yet in the language?
|
||||
pub fn (a []char) index(v char) int {
|
||||
for i in 0 .. a.len {
|
||||
if a[i] == v {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
// reduce executes a given reducer function on each element of the array,
|
||||
// resulting in a single output value.
|
||||
pub fn (a []int) reduce(iter fn (int, int) int, accum_start int) int {
|
||||
|
|
Loading…
Reference in New Issue