MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Function in a package

  • To: mathgroup at smc.vnet.net
  • Subject: [mg42493] Function in a package
  • From: Roger Mason <rmason at sparky2.esd.mun.ca>
  • Date: Fri, 11 Jul 2003 02:57:54 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Hello,

I have written and tested successfully a function in a notebook.  On
putting the function in a package it ceases to work.

Here is the package:

BeginPackage["FredNoEDA`"]

TestPkgNoEDA::usage = "a test function.";

Begin["`Private`"]

TestPkgNoEDA[dat_, opts___?OptionQ] := Module[
    {n, Tow, Tow0},
    n = norm /. Flatten[{opts}] /. {norm -> fst};
    Tow = dat;
    If[
      n == fst, Tow0 = First[Tow]
      ];
    If[
      n == max, Tow0 = Tow[[
            Position[Tow, Max[Tow] ][[1, 1]]
            ]]
      ];
    Tow0
    ]

End[]

Protect[TestPkgNoEDA]

EndPackage[];

Here is the identical function (under a different name) from a notebook:

TestPkg[dat_, opts___?OptionQ] := Module[
    {n, Tow, Tow0},
    n = norm /. Flatten[{opts}] /. {norm -> fst};
    Tow = dat;
    If[
      n == fst, Tow0 = First[Tow]
      ];
    If[
      n == max, Tow0 = Tow[[
            Position[Tow, Max[Tow] ][[1, 1]]
            ]]
      ];
    Tow0
    ]

Here are some test data:

In[2]:=
tst = Table[x, {x, 1, 10}]

Out[2]=
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

Here are the results of a test:

Needs["FredNoEDA`"]

In[6]:=
TestPkgNoEDA[tst, norm -> max]

Out[6]=
1

In[11]:=
TestPkg[tst, norm -> max]

Out[11]=
10

Can anyone explain why the version of the function in the package returns
an incorrect result?

Thanks,
Roger Mason


  • Prev by Date: ListConvolve Padding Q?
  • Next by Date: Re: Ouput Form
  • Previous by thread: ListConvolve Padding Q?
  • Next by thread: Re: Function in a package