luna-utils

luna-utils is a small utility package for Luna-Flow projects. It provides array helpers and comparison helpers whose numeric constraints come from the traits of luna-generic, so they work for any type that implements the required structure.

Public functions

The package exports only functions; it defines no types or traits of its own.

FunctionConstraintBehaviour
arr_sumAddMonoidSum of the elements; zero() for an empty array.
arr_abs_sumNum + CompareSum of the absolute values of the elements.
zero_arrAddMonoidArray of length n filled with zero().
arr_max, arr_minCompareLargest or smallest element; panics on an empty array.
findEqIndex of the first occurrence of a value, or None.
reversenoneNew array with the elements in reverse order.
reverse_inplacenoneReverses an array in place.
sameEqWhether all elements equal the first; panics on an empty array.
same_toEqWhether all elements equal a given sample.
map_same, map_same_toEq on the resultsame and same_to applied to the mapped array.
clampCompareRestricts a value to the closed range from min to max.
is_betweenCompareWhether a value lies in the closed range from min to max.

The interface file pkg.generated.mbti is the authoritative list of signatures, and the generated API documentation is on mooncakes.io.

Modules

The package Luna-Flow/luna-utils has two source files, which the manual documents as two modules:

Contributing

Code style, naming, commit and review rules are in the contribution guidelines.