خرید بک لینک

Vote count: 0

I was wondering if there's a simple way to combine the functions of rapply(, how="replace") and mapply() --- to use mapply() on nested lists recursively.

For instance,

A = list(list(c(1,2,3), c(2,3,4)), list(c(4,3,2), c(3,2,1)))
B = list(list(c(1,2,3), c(2,3,4)), list(c(4,3,2), c(3,2,1)))

Let's say I want to apply function(x,y) x+y to all the corresponding elements in A and B and preserve the nested structure --- the desired result would be

result = list(list(c(2,4,6),c(4,6,8), list(c(8,6,4), c(6,4,2)))

I think this should be a mapply() analog of rapply(x, f, how="replace"), but couldn't figure out how to integrate them. Could anyone kindly give me some pointers on this?

Another quick question is, which is usually faster for intensive computation, nested lists or multidimentional arrays? Any Idea are very much appreciated!

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 30 خرداد 1395 ساعت: 19:11

صفحه بندی