0
$\begingroup$

Consider a asymmetric list which has been obtained from a NSolve command

{{{w -> 0.25}}, {{w -> 0.05}}, {{w -> 0.190065}, {w -> 
    0.0182686}}, {{w -> 0.0404842}, {w -> 0.0086731}}, {{w -> 
    0.156634}, {w -> 0.015429}, {w -> 0.00478921}}, {{w -> 
    0.0344873}, {w -> 0.00753932}, {w -> 0.00292085}}, {{w -> 
    0.134788}, {w -> 0.0134812}, {w -> 0.00424987}, {w -> 
    0.00191167}}, {{w -> 0.0302949}, {w -> 0.00671401}, {w -> 
    0.0026321}, {w -> 0.00131905}}, {{w -> 0.119177}, {w -> 
    0.012046}, {w -> 0.00383985}, {w -> 0.0017433}, {w -> 
    0.000948279}}, {{w -> 0.0271667}, {w -> 0.00608107}, {w -> 
    0.00240521}, {w -> 0.00121431}, {w -> 0.00070449}}}

How can I build a list using above list so that assign an integer to number of each inner list in an ordered way,where smallest number in each inner list(they are in descending order) get 0, for example for above list we must build a list as follows

{{{0}},{{0}},{{1},{0}},{{1},{0}},{{2},{1},{0}} and etc} 
$\endgroup$
2
$\begingroup$
Ordering /@ Values@list - 1

Reverse /@ Range /@ Length /@ list - 1

{{0}, {0}, {1, 0}, {1, 0}, {2, 1, 0}, {2, 1, 0}, {3, 2, 1, 0}, {3, 2, 1, 0}, {4, 3, 2, 1, 0}, {4, 3, 2, 1, 0}}

Or

Map[List, Ordering /@ Values@list, {2}] - 1

{{{0}}, {{0}}, {{1}, {0}}, {{1}, {0}}, {{2}, {1}, {0}}, {{2}, {1}, {0}}, {{3}, {2}, {1}, {0}}, {{3}, {2}, {1}, {0}}, {{4}, {3}, {2}, {1}, {0}}, {{4}, {3}, {2}, {1}, {0}}}

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.