<div dir="ltr">Here's a really bare-bones version. Not very pretty or complete, but it does do the job. Could the 'unlist' part be converted to Rcpp?<div><br></div><div>THK</div><div><br></div><div><div>library(Rcpp)</div><div><br></div><div>code = '</div><div>SEXP test(List a)</div><div>{</div><div>  int l = Rf_length(a[0]);</div><div>  typedef std::vector<SEXP> svec;</div><div>  std::vector<svec> x(l);</div><div>  for (int i = 0; i != l; ++i)</div><div>    for (int j = 0; j != a.size(); ++j)</div><div>    {</div><div>      List b = a[j];</div><div>      x[i].push_back(b[i]);</div><div>    }</div><div>  return wrap(x);</div><div>}'</div><div><br></div><div>f = cppFunction(code = code)</div><div><br></div><div>res = lapply(f(list(list(1, 'a'), list(2, 'b'))), unlist)</div></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, May 2, 2015 at 1:18 PM, Dirk Eddelbuettel <span dir="ltr"><<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
On 2 May 2015 at 10:49, William Dunlap wrote:<br>
| Since translation from R to Rcpp is "seamless" I will leave that to you.<br>
<br>
</span>One problem is with the strongly typed nature of C++.  Rearranging dynamicly<br>
growing objects can be done.  I think I used Boost's variant type a few<br>
years.  I am sure there are other possibilities.  We should collect a few and<br>
compare.   But in C++ please :)<br>
<span class="HOEnZb"><font color="#888888"><br>
Dirk<br>
<br>
--<br>
<a href="http://dirk.eddelbuettel.com" target="_blank">http://dirk.eddelbuettel.com</a> | @eddelbuettel | <a href="mailto:edd@debian.org">edd@debian.org</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><a href="http://www.keittlab.org/" target="_blank">http://www.keittlab.org/</a></div></div>
</div>