From 80cf250d22a5d5eff4a2a1b9a6720026f2fe8e38 Mon Sep 17 00:00:00 2001 From: Hongbo Zhang Date: Tue, 3 Dec 2024 11:45:18 +0800 Subject: [PATCH] AI generated docs --- builtin/array.mbt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/builtin/array.mbt b/builtin/array.mbt index 631465738..437356d56 100644 --- a/builtin/array.mbt +++ b/builtin/array.mbt @@ -191,6 +191,24 @@ pub fn each[T](self : Array[T], f : (T) -> Unit) -> Unit { } ///| +/// Iterates over the elements of the array in reverse order, applying the given +/// function to each element. +/// +/// Parameters: +/// +/// * `array` : The array to iterate over. +/// * `f` : A function that takes an element of type `T` and returns `Unit`. This +/// function is applied to each element of the array in reverse order. +/// +/// Example: +/// +/// ``` +/// let v = [3, 4, 5] +/// let mut sum = 0 +/// v.rev_each(fn(x) { sum = sum - x }) +/// @json.inspect!(sum, content=-12) +/// +/// ``` pub fn rev_each[T](self : Array[T], f : (T) -> Unit) -> Unit { let len = self.length() for i in 0..