Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #7295 > unrolled thread
| Started by | Tomas Garza <tgarza10@msn.com> |
|---|---|
| First post | 2011-12-17 07:42 +0000 |
| Last post | 2011-12-17 07:42 +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: Table constructed from two lists Tomas Garza <tgarza10@msn.com> - 2011-12-17 07:42 +0000
| From | Tomas Garza <tgarza10@msn.com> |
|---|---|
| Date | 2011-12-17 07:42 +0000 |
| Subject | Re: Table constructed from two lists |
| Message-ID | <jchh61$ic3$1@smc.vnet.net> |
There is something suitable for your query: MapThread
In[1]:= list1 = {1, 2, 3};list2 = {4, 5, 6}; MapThread[Pl=
us, {list1, list2}]
Out[2]= {5, 7, 9}
And, in general,
In[3]:= MapThread[f, {list1, list2}]
Out[3]= {f[1, 4], f[2, 5], f[3, 6]}
-Tomas
> Date: Fri, 16 Dec 2011 05:48:57 -0500
> From: af17g11@gmail.com
> Subject: Table constructed from two lists
> To: mathgroup@smc.vnet.net
>
> Hello
>
> I'd like to construct a table by making each element of the table a
> function of elements of a couple of lists I have specified, but I'm
> getting an error message that seems not to make any sense.
>
> So I have a couple of lists, like these
> list1 = {1,2,3}
> list2 = {4,5,6}
>
> My code for the table I want to construct from those lists is a bit
> like this:
> Tplus = [list1[i]+list2[i], {i, Range[Length[list1]]}].
>
> The error I get claims that i is not an integer or a list of integers,
> but Range[Length[list1]] is a list of integers.
>
> I would appreciate any ideas on what I'm doing wrong.
>
> Alan Forrester
>
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web