Quantcast
Channel: How can I transform the string to a list? - Mathematica Stack Exchange
Browsing all 5 articles
Browse latest View live

Answer by E. Chan-López for How can I transform the string to a list?

b1 = {a, b, c, d, e};b2 = {1, 2, 3, 4, 5};Using Thread and MapApply:#1 <> " - " <> #2 & @@@ Map[ToString, Thread[{b1, b2}], {2}]Result:{"a - 1", "b - 2", "c - 3", "d - 4", "e - 5"}

View Article



Answer by eldo for How can I transform the string to a list?

b1 = {a, b, c, d, e};b2 = {1, 2, 3, 4, 5};Some more possibilities:StringRiffle[#, "-"] & /@ Transpose[{b1, b2}]{"a-1", "b-2", "c-3", "d-4", "e-5"}Cases[Transpose[{b1, b2}], x : {_, _} :>...

View Article

Answer by Liming Zhou for How can I transform the string to a list?

Yeah, I found the answer, the last line I should use b4 = StringReplace[ToString /@ b3, "->" -> "-"].

View Article

Answer by Bob Hanlon for How can I transform the string to a list?

Post actual data and code rather than images.Clear["Global`*"];b1 = {a, b, c, d, e};b2 = {1, 2, 3, 4, 5};b3 = Thread[b1 -> b2];b4 = StringReplace[ToString /@ b3, "->" -> "-"](* {"a - 1", "b -...

View Article

Image may be NSFW.
Clik here to view.

How can I transform the string to a list?

As you can see from the picture, when I use StringReplace function, the list is converted to a string. How can I get the list form back? And the String "-" is necessary (Cuz I just know one way to...

View Article

Browsing all 5 articles
Browse latest View live




Latest Images