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: [mg50842] Re: Telling Mathematica that a symbol is going to be a List?
  • From: AES/newspost <siegman at stanford.edu>
  • Date: Thu, 23 Sep 2004 05:27:26 -0400 (EDT)
  • References: <ciqvop$in9$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Thanks for responses.  I appreciate that Mathematica works the way it does for 
good and sufficient (and often complex and subtle) reasons.  Hassles 
arise when the way Mathematica actually works conflicts with reasonable but 
incomplete mental models held by unsophisticated users like me.

(Such internal mental models are of course well known to be very 
significant in how people interact with computer programs.)

For example when I write

    m := {d[[1], 2 d[[2], 3d[[3]]}

my mental model is that the ":=" means that Mathematica will in effect put this 
line aside, "on a shelf" so to speak, until it needs it at some later 
point, at which point I will have already defined d as a List (and in 
any case, one might guess that the "d[[" syntax, which is pretty 
unambiguous, might have made this clear from the start).

This mental model, whether good or bad, succeeds in predicting that the 
fragment

    m := {d[[1], 2 d[[2], 3d[[3]]}

    d =  {1,2,3}

    s = m

will work OK, as indeed it does.  But the alternative fragment

    m := {d[[1], 2 d[[2], 3d[[3]]}

    s = m /. {d->{1,2,3}}

which my mental model, augmented by a model of how "->" works, says 
should be OK also.  Instead this fragment puts up error messages -- and 
then, ignoring its own trouble messages, goes ahead and works OK anyway!!

Not complaining here, nor even really seeking to understand why this 
happens -- just noting it, FWIW.


  • Prev by Date: Matrix differential equation
  • Next by Date: Re: Plot Question
  • Previous by thread: Re: Telling Mathematica that a symbol is going to be a List?
  • Next by thread: Re: Re: Telling Mathematica that a symbol is going to be a List?