title: return index from a vector of the value closest to a given element
body: <p>I have a list of elements such as </p>
  
  <pre><code>A=
    0.992688
    0.892195
    0.889151
    0.380672
    0.180576
    0.685028
    0.58195
  </code></pre>
  
  <p>Given an input element, like 0.4, how can I find the index that holds the number being most near to this number. For instance, <code>A[4] = 0.380672</code>  is most near to 0.4. Therefore, it should return to 4</p>