MathGroup Archive 2002

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

Search the Archive

Checking Programming errors; a ?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg36616] Checking Programming errors; a ?
  • From: Jack Goldberg <jackgold at umich.edu>
  • Date: Fri, 13 Sep 2002 23:33:18 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Group:

I often run into this difficulty:  when designing a program, say as a
module, and testing it for various inputs, I get wrong answers.  What to
do?  I use a method that works for me but may not be the best available.
I want to show my method and then ask a question about how it can be
imporved.  (Oh yes, I abandoned Trace a long time ago!)

myFunction[f_] := Module[ {L1,L2,L3},

L1 = ... ;
L2 = ... ;
l3 = ... ;
	"final step"

		]

To see what went wrong, I use (*  *) selectively as follows:

Stage 1

myFunction[f_] := Module[ {L1,L2,L3},

L1 = ...  (*;
L2 = ... ;
L3 = ... ;
	"final step" *)

	]

Thus I see if L1 worked as expected.  The next step is to put  (* after L2
and see if this works.  I continue this til the bitter end and I usually
find my errors.

My question;   The process of moving  (*   *)  step by step through the
program is quite tedious when the code has lots more lines.  What I would
like is a "meta-program" which (like FoldList) does this job for me.  The
output of this "meta-program" is the list of outputs of each line in the
module, probably best printed as a column.
This sounds like Trace but my problem with Trace is it is terribly
difficult to read.  For the not-so-subtle programming I do, the only thing
I need is what expression is returned line by line.

Any advice?  All remarks are appreciated!

Jack



  • Prev by Date: Re: JLINK and Outputting a Plot
  • Next by Date: Re: trying to pull numbers out of a string from a file...
  • Previous by thread: AW: nth roots
  • Next by thread: Re: Checking Programming errors; a ?