4
$\begingroup$

I have this code:

text = "Today I woked up early"
cadena = InputForm[StringSplit[text]]
out:{"Today", "I", "woked", "up", "early"}

Why don't work this?

"\"#\"" & /@ {Monday, Tuesday, Wednesday, Thursday, Friday}
out:{"#", "#", "#", "#","#"}

The pure function only work with numbers?

$\endgroup$
  • 3
    $\begingroup$ You probably want either "\"" <> ToString[#] <> "\"" & /@ {Monday, Tuesday, Wednesday, Thursday, Friday} or ToString[#] & /@ {Monday, Tuesday, Wednesday, Thursday, Friday}. $\endgroup$ – Henrik Schumacher May 18 '18 at 22:42
  • $\begingroup$ Yes I may sound as a grammar nazi, but heck I could't resist it. Today I woke up early is more accurate :p $\endgroup$ – polfosol May 19 '18 at 9:04
10
$\begingroup$

Outside of quotes, # is shorthand for Slot[], but in quotes it's only a character. So, don't quote it:

"\"" <> SymbolName[#] <> "\"" & /@ {Monday, Tuesday, Wednesday,Thursday, Friday}
(* {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday"} *)
| improve this answer | |
$\endgroup$

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