srecord noeq probabilisticDistanceBasedLookup( IProbabilisticScheduler scheduler, NavigableMap map, IVF1 action, double key) { swappable double distanceToProbability(double distance) { ret genericDistanceToProbability(distance); } run { Double closest = closestDoubleKey(map, key); if (closest == null) ret; double p = distanceToProbability(abs(closest-key)); scheduler.at(p, () -> action.get(closest)); scheduler.at(p, () -> walkLeft(closest)); scheduler.at(p, () -> walkRight(closest)); } void walkLeft(double key) { Double x = map.lowerKey(key); if (x == null) ret; double p = distanceToProbability(abs(x-key)); scheduler.at(p, () -> action.get(x)); scheduler.at(p, () -> walkLeft(x)); } void walkLeft(double key) { Double x = map.lowerKey(key); if (x == null) ret; double p = distanceToProbability(abs(x-key)); scheduler.at(p, () -> action.get(x)); scheduler.at(p, () -> walkRight(x)); } }