MinMaxState >>
 Latest : Arg
;

C_* :
 MIN
 MAX
;

Max ->
Arg Items : Array | List, Pc : Float
    Value : < &Arg, Arg >, Store : < Arg, Integer >

- Enumerate 'State' Items . Pc Value Store CompareMax
' State : MinMaxState = . ..

Return

/* * */

Min ->
Arg Items : Array | List, Pc : Float
    Value : < &Arg, Arg >, Store : < Arg, Integer >

- Enumerate 'State' Items . Pc Value Store CompareMin
' State : MinMaxState = . ..

Return

/* * */

CompareMax = Compare ? * C_MAX
CompareMin = Compare ? * C_MIN

/* * */

Compare Compare% ->
Arg R : ^&Report, A : Data
    T : C_MAX | C_MIN

If A.Step = 1 then
 - Copy 'R' A
Else
 S : MinMaxState = R.Ext.State

 If T = C_MAX then
  If A.Value > S.Latest .A.Precision then - Copy 'R' A
  Else _
 Else
  If A.Value < S.Latest .A.Precision then - Copy 'R' A
  Else _
 ;
;

Return

/* * */

Copy Compare ->
Arg R : ^&Report, A : Data

R.Key = A.Key; R.Record = A.Record; R.Step = A.Step
State : MinMaxState = < Latest : A.Value >
R.Ext.State = State

Return