array-mumu 0.2.0-rc.5

Array tools plugin for the Mumu ecosystem
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
extend("array")

// Example 1: Summing the elements of an integer array
arr = [1, 2, 3, 4, 5]
result = array:reduce((acc, x) => acc + x, 0, arr)
slog(result)  // Output: 15 (the sum of the array)

// Example 2: Concatenating strings in an array
str_arr = ["Hello", " ", "World", "!"]
result_str = array:reduce((acc, x) => acc + x, "", str_arr)
slog(result_str)  // Output: "Hello World!"

// Example 3: Finding the maximum value in an array of numbers
numbers = [10, 5, 8, 22, 7]
result_max = array:reduce((acc, x) => acc > x ? acc : x, numbers[0], numbers)
slog(result_max)  // Output: 22 (the maximum value)