1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

arrays, maps: add indexed variant of collection function and minor cleanup (#15948)

This commit is contained in:
ChAoS_UnItY
2022-10-03 15:42:36 +08:00
committed by GitHub
parent 5b59171a00
commit ffaca82ff8
4 changed files with 135 additions and 5 deletions

View File

@@ -24,8 +24,8 @@ pub fn to_array<K, V, I>(m map[K]V, f fn (K, V) I) []I {
return a
}
// flatten maps map entries into arrays and flattens into a one-dimensional array
pub fn flatten<K, V, I>(m map[K]V, f fn (K, V) []I) []I {
// flat_map maps map entries into arrays and flattens into a one-dimensional array
pub fn flat_map<K, V, I>(m map[K]V, f fn (K, V) []I) []I {
mut a := []I{cap: m.len}
for k, v in m {