Inputs to Functions - Can they be FORCED to be a predefined type?

• To: mathgroup at smc.vnet.net
• Subject: [mg88646] Inputs to Functions - Can they be FORCED to be a predefined type?
• From: Donald DuBois <donabc at comcast.net>
• Date: Sun, 11 May 2008 15:14:19 -0400 (EDT)

```Fri 9 May 2008

Hello All,

I have a strange problem for which there might well be no solution.

A simplified version of the problem is this.

I would like people who use my system to be able  to specify time durations though symbols.
For example:  "dN" where N is an integer means N days.  So "d10" means 10 days.
"wN" means N weeks.  So "w5" means 5 weeks which is translated into 5 * 5 = 25 days  (assuming 5 days
per week).   I want these string designations for time  (e.g. "d10" and "w5") to be an input to a function
(called myFunction) that the user has access to.   So far, so good.

But, for ease of use, I would prefer that the user not have to remember to use string quote symbols
around the duration symbol   (like "w5") as input to myFunction.
This is not a problem if the symbol w5 has not already been defined outside of myFunction.  It's head
will be Symbol and I can use ToString on it within myFunction so that it would be as if it had
been input as the string "w5".

BUT, if w5 has already been defined before it is used as input to myFunction, that is obviously a problem - .
myFunction won't recognize it as "w5".  Is there a way to define myFunction  in such a way that any
w5 [or any other duration symbol such as "d20" or "w12"]  given to it as input will be interpreted as the String "w5".

In other words, is there a way to define
the input to myFunction so that it FORCES any w5 given to it to be the String "w5" OR the UNDEFINED
Symbol w5  - even if it had been previously defined outside of myFunction?