Function code need chang.

#1
My Original function is:
Expect=sum(listP[1,] * 0:t + listP[2,] * 0:t)
Loop is:
expnumber <- function(x)
{
n <- nrow(x)
m <- ncol(x)
sum(t(x) * (1 : m-1 ))
}
expnumber(listP)
However, I found out now my expect value want to be
Expect=sum(listP[1,] * 0:t + listP[2,] * 1:(t+1))
What should I do to my function now?
P is 2*1 Matrix, and expect value want to be 0*P0(1,0)+1*p0(2,0)+1*p1(1,1)+2*p1(2,1)......