MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Table constructed from two lists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg123748] Re: Table constructed from two lists
  • From: Armand Tamzarian <mike.honeychurch at gmail.com>
  • Date: Sat, 17 Dec 2011 02:45:29 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <jcf8dv$6us$1@smc.vnet.net>

On Dec 16, 10:01 pm, Alan Forrester <af17... at 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

Presumably the absence of Table at the head of your expression is not
present in your actual code? In any case you need to index using Part
which means using double brackets e.g. index[[i]]

But save yourself some time and just add the lists:

list1 + list2

Mike



  • Prev by Date: Re: Span Set nasty bug
  • Next by Date: Re: reliably sort?
  • Previous by thread: Re: Table constructed from two lists
  • Next by thread: Re: Table constructed from two lists