MathGroup Archive 1992

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

Search the Archive

Re: Table[ ...If[...i...] ,{i,...}]


The original problem was with

     Table[ v[i]'[t] == If[ x[i]>0,ex1,ex2] , {i,2,6} ]

I fooled with this a bit and think I see what's going on.  Apparently
mma does indeed substitute correctly for all the i's, but when it
discovers that the If evaluates to neither True nor False, sticks back
in the form of the If with i's in it rather than numbers.  Thus, this
seems to be a bug.  It occurs in an anomolous situation, to be sure,
but it is certainly not the expected behavior.

To see how I reached the above conclusion, try:

    Table[ If[ x[i], i, -i ], {i,2,6} ]
    Table[ If[ x[i], i, -i , i^2 ], {i,2,6} ]

and

    x[3] = True
    Table[ If[ x[i], i, -i ], {i,2,6} ]

Finally, as a workaround the following seems OK, though Lord knows why.

    Table[ If[ x[t], t, -t ]/.t->i, {i,2,6} ]

David Sibley
sibley at math.psu.edu






  • Prev by Date: Mathematica conference, Rotterdam
  • Next by Date: Re-indexing Mathematica
  • Previous by thread: Mathematica conference, Rotterdam
  • Next by thread: Re: Table[ ...If[...i...] ,{i,...}]