I have a list genus, containing the list of genus group names for some fishes I work on derived from a column of imported data:
genus = tempData2[[All,2]] (* here explicitly specifying just the 4 of them for brevity*)
returning the list
{Synanciea, Pterois, Helicolenus, Sebastes}
If I examine the head using
Head[genus]
it returns List as expected
If I examine the contents of the list using
Table[Head[genus[[i]], {i, 1, Length[genus]}] (*fudging here that only 4 are used*)
it returns, as expected
{String, String, String, String}
I wish to simply take the individual strings and append a "" to each string as follow
genusname = Map[ReplaceAll[#&, #-> #<>""],genus]
This works as intended returning appending the blank character onto each original string in the list:
{Synancia , Pterois , Helicolenus , Sebastes }
or {"Synancia ","Pterois ", "Helicolenus ", "Sebastes "} (when //InputForm is used in postfix notation)
However, it also generates the Error ... "StringJoin: String expected at position 1 in #1"
If I try to explicitly convert the slot to String as follows
Map[ReplaceAll[# &, ToString[#]-> ToString[#]<>""], genus]
it returns no error, but it doesn't append the blank character at the end of each string in the list.
Obviously, I can suppress/ignore the error since the first effort works, but I am not sure why it occurs.
Can anyone explain why the first effort at Map returns the error but works, whereas the second effort of Map does not return an error but does not work (leaves each element of the list unchanged)?