Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #7296
| From | DrMajorBob <btreat1@austin.rr.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Table constructed from two lists |
| Date | 2011-12-17 07:44 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <jchh81$icq$1@smc.vnet.net> (permalink) |
| References | <201112161048.FAA06818@smc.vnet.net> |
Codes that work include:
list1 = {1, 2, 3};
list2 = {4, 5, 6};
Table[list1[[i]] + list2[[i]], {i, Range[Length[list1]]}]
{5, 7, 9}
Table[list1[[i]] + list2[[i]], {i, Length[list1]}]
{5, 7, 9}
Table[list1[[i]] + list2[[i]], {i, 3}]
{5, 7, 9}
OR SIMPLY:
list1 + list2
{5, 7, 9}
Bobby
On Fri, 16 Dec 2011 04:48:57 -0600, Alan Forrester <af17g11@gmail.com>
wrote:
> 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
>
--
DrMajorBob@yahoo.com
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: Table constructed from two lists DrMajorBob <btreat1@austin.rr.com> - 2011-12-17 07:44 +0000
csiph-web