Question concerning Mathematica packages

• To: mathgroup at smc.vnet.net
• Subject: [mg25839] Question concerning Mathematica packages
• From: phoward1 <phoward1 at ic3.ithaca.edu>
• Date: Sat, 28 Oct 2000 01:41:36 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```I am having a problem saving a package.  Every time I attempt to save the
package (using Save as Special, Package Format) I get all these \ that
subsequently prevent it from running properly.  I was hoping someone could
possibly let me know what I'm doing wrong.
Thank you
Patricia Howard

(*Patricia Howard*)

BeginPackage["FractalTree`"]
PointGenerator::"usage" = "PointGenerator[r1, r2, \[Theta], n] generates a \
list of the end points of the branches in a fractal tree with a right branch \
scaling ratio r1, left branch scaling ratio r2, angle \[Theta] and iteration \
number n."
LineGenerator::"usage" = "LineGenerator[r1, r2, \[Theta], n] generates a list
\
of lines segments of the branches in a fractal tree with a right branch \
scaling ratio r1, left branch scaling ratio r2, angle \[Theta] and iteration \
number n."
FractalTree::"usage" = "FractalTree[r1, r2, \[Theta], n] generates a picture \
of a fractal tree with a right branch scaling ratio r1, left branch scaling \
ratio r2, angle \[Theta] and iteration number n."
Begin["Private`"]
\!\(PointGenerator[r1_, r2_, \[Theta]_, n_] :=
Module[{points, temppoints, wR, wL, a, x,
y},  (*Local\ variables*) \[IndentingNewLine]points = {{0, 0}, {0,
1}};  (*Enters\ the\ endpoints\ of\ the\ trunk\ into\ a\ list\
*) \[IndentingNewLine]temppoints = {};  (*Creates\ a\ list\ to\ temporarily\ \
store\ points\ in\ later*) \[IndentingNewLine]wL[x_,
y_] := {r2\ x\ Cos[\[Theta]] - r2\ y\ Sin[\[Theta]],
r2\ x\ Sin[\[Theta]] + r2\ y\ Cos[\[Theta]] +
1};  (*Affine\ transformation\ for\ the\ left\ branches\
*) \[IndentingNewLine]wR[x_,
y_] := {r1\ x\ Cos[\(-\[Theta]\)] - r1\ y\ Sin[\(-\[Theta]\)],
r1\ x\ Sin[\(-\[Theta]\)] + r1\ y\ Cos[\(-\[Theta]\)] +
1};  (*Affine\ transformation\ for\ the\ right\ branches\
*) \[IndentingNewLine]Do[ (*Begins\ a\ loop\ that\ iterates\ at\ each\ \
branching\ stage*) \[IndentingNewLine]Do[ (*Begins\ a\ loop\ that\ evaluates\
\
the\ end\ points\ of\ the\ branches\ from\ the\ last\ stage\
*) \[IndentingNewLine]a =
Length[points] - \((j -
1)\);  (*Assigns\ the\ variable\ a\ to\ one\ of\ the\ last\
\
2\^i\ points\ in\ the\ list\ points*) \[IndentingNewLine]x =
points[\([a, 1]\)];  (*Assigns\ the\ variable\ x\ to\ the\ x -
coordinate\ of\ the\ point\ a*) \[IndentingNewLine]y =
points[\([a, 2]\)];  (*Assigns\ the\ variable\ y\ to\ the\ y -
coordinate\ of\ the\ point\ a*) \[IndentingNewLine]temppoints =
Append[temppoints,
wR[x, y]];  (*Evaluates\ wR\ at\ the\ point\ a\ and\ add\ the\ \
point\ to\ the\ end\ of\ the\ list\ \
temppoints*) \[IndentingNewLine]temppoints =
Append[temppoints,
wL[x, y]]; (*Evaluates\ wL\ at\ the\ point\ a\ and\ add\ the\ \
point\ to\ the\ end\ of\ the\ list\ temppoints*) \[IndentingNewLine], {j, 1,
2\^i} (*Inner\ Do[]\ loop\ iterator, \ assigns\ j\ to\ 1,
2,  ... ,
2\^i\ where\ 2\^i\ is\ half\ the\ number\ of\ branches\ at\ stage\
\ i*) \[IndentingNewLine]];  (*Ends\ the\ inner\ Do[]\ loop\
*) \[IndentingNewLine]points =
Join[points,
temppoints];  (*Adds\ the\ list\ temppoints\ to\ the\ end\ of\ \
the\ list\ points*) \[IndentingNewLine]temppoints = {}; (*Resets\ temppoints\
\
to\ empty*) \[IndentingNewLine], {i, 0,
n - 1} (*Outer\ Do[]\ loop\ iterator, \
assigns\ i\ to\ a\ value\ from\ 0\ to\ n -
1\ which\ is\ the\ stage\ of\ the\ tree \((note\ at\ stage\ 1, \
i = 0)\)*) \[IndentingNewLine]];  (*Ends\ outer\ Do[]\ loop\
*) \[IndentingNewLine]Return[
points] (*Assigns\ the\ list\ points\ to\ the\ function\ \
PointGenerator\ for\ later\ use*) \[IndentingNewLine]]\)
\!\(LineGenerator[r1_, r2_, \[Theta]_, n_] :=
Module[{points, connectpoints,
stage},  (*Local\ variables*) \[IndentingNewLine]points =
PointGenerator[r1, r2, \[Theta],
n];  (*Assigns\ the\ variable\ points\ to\ the\ list\ generated\ by\
\ PointGenerator*) \[IndentingNewLine]connectpoints = {Line[{points[\([1]\)],
points[\([2]\)]}]};  (*Creates\ a\ list\ connectpoints\ \
containing\ a\ line\ representing\ the\ trunk*) \[IndentingNewLine]Do[ \
(*Begins\ a\ loop\ that\ pairs\ and\ connects\ \
points*) \[IndentingNewLine]stage =
1;  (*Assigns\ the\ variable\ stage\ a\ value\ of\ 1, \
note\ stage\ is\ reset\ to\ 1\ at\ every\ iteration\
*) \[IndentingNewLine]While[ (*Begins\ a\ loop\ that\ finds\ the\ stage\ of\ \
a\ particular\ point\ in\ points*) \[IndentingNewLine]k >
2\^stage,  (*Condition : \
evaluates\ expression\ while\ k >
2\^stage*) \[IndentingNewLine]stage +=
1 (*Adds\ 1\ to\ stage\ if\ the\ condition\ is\ true\
*) \[IndentingNewLine]];  (*Ends\ While[]\ \
loop*) \[IndentingNewLine]connectpoints =
Join[connectpoints,  (*Adds\ the\ following\ list\ to\ the\ end\ of\
\ the\ list\ connectpoints*) \[IndentingNewLine]{Line[{points[\([k]\)],
points[\([k +
2\^\(stage - 1\)]\)]}],  (*First\ \(element : \
connects\ the\ point\ in\ postion\ k\ to\ the\ point\ in\
\
position\ k + 2\^\(stage - 1\)\)*) \[IndentingNewLine]Line[{points[\([k]\)],
points[\([k + 2\^stage]\)]}]}] (*Second\ \(element : \
connects\ the\ point\ in\ postion\ k\ to\ the\ point\ in\ \
position\ k + 2\^stage\)*) \[IndentingNewLine], {k, 2,
2\^n} (*Do[]\ loop\ iterator, \
assigns\ k\ to\ a\ value\ from\ 2\ to\ 2\^n\ which\ is\ the\ \
position\ in\ the\ list\ points\ of\ the\ starting\ point\ of\ a\ line\
*) \[IndentingNewLine]];  (*End\ Do[]\ loop*) \[IndentingNewLine]Return[
connectpoints] (*Assigns\ the\ list\ connectpoints\ to\ the\ function\
\ LineGenerator\ for\ later\ use*) \[IndentingNewLine]]\)
FractalTree[r1_, r2_, \[Theta]_, n_] :=
Module[{connectpoints},(*Local variables*)
connectpoints =
LineGenerator[r1, r2, \[Theta],
n];(*Assigns the variable connectpoints to the list generated by \
LineGenerator*)
Show[Graphics[connectpoints], AspectRatio -> Automatic,
PlotRange ->
All];(*Graphs the lines in the list connectpoints on one set of axes*)
\

]
End[]
EndPackage[]

```

• Prev by Date: Re: Vertical Tangents
• Next by Date: Re: FULLSIMPLIFY and Subscripted Variables