# Find left side of definitions?

Posted 25 days ago
241 Views
|
3 Replies
|
5 Total Likes
|
 How do I find the left side of the sets as the following example? o = {3, 2}; g = {9}; z = {5, 7}; f = {8, 11}; I'd like the result to be:I would like a code to do this even if I change or add more definitions to the sets list freely, for example adding two more sets or renaming some.My attempt to accomplish this (although believe that must have a much easier way): ClearAll["Global*"] o = {3, 2}; g = {9}; z = {5, 7}; f = {8, 11}; FromLetterNumber[ Select[Flatten[ Table[If[ Length[Flatten[ Take[Position[ Table[If[ FromDigits[ Flatten[ Take[Alphabet[] // ToExpression, {ii}]]] \[Element] Reals, 1], {ii, 1, 26}], 1], {ii}]]] < 2, Take[Position[ Table[If[ FromDigits[ Flatten[ Take[Alphabet[] // ToExpression, {ii}]]] \[Element] Reals, 1], {ii, 1, 26}], 1], {ii}]], {ii, 1, 26}]], NumberQ]] My achievement was partial, because the answer is not organized correctly in a way that I want (instead, it was in alphabetic sort). Is there any way to do that with a smarter code? Would someone please know how to help me?Thanks.
3 Replies
Sort By:
Posted 25 days ago
 This is shorter, but still not ordered in your preferred way. o = {3, 2}; g = {9}; z = {5, 7}; f = {8, 11}; #[[Flatten@Position[Symbol /@ #, _List]]] &@Names[$Context <> "*"] (* {"f", "g", "o", "z"} * ) Answer Posted 24 days ago  Thank you very much Tim, your code is very beautiful and powerful! I've tested your code for several special characters and different sets and the result was very very good. I'm very impressed! (while my code just works with the simple alphabet and numerical sets..) ClearAll["Global*"] a﹌ = {1, "ç", 9}; o\[Infinity]o = {3, 2/3}; \[BlackBishop]z = {9, "©"}; 軍￼ = {"5", 7}; \[FivePointedStar]\:f090 = {}; \[Checkmark]fꘚ = {"\[FivePointedStar]", 0}; \[Wolf]\[WolframLanguageLogoCircle] = {22.4}; ꧂4 = {0, 0, Sqrt[15]}; h\[WolframAlphaPrompt]7 = {17, "ij"}; #[[Flatten@Position[Symbol /@ #, _List]]] &@Names[$Context <> "*"] The character codes of the special characters I used in the test: (*{{169},{36557,65532},{43458,52},{97,65100},{104,62290,55},{111,8734, 111},{9821,122},{10003,102,42522},{9733,61584},{63264,61727}}*) Thank you.