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


Groups > comp.soft-sys.math.maple > #894

Re: Merging two lists

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Joe Riel <joer@san.rr.com>
Newsgroups comp.soft-sys.math.maple
Subject Re: Merging two lists
Date Sun, 15 Jun 2014 11:02:06 -0700
Organization A noiseless patient Spider
Lines 30
Message-ID <87ioo2dpb5.fsf@san.rr.com> (permalink)
References <lnj4fm$mon$1@news.albasani.net> <87mwdedphl.fsf@san.rr.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Injection-Info mx05.eternal-september.org; posting-host="15591ad2607da309a0d1a78a1d632bc7"; logging-data="14185"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19jR4/RJikf4Ex/kmXdDLf2"
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)
Cancel-Lock sha1:6dO+fwsLcvuXNhAIDoPbEitTEXc= sha1:QxKt9/ycgkvVL2gy7NLGRVKh5lc=
Xref csiph.com comp.soft-sys.math.maple:894

Show key headers only | View raw


Joe Riel <joer@san.rr.com> writes:

> rouben@shadow.(none) (Rouben Rostamian) writes:
>
>> Let's say I have the following two lists:
>> M := [a,b,c,d];
>> N := [e,f,g,h];
>>
>> I want to create a list of pairs, as in:
>> [[a, e], [b, f], [c, g], [d, h]]
>>
>> Here is how I do it:
>> [seq([M[i],N[i]], i=1..nops(M))];
>>
>> but that's too pedestrian.  Is there a neater and more elegant
>> way of doing this?
>
> (**) zip(`[]`,M,N);
>                   [[a, e], [b, f], [c, g], [d, h]]
>
> (**) `[]`~(M,N);   
>                   [[a, e], [b, f], [c, g], [d, h]]

also

(**) ListTools:-Transpose([M,N]);
                   [[a, e], [b, f], [c, g], [d, h]]

-- 
Joe Riel

Back to comp.soft-sys.math.maple | Previous | NextPrevious in thread | Find similar


Thread

Merging two lists rouben@shadow.(none) (Rouben Rostamian) - 2014-06-15 03:38 +0000
  Re: Merging two lists Axel Vogt <&noreply@axelvogt.de> - 2014-06-15 19:56 +0200
    Re: Merging two lists Rainer Rosenthal <r.rosenthal@web.de> - 2014-06-16 00:27 +0200
      Re: Merging two lists rouben@shadow.(none) (Rouben Rostamian) - 2014-06-16 20:17 +0000
  Re: Merging two lists Joe Riel <joer@san.rr.com> - 2014-06-15 10:58 -0700
    Re: Merging two lists Joe Riel <joer@san.rr.com> - 2014-06-15 11:02 -0700

csiph-web