Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #3329 > unrolled thread
| Started by | Murray Eisenberg <murray@math.umass.edu> |
|---|---|
| First post | 2011-06-26 21:38 +0000 |
| Last post | 2011-06-26 21:38 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: How can I concatenate elements Murray Eisenberg <murray@math.umass.edu> - 2011-06-26 21:38 +0000
| From | Murray Eisenberg <murray@math.umass.edu> |
|---|---|
| Date | 2011-06-26 21:38 +0000 |
| Subject | Re: How can I concatenate elements |
| Message-ID | <iu88th$7cp$1@smc.vnet.net> |
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@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
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web