0
$\begingroup$

I have a set of lists in any iteration

list[1]={{0.129627, 0.74633, 0.93636, 0.328093, 0.323795},{0.24651, 0.15002, 0.341932, 0.0734819, 0.596785}, {0.381849, 0.798165, 0.847398, 0.619787, 0.663031}};

list[2]={{0.577629, 0.756704, 0.330815, 0.873377, 0.268678},{0.0456685, 0.320828, 0.541756, 0.116326, 0.683982}};

list[3]={{0.7495, 0.513172, 0.882195, 0.184402, 0.442981}};

As it can be seen the Dimensions of every list is different from another. But I wish to apply the PaddedForm[#,{2,3}] to each number contained in a list. The desired results must be for example:

list[1]={{0.130, 0.750, 0.940, ...},{0.250, .....}, {0.390,....}};
.etc

I tried PaddedForm[#,{2,3}]&list[1] but it does not work. As long as I am not sure to use Map or Mapthread because in each iteration, the Dimension of the list is changing!

$\endgroup$
5
  • 2
    $\begingroup$ You can Map at {-1} level, check 3rd argument of Map. Or create Listable function. $\endgroup$
    – Kuba
    Jun 22, 2017 at 10:53
  • $\begingroup$ btw, PaddedForm will work applied globally too, you just forgot @, check: PaddedForm[#, {2, 3}] &@list[1] $\endgroup$
    – Kuba
    Jun 22, 2017 at 11:03
  • $\begingroup$ I could understand what you mean $\endgroup$ Jun 22, 2017 at 11:03
  • $\begingroup$ Is there any way to not have a number as 0.000? because for another list which is not written here I have 0.000 after applying that. For a number that results in as 0.000 it should be written 0. $\endgroup$ Jun 22, 2017 at 11:06
  • $\begingroup$ You can use If. or replace 0 with "0" before PaddedForm $\endgroup$
    – Kuba
    Jun 22, 2017 at 11:09

1 Answer 1

3
$\begingroup$

PaddedForm maps automatically:

PaddedForm[list[1], {2, 3}] // TableForm

enter image description here

PaddedForm[{list[1], list[2], list[3]}, {2, 3}] //TableForm

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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