# Using List to create lists of strings: difference(s) between two one-line codes?

In the Virtual Book of Mathematica, there is a simple example to show how to create lists of strings by List:

List[{"a", "b", "c"}, {"you", "are", "good"}]


here " " indicates these strings, which is easy to understand.

However, if we use

List[{a, b, c}, {you, are, good}]


instead, we can find that both codes give the same result:

{{a, b, c}, {you, are, good}}

So my questions:

1. Whether or not the two codes are different with respect to the output of their results. If yes, what is(are) the difference(s)?

2. Whether or not the two codes are exactly the same in the context of a program?

• Move your cursor into the output cell and type something to reveal the quotes. Mathematica hides quotes in outputs by default (I don't know why) Dec 10, 2018 at 11:48
• Your first List creates a list of strings, the second a list of actual undefined variables Dec 10, 2018 at 11:49
• Output cells, you see the results in, have ShowStringCharacters->False so no, they are not the same. Take a loot at FullForm. p.s. List[1] vs {1} is only a syntactic sugar, again compare with FullForm.
– Kuba
Dec 10, 2018 at 11:50
• With respect to question 2, if you're ever wondering if two things are precisely identical in Mathematica, SameQ (===) works for that. Dec 10, 2018 at 12:06
• @Kuba Thanks a lot. Could you suggest how do I see that output cells have the property of ShowStringCharacters->False?
– lxy
Dec 10, 2018 at 13:59

la = List[{"a", "b", "c"}, {"you", "are", "good"}];

lb = List[{a, b, c}, {you, are, good}];

Head @ #[[1, 1]] & /@ {la, lb}


{String, Symbol}

Apply[SameQ][%]


False

With

l1 = List[{"a", "b", "c"}, {"you", "are", "good"}];
l2 = List[{a, b, c}, {you, are, good}];


1. Whether or not the two codes are different with respect to the output of their results. If yes, what is(are) the difference(s)?

One way to see that they are different is the following:

l1 // FullForm
l2 // FullForm


Addressing the comment: Could you suggest how do I see that output cells have the property of ShowStringCharacters->False

From the docs we read:

ShowStringCharacters is an option for Cell that specifies whether to display " when a string is entered.


So, you can set it to True for both lists and check for which one you will get the "" like so:

ExpressionCell[l1, "Output", ShowStringCharacters -> True]
ExpressionCell[l2, "Output", ShowStringCharacters -> True]


2.Whether or not the two codes are exactly the same in the context of a program?

When you run

l1 === l2


you get