Module: core.array

Source: ./core/array.reef


Overview

core.array - Array utility functions

Provides generic and type-specific array operations including length, contains, index_of, sum, min/max, sorting, and reversing.

array_index_of, min_int, and max_int return core.option.Option[int]: Some(value) on success, None when the value is absent (not found, or the array is empty for min/max).


Functions

fn array_length(arr: [T]): int

Returns the length of an array by counting elements

fn array_contains(arr: [T], value: T): bool

Checks if an array contains a specific value

fn array_index_of(arr: [T], value: T): option.Option[int]

Returns Some(index) of the first occurrence of value, or None if not found

fn sum_int(arr: [int]): int

Sums all integers in an array

fn sum_float(arr: [float]): float

Sums all floats in an array

fn min_int(arr: [int]): option.Option[int]

Returns Some(minimum value) in an int array, or None for an empty array

fn max_int(arr: [int]): option.Option[int]

Returns Some(maximum value) in an int array, or None for an empty array

fn partition_int(arr: [int], low: int, high: int): int

Partition helper for integer quicksort

fn partition_float(arr: [float], low: int, high: int): int

Partition helper for float quicksort

fn partition_string(arr: [string], low: int, high: int): int

Partition helper for string quicksort

fn is_sorted_int(arr: [int], len: int): bool

Checks if an integer array is sorted in ascending order

fn is_sorted_float(arr: [float], len: int): bool

Checks if a float array is sorted in ascending order

fn is_sorted_string(arr: [string], len: int): bool

Checks if a string array is sorted in lexicographic order


Procedures

proc sort_int(arr: [int], len: int)

Sorts an integer array in-place using quicksort

proc quicksort_int(arr: [int], low: int, high: int)

Quicksort helper for integers

proc sort_float(arr: [float], len: int)

Sorts a float array in-place using quicksort

proc quicksort_float(arr: [float], low: int, high: int)

Quicksort helper for floats

proc sort_string(arr: [string], len: int)

Sorts a string array in-place using quicksort (lexicographic order)

proc quicksort_string(arr: [string], low: int, high: int)

Quicksort helper for strings

proc reverse_int(arr: [int], len: int)

Reverses an integer array in-place

proc reverse_float(arr: [float], len: int)

Reverses a float array in-place

proc reverse_string(arr: [string], len: int)

Reverses a string array in-place


Generated by reefc doc