[Date Index]
[Thread Index]
[Author Index]
Re: How can I concatenate elements
*To*: mathgroup at smc.vnet.net
*Subject*: [mg119860] Re: How can I concatenate elements
*From*: Murray Eisenberg <murray at math.umass.edu>
*Date*: Sun, 26 Jun 2011 06:26:17 -0400 (EDT)
*References*: <201106250928.FAA20229@smc.vnet.net>
*Reply-to*: murray at math.umass.edu
What you ask doesn't quite make sense! The entries in s1 are numbers;
the entries in s2 are symbols (or possibly symbols that have been given
values of some type or other - numbers, strings, lists, whatever).
So in the list you want as result, what, for example, does the entry 1c
even mean?
Do you want the _number_ 1 to be made into a one-character string, the
_symbol_ (or value of that symbol) c to be made into a string, and then
the two strings concatenated?
If so, the following will do it:
ss1 = ToString /@ s1;
ss2 = ToString /@ s2;
Flatten@Transpose@Outer[StringJoin, ss1, ss2]
If not, please explain further what the objects actually are and what
kind of entries you want s3 to have.
On 6/25/11 5:28 AM, Leandro Tenfen wrote:
> Hi,
>
> I have two lists:
>
> s1={1,2,3,4,5,6};
> s2={c,k};
>
> How can I concatenate elements of lists as follows:
>
> s3={1c,2c,3c,4c,5c,6c,1k,2k,3k,4k,5k,6k}
>
> Many Thanks!
>
>
--
Murray Eisenberg murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305
Prev by Date:
**Re: How can I write the input code for a comparison**
Next by Date:
**MPI-style message passing in pure Mathematica**
Previous by thread:
**Re: How can I concatenate elements**
Next by thread:
**Re: How can I concatenate elements**
| |