hueContrastScore = palette => {
const threshold = 0.05;
const hues = map(palette, hue);
const [ok, notok] = partition(combinations(hues, 2).map( ([a,b])=>Math.abs(circdist(a,b))), _ => _ >= threshold);
const huedists = map(combinations(hues, 2), _ => circdist(_[0], _[1]));
const [minhue, maxhue] = minmax(huedists);
const ideal = Math.max(threshold, (maxhue-minhue)/len(palette));
const [above, below] = partition(ok, _ => dist(ideal, _) >= 0)
return len(above) / (len(ok)||1);
}