Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #7986
| From | Michael Stern <nycstern@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Can the code of a function obtain the names of its arguments? |
| Date | 2012-01-19 10:09 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <jf8q4v$3hc$1@smc.vnet.net> (permalink) |
I asked a related question five years ago. You can find the discussion
at http://forums.wolfram.com/mathgroup/archive/2006/Aug/msg00111.html
and linked pages.
Personally, if I wanted do something like this today, I would probably
change the inputs of the function so that the user passes both the
variable and a string.
So, if
a=2;b=3;c=4.
then Max[{a,b,c}] == 4
but if we want the variable name, we can do something like this:
myMax[valueAndName_List]:=First[SortBy[valueAndName, First]][[2]]
myMax[{2," a"}, {3, "b"}, {4," c"}]
="c"
On 1/18/2012 5:59 AM, James Stein wrote:
> I fear the answer is no, because I suspect that once values are bound to
> the names, there might seem to be scant use in keeping the names around.
>
> But I have a little debugging routine in mind I'd like to implement, so I'm
> hoping the answer is yes. (And if yes, how?)
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: Can the code of a function obtain the names of its arguments? Michael Stern <nycstern@gmail.com> - 2012-01-19 10:09 +0000
csiph-web