NSState >>
 Distance : Float
;

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

- Enumerate 'State' Items Rq Pc Value Store Compare
' State : NSState = . ..

Return

/* * */

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

Previous_distance = 0 ..

Distance = Distance A.Value A.Request

T : NSState = R.Ext.State,
Previous_distance = T.Distance [ R.Ext.State is NSState ]

If A.Step = 1 | Distance < Previous_distance .A.Precision then
 R.Key = A.Key; R.Record = A.Record; R.Step = A.Step
 R.Continue = 0 [ Distance = 0 .A.Precision ]
 State : NSState = < Distance : _ >
 R.Ext.State = State
;  

Return