# Crown a list of two sublists with ErrorBar without losing list structure

I have a list with two sublists of numbers, e.g.

Sigmaf = {{1,2,3},{3,4,5}};

... and I would like to crown each number with ErrorBar to yield:

{{ErrorBar[1], ErrorBar[2], ErrorBar[3]},{ErrorBar[3], ErrorBar[4], ErrorBar[5]}}

I have tried:

MapThread[ErrorBar[#] &, Flatten[Sigmaf]]

... as well as:

MapThread[ErrorBar[#] &, Sigmaf]

... without success. Any tips?

• Why use ErrorBar instead of Around? If you're using a more recent version of Mathematica, Around is the modern way to achieve this (and is better supported).
– ktm
Jun 26, 2020 at 1:02
• "Crown".......? Jun 26, 2020 at 17:46

1. Map ErrorBar at level -1:

Map[ErrorBar, Sigmaf, {-1}]

{{ErrorBar[1], ErrorBar[2], ErrorBar[3]},
{ErrorBar[3], ErrorBar[4],  ErrorBar[5]}}


2. ReplaceAll replacing number x with ErrorBar[x]:

Sigmaf /. x_?NumericQ :> ErrorBar[x]

{{ErrorBar[1], ErrorBar[2], ErrorBar[3]},
{ErrorBar[3], ErrorBar[4], ErrorBar[5]}}


3. Map ErrorBar on Flattened input list and use  InternalCopyListStructure:

InternalCopyListStructure[Sigmaf, ErrorBar /@ Flatten[Sigmaf]]

{{ErrorBar[1], ErrorBar[2], ErrorBar[3]},
{ErrorBar[3], ErrorBar[4], ErrorBar[5]}}

• The {-1} is equivalent to {2} for this particular case right? +1, as I wasn't aware of negative levels until today. Jun 25, 2020 at 23:56
• @flinty, thank you for the vote. Yes, {-1} is the same as {2} for this case. {-1} particularly convenient for sublists with different depths.
– kglr
Jun 26, 2020 at 0:11