MathGroup Archive 1998

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

Search the Archive

Re: Null in output problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg13780] Re: Null in output problem
  • From: "Clemens Frey" <Clemens.Frey at uni-bayreuth.de>
  • Date: Mon, 24 Aug 1998 05:07:28 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

-----Urspr|ngliche Nachricht-----
Von: Tom Goetze <TomG at ultimatetech.com> An: mathgroup at smc.vnet.net
<mathgroup at smc.vnet.net> Datum: Mittwoch, 19. August 1998 11:30
Betreff: [mg13730] Null in output problem


>I'm writing a package and one of the functions I define in it outputs
>'2 Null'
>when called.
>
>this seems like a very strange output.  Of course, I seem to be able to
>run the exact same commands not in the package in several pieces and
>get a result (which is not '2 Null'). So that is also rather
>bothersome.
>
>Anybody have any suggestions as to why '2 Null' would be the output of a
>Sum call? Sum is the last piece of the Module that is being called.
>
>I would like to post some of the code, but it is rather long and messy.
>Of course, I will try to get it to do the same thing with a smaller
>more trivial piece of code, but I thought someone might have some good
>input on Null in output before I got to that stage.
>
>Thanks for any input,
>
>Tom Goetze
>

Tom:

No problem to produce a trap like this. Write exactly the following

f[x_] := (If[False, NeverExecuted]
Sum[i,{i,-1,2}])

into a package file (with the line break after If). Or, what's
equivalent:

f[x_] := Module[
{},
If[False, NeverExecuted]
Sum[i,{i,-1,2}]
]

again with the line break...

Load the package, and get for

f[whatever]

2 Null


So what? When the package is loaded, Mathematica understands the line
break after 'If ' as a multiplication operator (and gives you a
syntax::newl warning). Because the second case for 'If' is not defined,
you get a   Null*2   , what is our 'result' above.

regards
Clemens

PS This trap was produced with Mathematica 2.2, so hope it 'works'.


  • Prev by Date: Re: Importing CSV (comma separated values) files?
  • Next by Date: Please somebody, need help on weightmatching/minimizing problem!
  • Previous by thread: Null in output problem
  • Next by thread: Replacement rules in NonCommutative Algebra Package