<div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><br><pre class="sourceCode cpp" style="font-family: Inconsolata, sans-serif; box-sizing: border-box; padding: 9.5px; margin-top: 0px; margin-bottom: 10px; line-height: 20px; word-break: break-all; background-color: rgb(250, 250, 250); border: 1px solid rgb(221, 221, 221); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px;"><div><font color="#902000">Dear Rcppusers,</font></div><div><font color="#902000">  When i am learning Rcpp , i meet the following function, i can't figure out its use, May you explain to me ?</font></div></pre><pre class="sourceCode cpp" style="box-sizing: border-box; font-family: Inconsolata, sans-serif; padding: 9.5px; margin-top: 0px; margin-bottom: 10px; line-height: 20px; word-break: break-all; background-color: rgb(250, 250, 250); border: 1px solid rgb(221, 221, 221); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px;"><div><span style="color: rgb(144, 32, 0); font-family: arial;"> </span></div><div style="color: rgb(51, 51, 51);"><code class="sourceCode cpp" style="box-sizing: border-box; font-family: Inconsolata, sans-serif; font-size: inherit; padding: 0px; color: inherit; background-color: transparent; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; border: 0px;"><span class="dt" style="box-sizing: border-box; color: rgb(144, 32, 0);">int</span> f4(Function pred, List x) {</code></div><code class="sourceCode cpp" style="color: inherit; box-sizing: border-box; font-family: Inconsolata, sans-serif; font-size: inherit; padding: 0px; background-color: transparent; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; border: 0px;">  <span class="dt" style="box-sizing: border-box; color: rgb(144, 32, 0);">int</span> n = x.size();

  <span class="kw" style="box-sizing: border-box; color: rgb(85, 85, 85); font-weight: bold;">for</span>(<span class="dt" style="box-sizing: border-box; color: rgb(144, 32, 0);">int</span> i = <span class="dv" style="box-sizing: border-box; color: rgb(64, 160, 112);">0</span>; i < n; ++i) {
    LogicalVector res = pred(x[i]);
    <span class="kw" style="box-sizing: border-box; color: rgb(85, 85, 85); font-weight: bold;">if</span> (res[<span class="dv" style="box-sizing: border-box; color: rgb(64, 160, 112);">0</span>]) <span class="kw" style="box-sizing: border-box; color: rgb(85, 85, 85); font-weight: bold;">return</span> i + <span class="dv" style="box-sizing: border-box; color: rgb(64, 160, 112);">1</span>;
  }
  <span class="kw" style="box-sizing: border-box; color: rgb(85, 85, 85); font-weight: bold;">return</span> <span class="dv" style="box-sizing: border-box; color: rgb(64, 160, 112);">0</span>;
}</code></pre><br><br><div>--<br><div>PO SU</div><div><a href="mailto:rcppmail@163.com" _src="mailto:rcppmail@163.com">rcppmail@163.com</a> </div><div>Majored in Statistic Shanghai JiaoTong University</div><div><br></div></div></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>