Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #15017 > unrolled thread
| Started by | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| First post | 2013-06-26 05:00 +0000 |
| Last post | 2013-06-28 07:48 +0000 |
| Articles | 4 — 4 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: What is f[1]? Advanced question Bob Hanlon <hanlonr357@gmail.com> - 2013-06-26 05:00 +0000
Re: What is f[1]? Advanced question amannucci <Anthony.J.Mannucci@jpl.nasa.gov> - 2013-06-27 10:25 +0000
Re: What is f[1]? Advanced question David Bailey <dave@removedbailey.co.uk> - 2013-06-28 07:48 +0000
Re: What is f[1]? Advanced question John Doty <noqsiaerospace@gmail.com> - 2013-06-28 07:48 +0000
| From | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| Date | 2013-06-26 05:00 +0000 |
| Subject | Re: What is f[1]? Advanced question |
| Message-ID | <kqdshl$n34$1@smc.vnet.net> |
Do[x[i] = i/10., {i, 1, 3}]
x is a user-defined function whose domain is just the integers 1, 2, and
3. Like all functions, its Head is Symbol.
Head /@ {x, Exp, Mean}
{Symbol, Symbol, Symbol}
The function definitions are stored in the DownValues of the symbol
DownValues[x]
{HoldPattern[x[1]] :> 0.1, HoldPattern[x[2]] :> 0.2, HoldPattern[x[3]] :>
0.3}
Like any function, when given an argument outside of its defined domain, it
returns unevaluated.
x[4]
x[4]
Bob Hanlon
On Tue, Jun 25, 2013 at 9:14 PM, amannucci
<Anthony.J.Mannucci@jpl.nasa.gov>wrote:
> I have found a Mathematica program with the following construct:
> x[1]=0.1
> x[2]=0.2
> x[3]=0.3
>
> or
> Do[x[i]=i/10.,{i,1,3}]
>
> x is not a function. It is not a list. What is it? If I query x thus:
> ?x
>
> the answer is just what I have written above. Mathematica knows about
> x[1], x[2], etc. How does Mathematica know about the "elements" of x?
>
> In some other sense, I could have written:
> y1 = 0.1
> y2 = 0.2
> y3 = 0.3
>
> But
> ?y
>
> obviously gives a different result (just returns y).
>
> Thank you.
>
>
[toc] | [next] | [standalone]
| From | amannucci <Anthony.J.Mannucci@jpl.nasa.gov> |
|---|---|
| Date | 2013-06-27 10:25 +0000 |
| Message-ID | <kqh3u0$2im$1@smc.vnet.net> |
| In reply to | #15017 |
Thanks. This is very helpful. I remain puzzled by this:
u // FullForm
FullForm[Symbol["u"]]
FullForm[Unevaluated[Symbol["u"]]
Head[u]
FullForm[{1, 2, 3}]
Head[{1, 2, 3}]
In other words, Head and FullForm seem consist for the list, and inconsistent for the variable u. u's full form is just, literally "u", not Symbol["u"]. But the list's FullForm starts with "List". Head of Symbol["u"] is not Symbol, but "u". What gives?
[toc] | [prev] | [next] | [standalone]
| From | David Bailey <dave@removedbailey.co.uk> |
|---|---|
| Date | 2013-06-28 07:48 +0000 |
| Message-ID | <kqjf3g$9eo$1@smc.vnet.net> |
| In reply to | #15025 |
On 27/06/2013 11:25, amannucci wrote:
> Thanks. This is very helpful. I remain puzzled by this:
>
> u // FullForm
> FullForm[Symbol["u"]]
> FullForm[Unevaluated[Symbol["u"]]
> Head[u]
>
> FullForm[{1, 2, 3}]
> Head[{1, 2, 3}]
>
> In other words, Head and FullForm seem consist for the list, and inconsistent for the variable u. u's full form is just, literally "u", not Symbol["u"]. But the list's FullForm starts with "List". Head of Symbol["u"] is not Symbol, but "u". What gives?
>
>
I don't think there is too much mystery here - FullForm would simply be
too clumsy if it expanded symbols into Symbol constructs. As it is,
FullForm is incredibly useful.
I wish there was also a variant that did not evaluate its argument. True
one can write:
expression //Hold//FullForm
but the expression gets contaminated with Hold.
David Bailey
http://www.dbaileyconsultancy.co.uk
[toc] | [prev] | [next] | [standalone]
| From | John Doty <noqsiaerospace@gmail.com> |
|---|---|
| Date | 2013-06-28 07:48 +0000 |
| Message-ID | <kqjf44$9eq$1@smc.vnet.net> |
| In reply to | #15017 |
On Thursday, June 27, 2013 4:25:04 AM UTC-6, amannucci wrote:
> Thanks. This is very helpful. I remain puzzled by this:
>
>
>
> u // FullForm
>
> FullForm[Symbol["u"]]
>
> FullForm[Unevaluated[Symbol["u"]]
>
> Head[u]
>
>
>
> FullForm[{1, 2, 3}]
>
> Head[{1, 2, 3}]
>
>
>
> In other words, Head and FullForm seem consist for the list, and inconsistent for the variable u. u's full form is just, literally "u", not Symbol["u"]. But the list's FullForm starts with "List". Head of Symbol["u"] is not Symbol, but "u". What gives?
If FullForm did what you expected, its output would be infinite, because every expression in Mathematica has a head. Remember that the head of an expression is itself an (arbitrary!) expression. So, FullForm "bottoms out" when further expansion would expose an elementary head like Symbol or Integer.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web