help with Mathematica 3.0 'features' under NT
- To: mathgroup@smc.vnet.net
 - Subject: [mg10762] help with Mathematica 3.0 'features' under NT
 - From: calvitti@gulam.ces.cwru.edu
 - Date: Mon, 2 Feb 1998 00:44:58 -0500
 - Organization: Case Western Reserve University
 
I'm running Mathematica 3.0 under NT 4. 
1) To debug code, I insert Print[] statements within functions which I
comment out using (* ... *) when not needed (yes, I also comment out
the semicolons). However, the next time I open that notebook and such a
function is evaluated Mathematica flags it with syntax errors. When I
remove the (* ... *), the functions evaluate correctly, as they do
*even* after I reinsert the (* ... *). Clearly, I want to avoid doing
that everytime I open a notebook. Am I doing something wrong or is this
a known bug in 3.0?
2) Is there an elegant way for a default (or optional) argument to a
function to take a value which depends on another argument to the same
function if it's not explicitly passed? e.g. in "foo" I would like to
have "a" default to Length[lst].
  foo[lst_List, a_Integer : Length[lst_]] := lst[[a]]
but foo[{5,6,7,8}] returns "List", which implies that it's defaulting
"a" to 0. I've tried definding an optional argument with
  Options[foo] = {a -> Length[lst_]}
with no luck....Obviously, I can pass a : Infinity and set it
appropriately within the functions' body after a quick check, but it
doesn't seem like an elegant solution.
Thanks for the help.
 +---------------------------------+
 |          Alan Calvitti          |
 |       Control Engineering       |
 | Case Western Reserve University |
 +---------------------------------+