3
$\begingroup$

I have the following list. I want to remove all commas and just be left with the elements of the set.

Tuples[{I, l}, 16]

{{I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I}, {I, I, I, I, I, I,
      I, I, I, I, I, I, I, I, I, l}, {I, I, I, I, I, I, I, I, I, I, I, I,
      I, I, l, I}, {I, I, I, I, I, I, I, I, I, I, I, I, I, I, l, l}, ....}

I would like something like:

{{IIIIIIIIIIIIIIII}, {IIIIIIIIIIIIIIIl}, {IIIIIIIIIIIIIIlI}, {IIIIIIIIIIIIIIll}, ....}
$\endgroup$
  • $\begingroup$ Can you show us what kind of final result you expect? $\endgroup$ – rafalc Jan 29 '19 at 12:17
  • $\begingroup$ @rafalc sure, please look at edited question $\endgroup$ – Maths Jan 29 '19 at 12:19
  • 2
    $\begingroup$ While it can be answered it appears to be a very strange request. Why do you need a symbol composed of 16 I-s? Maybe knowing the context we could help to solve your initial problem. $\endgroup$ – Kuba Jan 29 '19 at 12:24
  • $\begingroup$ does ToExpression /@ (StringRiffle[# , {"{", "", "}"}] & /@ Tuples[ToString /@ {I, l}, 16]) give what you need? $\endgroup$ – kglr Jan 29 '19 at 12:29
  • $\begingroup$ @kglr I haven't checked since I got the solution from Henrik, yours probably will work too but he beat you to it :) $\endgroup$ – Maths Jan 29 '19 at 12:32
5
$\begingroup$

Maybe this does what you want?

ToExpression[StringJoin /@ Map[ToString, Tuples[{I, l}, 16], {2}]]
| improve this answer | |
$\endgroup$
  • $\begingroup$ Thank you, indeed what I wanted. $\endgroup$ – Maths Jan 29 '19 at 12:28
  • $\begingroup$ You're welcome. $\endgroup$ – Henrik Schumacher Jan 29 '19 at 12:28
6
$\begingroup$

You can also do:

Symbol @* StringJoin /@ Tuples[{"I", "l"}, 16] 

% // Short

{IIIIIIIIIIIIIIII, IIIIIIIIIIIIIIIl, IIIIIIIIIIIIIIlI, IIIIIIIIIIIIIIll, << 65528 >>, llllllllllllllII, llllllllllllllIl, lllllllllllllllI, llllllllllllllll}

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.