diff --git a/orx-delegate-magic/src/commonMain/kotlin/aggregation/Aggregators.kt b/orx-delegate-magic/src/commonMain/kotlin/aggregation/Aggregators.kt index c4dea4c6..a17ba445 100644 --- a/orx-delegate-magic/src/commonMain/kotlin/aggregation/Aggregators.kt +++ b/orx-delegate-magic/src/commonMain/kotlin/aggregation/Aggregators.kt @@ -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.maxMag(): Double { + + this.max() if (isEmpty()) { error("list is empty") } @@ -21,6 +27,10 @@ fun List.maxMag(): Double { return maxMagWithSign } +/** + * Return element with smallest magnitude + * @since 0.4.3 + */ fun List.minMag(): Double { if (isEmpty()) { error("list is empty") diff --git a/orx-delegate-magic/src/commonMain/kotlin/aggregation/ListAggregation.kt b/orx-delegate-magic/src/commonMain/kotlin/aggregation/ListAggregation.kt index fa0f5406..5260db33 100644 --- a/orx-delegate-magic/src/commonMain/kotlin/aggregation/ListAggregation.kt +++ b/orx-delegate-magic/src/commonMain/kotlin/aggregation/ListAggregation.kt @@ -6,6 +6,9 @@ import org.openrndr.Clock import kotlin.reflect.KProperty import kotlin.reflect.KProperty0 +/** + * Property delegation by list aggregation + */ class ListPropertyAggregation( private val clock: Clock, private val property: KProperty0>, @@ -29,6 +32,12 @@ class ListPropertyAggregation( } } +/** + * Aggregate list property + * @param property the list property to aggregate + * @param aggregationFunction the function that is + * @since 0.4.3 + */ fun Clock.aggregating( property: KProperty0>, aggregationFunction: (List) -> R