Q:

Row-bind specific rows that are in matrices in lists in R

I would like to row-bind specific rows that are rows in matrices in a list. For instance, I might have a list that has three matrices in them like:
> t

[[1]]
     [,1] [,2]
[1,]    1    3
[2,]    2    4

[[2]]
     [,1] [,2]
[1,]    5    7
[2,]    6    8

[[3]]
     [,1] [,2]
[1,]    9   11
[2,]   10   12

Then what I'd like to do is calculate the distances between the rows of these matrices, so if I could just write out
dist(rbind(t[[1]][1,], t[[2]][1,], t[[3]][1,]))
dist(rbind(t[[1]][2,], t[[2]][2,], t[[3]][2,]))

But in my case I could have much larger matrices and larger lists, so I was wondering if there is a way to row bind the corresponding rows of the matrices in the list in a quicker way?
Many thanks for any help!

A:

Sure, if l is your list, we may use, e.g., sapply in the following way:
t(sapply(l, `[`, 1,))
#      [,1] [,2]
# [1,]    1    3
# [2,]    5    7
# [3,]    9   11

which is short for
t(sapply(l, `[`, i = 1, j =))

or
t(sapply(l, function(ll) ll[1, ]))

