Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #15410 > unrolled thread
| Started by | Itai Seggev <itais@wolfram.com> |
|---|---|
| First post | 2013-09-11 07:44 +0000 |
| Last post | 2013-09-12 06:21 +0000 |
| Articles | 2 — 2 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: basic namespace question, and access to BinarySearch Itai Seggev <itais@wolfram.com> - 2013-09-11 07:44 +0000
Re: basic namespace question, and access to BinarySearch Szabolcs Horvát <szhorvat@gmail.com> - 2013-09-12 06:21 +0000
| From | Itai Seggev <itais@wolfram.com> |
|---|---|
| Date | 2013-09-11 07:44 +0000 |
| Subject | Re: basic namespace question, and access to BinarySearch |
| Message-ID | <l0p70p$s2d$1@smc.vnet.net> |
On Tue, Sep 10, 2013 at 03:33:47AM -0400, Alan wrote:
> What is the proper way to get access to a package without adding that
> package to $ContextPath? If I use Needs, the package name is added to
> $ContextPath. (Of course I can remove items from $ContextPath.)
The short answer is there really isn't.
In[26]:= BeginPackage["foo`"]
In[29]:= EndPackage[]
In[30]:= $ContextPath
Out[30]= {"foo`", "DocuTools`", "InflationAdjust`", "FormulaData`", \
"QuantityUnits`", "WebServices`", "System`", "Global`"}
The moment the package loads it will be added to $ContextPath.
> Motivations: 1. I would like a cleaner namespace, and I don't mind using
> long names. 2. I would like to avoid the following warning when I want
> access just to Combinatorica`BinarySearch.
>
> General::compat: Combinatorica Graph and Permutations functionality has
> been superseded by preloaded functionality. The package now being
> loaded may conflict with this. Please see the Compatibility Guide for
> details.
>
> Follow-up questions:
>
> 1. Mathematiaca documentation currently suggests loading Combinatorica to get BinarySearch:
> http://reference.wolfram.com/mathematica/Combinatorica/ref/BinarySearch.html
> However if one does so, the above warning is given. It seems to me that
> this arrangement is buggy. Is it?
It is not ideal, but it is current intended. When version 8 was released, it
was deemed that the new Graph functionality was sufficiently advanced and
useful to release, but it did not replicate all the functions of
combinatorica. A decision was therefore made to keep Combinatorica but
deprecate it. With each release more functionality is built into the kernel
and eventually combinatorica will be removed.
> 2. I am surprised that BinarySearch is not in the Global context.
> Am I overlooking similar functionality under another name?
> The functionality I seek is the insertion point into a sorted
> list that would maintain insertion order, ideally with left/right
> option for when the inserted item matches a list item.
> (See Pythons binary_search, for example.)
I don't think that BinarySearch does what you want; it is much more similar to
Position for a list than a tree search algorithm. As for that, I'm not aware
of built in functionality. I think you'd have to roll your own solution, since
a graphs need not be trees, or even directed/acyclic. Others may know better
than I on this specific point.
> 3. I see that a BinarySearch function is in the GeometricFunctions package,
> which in turn is available by default. But I cannot find any related
> documentation. What do I make of this arrangement?
GeoemtricFunctions` is an internal package (which probably needs a better name
to make this clearer) which is used to support the plotting of splines and
such. It is not intended for public consumption.
--
Itai Seggev
Mathematica Algorithms R&D
217-398-0700
[toc] | [next] | [standalone]
| From | Szabolcs Horvát <szhorvat@gmail.com> |
|---|---|
| Date | 2013-09-12 06:21 +0000 |
| Message-ID | <l0rmgg$59n$1@smc.vnet.net> |
| In reply to | #15410 |
On 2013-09-11 07:44:25 +0000, Itai Seggev said:
> On Tue, Sep 10, 2013 at 03:33:47AM -0400, Alan wrote:
>> What is the proper way to get access to a package without adding that
>> package to $ContextPath? If I use Needs, the package name is added to
>> $ContextPath. (Of course I can remove items from $ContextPath.)
>
> The short answer is there really isn't.
>
> In[26]:= BeginPackage["foo`"]
>
> In[29]:= EndPackage[]
>
> In[30]:= $ContextPath
>
> Out[30]= {"foo`", "DocuTools`", "InflationAdjust`", "FormulaData`", \
> "QuantityUnits`", "WebServices`", "System`", "Global`"}
>
> The moment the package loads it will be added to $ContextPath.
I wouldn't say that there isn't a way…
Here's a link to the same question on Mathematica.SE (and the answer I like):
http://mathematica.stackexchange.com/a/5574/12
Block[{$ContextPath}, Needs["Combinatorica`"]]
I always load Combinatorica like this in version 8 and later.
I should note here that if you use the ToCombinatoricaGraph function
from the GraphUtilities package, it'll force-add Combinarotica` to the
context path. I did point out how this is rather inconvenient to
support@wolfram.com, but it wasn't fixed.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web