whiffelwink
(Whiffee Bollenbach)
1
Hi All,
I have a list that looks like this:
{{0, {0.}[0]}, {1, {309.56}[1]}, {2, {123.06}[2]}, {3, {-302.53}[3]}, {4, {-136.92}[4]}}
I want it to look like this:
{{0, 0}, {1, 309.56}, {2, 123.06}, {3, -302.53}, {4, -136.92}}
Can I get some advice?
thanks,
Whiffy
mthiel
(Marco Thiel)
2
I suppose that there is a problem with the code that generates that list, but here is how you can clean it up:
{#[[1]], #[[2, 0, 1]]} & /@
{{0, {0.}[0]}, {1, {309.56}[1]}, {2, {123.06}[2]}, {3, {-302.53}[3]}, {4, {-136.92}[4]}}
Cheers,
Marco
whiffelwink
(Whiffee Bollenbach)
3
Hey Marco, that’s like magic. Thanks.
Using ReplaceAll
{{0, {0.}[0]}, {1, {309.56}[1]}, {2, {123.06}[2]}, {3, {-302.53}[3]}, {4, {-136.92}[4]}} /.
{a_, {b_}[_]} :> {a, b}
(* {{0, 0.}, {1, 309.56}, {2, 123.06}, {3, -302.53}, {4, -136.92}} *)