def select(expr n)(text values) =
  begingroup;
    i := 0;
    for v = values:
      result := v;
      exitif i = n;
      i := i + 1;
    endfor;
    result
  endgroup
enddef;

def interpolate(expr x)(text values) =
  begingroup;
    if design_size <= 5:
      x * select(0)(values) * design_size/5
    elseif design_size >= 12:
      x * select(6)(values) * design_size/12
    elseif design_size >= 10:
      x * ((design_size - 10)/2)[select(5)(values), select(6)(values)]
    else:
      n := floor design_size;

      x * (design_size - n)[select(n-5)(values), select(n-4)(values)]
    fi
  endgroup
enddef;