NSState >>
 Distance : Float
;

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

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

Return

/* * */

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

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 : Distance >
 R.Ext.State = State
;  

Return