Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #9963 > unrolled thread
| Started by | James Stein <james@stein.org> |
|---|---|
| First post | 2012-05-05 08:16 +0000 |
| Last post | 2012-05-09 07:52 +0000 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Question about Initialization Cells James Stein <james@stein.org> - 2012-05-05 08:16 +0000
Re: Question about Initialization Cells David Reiss <dbreiss@gmail.com> - 2012-05-08 08:07 +0000
Re: Question about Initialization Cells Murray Eisenberg <murray@math.umass.edu> - 2012-05-09 07:52 +0000
| From | James Stein <james@stein.org> |
|---|---|
| Date | 2012-05-05 08:16 +0000 |
| Subject | Question about Initialization Cells |
| Message-ID | <jo2nke$mdk$1@smc.vnet.net> |
I downloaded the source code for a Wolfram Demonstrations Project; this one:
http://demonstrations.wolfram.com/ComparingAlgorithmsForTheTravelingSalesmanProblem/
The first three cells, all initialization cells, each contain a simple
one-liner, for example:
dist[p1_, p2_] := Norm[p1 - p2]
When I evaluate any of these cells, it appears to define the function, but
when I try (in a second, new notebook window) to evaluate the function
(e.g., to evaluate "dist[4.5]}), the function is undefined. It is blue i
the second window, even though it is black in the first window.
But If I type "dist[4,5]" in the demonstration project window itself, all
works as expected.
The demo project does not appear to be a package; 'dist' does not seem to
be private. What am I missing?
[toc] | [next] | [standalone]
| From | David Reiss <dbreiss@gmail.com> |
|---|---|
| Date | 2012-05-08 08:07 +0000 |
| Message-ID | <joak7v$nf8$1@smc.vnet.net> |
| In reply to | #9963 |
Evaluate the following in the notebook:
Options[EvaluationNotebook[], CellContext]
If the result is
{CellContext -> Notebook}
then that means that the notebook has been set so that any function
defined in it is defined in a Context unique to that notebook. If so,
then those functions will not be in the context path for Mathematica
to find them in another notebook and would need to be called there by
their full context path.
--David
On May 5, 4:16 am, James Stein <ja...@stein.org> wrote:
> I downloaded the source code for a Wolfram Demonstrations Project; this one:http://demonstrations.wolfram.com/ComparingAlgorithmsForTheTravelingS...
>
> The first three cells, all initialization cells, each contain a simple
> one-liner, for example:
> dist[p1_, p2_] := Norm[p1 - p2]
> When I evaluate any of these cells, it appears to define the function, but
> when I try (in a second, new notebook window) to evaluate the function
> (e.g., to evaluate "dist[4.5]}), the function is undefined. It is blue i
> the second window, even though it is black in the first window.
>
> But If I type "dist[4,5]" in the demonstration project window itself, all
> works as expected.
>
> The demo project does not appear to be a package; 'dist' does not seem to
> be private. What am I missing?
[toc] | [prev] | [next] | [standalone]
| From | Murray Eisenberg <murray@math.umass.edu> |
|---|---|
| Date | 2012-05-09 07:52 +0000 |
| Message-ID | <jod7oq$5gf$1@smc.vnet.net> |
| In reply to | #9963 |
That's something good to know: from time to time there have been posts
to this list asking about how to arrange exactly the same restriction --
typically by somebody used to another CAS system and expecting
definitions in one notebook, by default, to be confined to that
notebook's context.
On 5/8/12 4:06 AM, David Reiss wrote:
> Evaluate the following in the notebook:
>
> Options[EvaluationNotebook[], CellContext]
>
> If the result is
>
> {CellContext -> Notebook}
>
> then that means that the notebook has been set so that any function
> defined in it is defined in a Context unique to that notebook. If so,
> then those functions will not be in the context path for Mathematica
> to find them in another notebook and would need to be called there by
> their full context path.
>
> --David
>
>
> On May 5, 4:16 am, James Stein<ja...@stein.org> wrote:
>> I downloaded the source code for a Wolfram Demonstrations Project; this one:http://demonstrations.wolfram.com/ComparingAlgorithmsForTheTravelingS...
>>
>> The first three cells, all initialization cells, each contain a simple
>> one-liner, for example:
>> dist[p1_, p2_] := Norm[p1 - p2]
>> When I evaluate any of these cells, it appears to define the function, but
>> when I try (in a second, new notebook window) to evaluate the function
>> (e.g., to evaluate "dist[4.5]}), the function is undefined. It is blue i
>> the second window, even though it is black in the first window.
>>
>> But If I type "dist[4,5]" in the demonstration project window itself, all
>> works as expected.
>>
>> The demo project does not appear to be a package; 'dist' does not seem to
>> be private. What am I missing?
>
>
--
Murray Eisenberg murray@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web