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


Groups > comp.lang.forth > #52894

:Re: How to concatenate strings in different lists

From "Robert L." <No_spamming@noWhere_7073.org>
Newsgroups comp.lang.forth
Subject :Re: How to concatenate strings in different lists
Date 2016-11-27 09:50 +0000
Organization Aioe.org NNTP Server
Message-ID <o1ea8o$las$1@gioia.aioe.org> (permalink)

Show all headers | View raw


Joonas Liik wrote:

> > Hi, I am wondering how to concatenate corresponding strings in two lists,
> > assuming that the lists are of same length, e.g.
> >
> > val_1 = ['a', 'b', 'c']
> > val_2 = ['A', 'B', 'C']
> >
> > # concatenate corresponding strings in 'val_1' and 'val_2'
> > # and put results in another list 'val' so that
> > # val = ['aA', 'bB', 'cC']
> >
> > cheers
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> 
> one way to do it:
> 
> val = [''.join(pair) for pair in zip(val_1, val2)]

Ruby:

val_1 = %w(a b c)
val_2 = %w(A B C)

val_1.zip(val_2).map{|x,y| x+y}
    ==>["aA", "bB", "cC"]

In Forth?


-- 
Goyim were born only to serve us....  They will work, they will plow, they will
reap. We will sit like an effendi and eat. --- Rabbi Ovadia Yosef
web.archive.org/web/20101020044210/http://www.jpost.com/JewishWorld/JewishNews/Article.aspx?id=191782
archive.org/download/DavidDuke_videos/TopRabbiExposesJewishRacism-cybsdwjezqi.ogv

Back to comp.lang.forth | Previous | Next | Find similar | Unroll thread


Thread

:Re: How to concatenate strings in different lists "Robert L." <No_spamming@noWhere_7073.org> - 2016-11-27 09:50 +0000

csiph-web