Decompose F.SUM/F.MIN/F.MAX functors and build them with composition using F.SUM_RANGE/F.MIN_ELEMENT/F.MAX_ELEMENT
There are now two sets of functors F.SUM(functor)
/F.MIN(functor)
/F.MAX(functor)
and F.SUM_RANGE
/F.MIN_ELEMENT
/F.MAX_ELEMENT
, which can be very confusing.
The F.SUM(functor)
/F.MIN(functor)
/F.MAX(functor)
functors apply the given functor
to the immediate children of the composite and return the sum/min/max value, whereas F.SUM_RANGE
/F.MIN_ELEMENT
/F.MAX_ELEMENT
return the sum/min/max values in a container.
The former can be decomposed in favor of latter i.e.
SUM = lambda functor: SUM_RANGE @ MAP(functor) @ GET_CHILDREN
MIN = lambda functor: MIN_ELEMENT @ MAP(functor) @ GET_CHILDREN
MAX = lambda functor: MAX_ELEMENT @ MAP(functor) @ GET_CHILDREN
Would need a new functor GET_CHILDREN
to achieve this.
Edited by Tommaso Fulghesu