title: Equivalent of `break` in purrr::map
body: <p>Say I want to run a loop until a condition is met, at which point the result is saved and the loop exits:</p>
  
  <pre><code>library(tidyverse)
  
  for (i in 1:5) {
  
    df &lt;- iris %&gt;% select(i) %&gt;% head(2)
  
    if (names(df) == "Petal.Width") {
      out &lt;- df
      break 
  
    }
  }
  
  out
  </code></pre>
  
  <p>How can I rewrite this using <code>purr::map</code> without having to evaluate each i?</p>
  
  <p>Doing the following gives the result I need, but has to evaluate 5 times, whereas the for loop only 3 times:</p>
  
  <pre><code>fun &lt;- function(x) {
  
    df &lt;- iris %&gt;% select(x) %&gt;% head(2)
  
    if (names(df) == "Petal.Width") {
    return(df)
    }
  }
  
  map_df(1:5, fun)
  </code></pre>