Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #3312

Re: How can I concatenate elements

From Murray Eisenberg <murray@math.umass.edu>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: How can I concatenate elements
Date 2011-06-26 10:30 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <iu71n8$1bj$1@smc.vnet.net> (permalink)
References <201106250928.FAA20229@smc.vnet.net>

Show all headers | View raw


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 comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: How can I concatenate elements Murray Eisenberg <murray@math.umass.edu> - 2011-06-26 10:30 +0000

csiph-web