Function Works in Notebook NOT Package

• To: mathgroup at smc.vnet.net
• Subject: [mg86518] Function Works in Notebook NOT Package
• From: Andrew Beveridge <acbev at lanl.gov>
• Date: Thu, 13 Mar 2008 04:29:41 -0500 (EST)

```Any help would be appreciated.

I am using Mathematica 5.2.

I wrote a function that compares rows in a 2D array. If the
individual values of the rows are within some tolerance, for example
15%, it is considered a match.

Since I do not know many elements will be in each row, I had to write
a conditional for any value of elements. There is probably a better
way of doing this, any suggestions welcomed.

Anyway the following function works fine IF I evaluate it in a
Notebook. When I try to place it in a package file it does not work.
It appears the replacement rules are not working.

Why does not it work in the package file?

Function:

PreliminaryAlignment[x_List, percentTolerance_] :=
Module[ {ListLength,numLength, correctForm,numData,
blankTable,lowerLimit, upperLimit, conditionalTable,stringConditional},

correctForm =SameQ@@(Length/@x);
numData = Rest/@x;
ListLength=Length/@numData;
numLength = First[ListLength];
lowerLimit = ToString[ 1 - percentTolerance];
upperLimit = ToString[1 + percentTolerance];

If[correctForm=== False, Return[\$Failed],

blankTable =  "z:Table[_, {"<>ToString[numLength]<>"}]";
conditionalTable =
Table["LessEqual[Times["<>lowerLimit<>",Part[kkk, j, " <> ToString[i] <>
"]], Part[z," <> ToString[
i] <> "], Times["<>upperLimit<>", Part[kkk, j, "<>ToString[i]<>"]]]
"  , {i,1,numLength}]  ;

stringConditional =
MakeExpression[  blankTable <> "/; And[" <> \
StringReplace[ToString[conditionalTable]<> "]", {"{"\[Rule] " ",
"}"\[Rule] ""} ] ] ;

Union[ Table[Flatten[
Position[numData,  ReleaseHold[
stringConditional/.{kkk\[Rule] numData,j\[Rule]l} ] ] ],{l,1,
Length[numData]} ]  ]

]

]

Andrew C Beveridge
MS M888
Los Alamos National Laboratory
Los Alamos, NM  87545

505-665-2092
e-mail: acbev at lanl.gov

```

• Prev by Date: Re: Question on Sum[] function
• Next by Date: Mouth position with the GraphicsRow
• Previous by thread: Register for IMS 2008, 20-24 June 2008, Maastricht, the
• Next by thread: Re: Function Works in Notebook NOT Package