Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!newspump.sol.net!post2.nntp.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail From: Alexei Boulbitch Newsgroups: comp.soft-sys.math.mathematica Subject: Re: Building a matrix Date: Wed, 21 May 2014 08:14:26 +0000 (UTC) Sender: steve@smc.vnet.net Approved: Steven M. Christensen , Moderator Message-ID: Lines: 44 Organization: Time-Warner Telecom NNTP-Posting-Date: 21 May 2014 08:20:52 GMT NNTP-Posting-Host: 1479f091.news.twtelecom.net X-Trace: DXC=3_X7Y3]6d2>k9S[AF=UEb5C_A=>8kQj6=;[h;PUXBgb4W:Sk\@?4VC6EFiONJ7[Go6gX9<@2EVJ7: X-Complaints-To: abuse@twtelecom.net Xref: csiph.com comp.soft-sys.math.mathematica:16955 Given: m = [0,0,0} n = {1,2,3} how can I get a function to give: {{1,2,3,0,0,0,0,0,0}, {0,0,0,1,2,3,0,0,0}, {0,0,0,0,0,0,1,2,3}} ??? Bruno Hi, Bruno, You might do like the following, for example: Map[Flatten, Table[RotateRight[{n, m, m}, i], {i, 0, 2}]] Returning {{1, 2, 3, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 1, 2, 3, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 1, 2, 3}} As you want, or a bit shorter: Flatten /@ (RotateRight[{n, m, m}, #] & /@ {0, 1, 2}) Returning the same. Have fun, Alexei Alexei BOULBITCH, Dr., habil. IEE S.A. ZAE Weiergewan, 11, rue Edmond Reuter, L-5326 Contern, LUXEMBOURG Office phone : +352-2454-2566 Office fax: +352-2454-3566 mobile phone: +49 151 52 40 66 44 e-mail: alexei.boulbitch@iee.lu