The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Inactive » comp.soft-sys.math.mathematica

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: basic namespace question, and access to BinarySearch
Replies: 3   Last Post: Sep 12, 2013 2:21 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Itai Seggev

Posts: 61
Registered: 7/29/13
Re: basic namespace question, and access to BinarySearch
Posted: Sep 11, 2013 3:44 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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:
> 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

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.