Re: Checking Programming errors; a ?
- To: mathgroup at smc.vnet.net
- Subject: [mg36672] Re: Checking Programming errors; a ?
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Wed, 18 Sep 2002 02:10:07 -0400 (EDT)
- Organization: Universitaet Leipzig
- References: <alub76$nld$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
- Sender: owner-wri-mathgroup at wolfram.com
Hi, does http://www.mathsource.com/Content/Enhancements/FrontEnd/0211-037 help you ? Regards Jens Jack Goldberg wrote: > > 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