Swap two lists in c# -


this question has answer here:

i have list of list (a matrix, sent via web.api http post matlab).

list<list<decimal>> mylist; 

the size of matrix nxm, how can swap lists? i.e.

mylist[i][j] --> mylist[j][i] 

in matlab operation mylist' or in mathematical context (transposing)

mylist^t  

you use linq achieve without for loop this:

var swapedlist =     mylist    .selectmany((l, i) => l.select((d, j) => new { i, j, d }))    .groupby(l=>l.j)    .select(l=>l.select(ll=>ll.d).tolist());    .tolist(); 

i hope helpful :)


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -