From c7e47e6884901c97f19db3e09e52259369fe4f18 Mon Sep 17 00:00:00 2001 From: Don Alfons Nisnoni Date: Sat, 12 Oct 2019 05:06:30 +0800 Subject: [PATCH] array: minor clean up --- vlib/builtin/array.v | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/vlib/builtin/array.v b/vlib/builtin/array.v index eea38bb19a..4499d80868 100644 --- a/vlib/builtin/array.v +++ b/vlib/builtin/array.v @@ -293,7 +293,6 @@ pub fn (a mut []int) sort() { // Looking for an array index based on value. // If there is, it will return the index and if not, it will return `-1` -// TODO: Implement for all types pub fn (a []string) index(v string) int { for i := 0; i < a.len; i++ { if a[i] == v { @@ -344,7 +343,7 @@ pub fn (a []string) filter(predicate fn(p_val string, p_i int, p_arr []string) return res } -pub fn (a []int) filter(predicate fn(p_val int, p_i int, p_arr []int) bool) []int +pub fn (a []int) filter(predicate fn(p_val, p_i int, p_arr []int) bool) []int { mut res := []int for i := 0; i < a.len; i++ { @@ -357,13 +356,9 @@ pub fn (a []int) filter(predicate fn(p_val int, p_i int, p_arr []int) bool) []in ////////////// REDUCE ////////////// -// method executes a reducer function (that you provide) on each element of the array, +// Executes a reducer function (that you provide) on each element of the array, // resulting in a single output value. -pub fn (a []int) reduce( - iter fn (accum int, curr int) int, - accum_start int -) int -{ +pub fn (a []int) reduce(iter fn (accum, curr int) int, accum_start int) int { mut _accum := 0 _accum = accum_start for i := 0; i < a.len; i++ {