mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
rand: minor cleanup in choose() (#14376)
This commit is contained in:
parent
5bc4fea9e0
commit
8830af5c89
@ -327,9 +327,7 @@ pub fn (mut rng PRNG) choose<T>(array []T, k int) ?[]T {
|
|||||||
}
|
}
|
||||||
mut results := []T{len: k}
|
mut results := []T{len: k}
|
||||||
mut indices := []int{len: n, init: it}
|
mut indices := []int{len: n, init: it}
|
||||||
// TODO: see why exactly it is necessary to enfoce the type here in Checker.infer_fn_generic_types
|
rng.shuffle(mut indices) ?
|
||||||
// (v errors with: `inferred generic type T is ambiguous: got int, expected string`, when <int> is missing)
|
|
||||||
rng.shuffle<int>(mut indices) ?
|
|
||||||
for i in 0 .. k {
|
for i in 0 .. k {
|
||||||
results[i] = array[indices[i]]
|
results[i] = array[indices[i]]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user