MathGroup Archive 2004

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

Search the Archive

Re: Telling Mathematica that a symbol is going to be a List?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg50838] Re: Telling Mathematica that a symbol is going to be a List?
  • From: p-valko at tamu.edu (Peter Valko)
  • Date: Thu, 23 Sep 2004 05:27:19 -0400 (EDT)
  • References: <ciqvop$in9$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

The error is happening, because an element of the list is referred to
before the list turns out to be a list.

To change the order of happenings, I would suggest:


m[d_]:= { {d[[1]], 0, 0}, {0, d[[2]], 0}, {0, 0, d[[3]]}  }
m[d/. d -> {d1, d2, d3} ]  // MatrixForm

Then the symbol d turns out to be a list of {d1,d2,d3} before it is
used in the evaluation of m and there will be no error message.

Peter

 


AES/newspost <siegman at stanford.edu> wrote in message news:<ciqvop$in9$1 at smc.vnet.net>...
> I want to define a function containing parameters that are going to be 
> elements in a list, e.g. something like
> 
>   m := { { d[[1]], 0, 0}, {0, d[[2]], 0}, {0, 0, d[[3]]}
> 
> but not define the list of values of  d  until later (and not put the 
> parameters in as explicit arguments of  m  just to keep the appearance 
> less cluttered and typing easier).
> 
> If I then give an input line
> 
>     m /. {d -> {d1, d2, d3} } // MatrixForm
> 
> I get "Part::partd" errors -- but the matrix then displays correctly.
> 
> I can of course just Off[] the errors -- but is there a better way.


  • Prev by Date: Integrating Feynman integrals in mathematica
  • Next by Date: Re: How to simplify to a result that is real
  • Previous by thread: Re: Telling Mathematica that a symbol is going to be a List?
  • Next by thread: Re: Telling Mathematica that a symbol is going to be a List?