[orx-delegate-magic] Update docstrings

This commit is contained in:
Edwin Jakobs
2023-04-29 12:01:45 +02:00
parent 0353b923e3
commit cef15b728b
2 changed files with 19 additions and 0 deletions

View File

@@ -4,7 +4,13 @@ package org.openrndr.extra.delegatemagic.aggregation
import kotlin.math.abs
/**
* Return element with largest magnitude
* @since 0.4.3
*/
fun List<Double>.maxMag(): Double {
this.max()
if (isEmpty()) {
error("list is empty")
}
@@ -21,6 +27,10 @@ fun List<Double>.maxMag(): Double {
return maxMagWithSign
}
/**
* Return element with smallest magnitude
* @since 0.4.3
*/
fun List<Double>.minMag(): Double {
if (isEmpty()) {
error("list is empty")

View File

@@ -6,6 +6,9 @@ import org.openrndr.Clock
import kotlin.reflect.KProperty
import kotlin.reflect.KProperty0
/**
* Property delegation by list aggregation
*/
class ListPropertyAggregation<T, R>(
private val clock: Clock,
private val property: KProperty0<List<T>>,
@@ -29,6 +32,12 @@ class ListPropertyAggregation<T, R>(
}
}
/**
* Aggregate list property
* @param property the list property to aggregate
* @param aggregationFunction the function that is
* @since 0.4.3
*/
fun <T, R> Clock.aggregating(
property: KProperty0<List<T>>,
aggregationFunction: (List<T>) -> R