Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #1491 > unrolled thread
| Started by | Jack L Goldberg 1 <jackgold@umich.edu> |
|---|---|
| First post | 2011-04-05 10:45 +0000 |
| Last post | 2011-04-06 09:14 +0000 |
| Articles | 4 — 4 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
package construction Jack L Goldberg 1 <jackgold@umich.edu> - 2011-04-05 10:45 +0000
Re: package construction "Sjoerd C. de Vries" <sjoerd.c.devries@gmail.com> - 2011-04-06 09:12 +0000
Re: package construction Alexey <lehin.p@gmail.com> - 2011-04-07 12:06 +0000
Re: package construction "Nasser M. Abbasi" <nma@12000.org> - 2011-04-06 09:14 +0000
| From | Jack L Goldberg 1 <jackgold@umich.edu> |
|---|---|
| Date | 2011-04-05 10:45 +0000 |
| Subject | package construction |
| Message-ID | <inerrp$jae$1@smc.vnet.net> |
Hi Folks; Something puzzles me. (Actually, a lot puzzles me but thats a story for my psychologist). Considering the incredible sophistication of Mathematica, why is it so mysteriously hard for a beginner to write a package and store it properly so that it can by accessed as easily as built-n packages? Has anyone put there mind to develop a template to make this stuff automatic. As a model, consider digital cameras, which have automatic mode for camera dummies like me, and a manual mode for the serious enthusiasts. I envisage a template in which the pertinent questions are asked of the developer: Name of package, name of commands for users and the syntax of these commands, the private code and etc. Mathematica then takes this info, does all the routine stuff needed to have a package ready to go. I suppose that this has not been done because it is far harder to do than I imagine it to be. But when I consider the sophistication of Resolve, I can't believe this is harder. Jack
[toc] | [next] | [standalone]
| From | "Sjoerd C. de Vries" <sjoerd.c.devries@gmail.com> |
|---|---|
| Date | 2011-04-06 09:12 +0000 |
| Message-ID | <inhaph$28b$1@smc.vnet.net> |
| In reply to | #1491 |
This is from tutorial/SettingUpMathematicaPackages. It doesn't look
that complicated to me...
BeginPackage["Collatz`"]
Collatz::usage =
"Collatz[n] gives a list of the iterates in the 3n+1 problem,
starting from n. The conjecture is that this sequence always
terminates."
Begin["`Private`"]
Collatz[1] := {1}
Collatz[n_Integer] := Prepend[Collatz[3 n + 1], n] /; OddQ[n] && n >
0
Collatz[n_Integer] := Prepend[Collatz[n/2], n] /; EvenQ[n] && n > 0
End[ ]
EndPackage[ ]
Cheers -- Sjoerd
On Apr 5, 12:45 pm, Jack L Goldberg 1 <jackg...@umich.edu> wrote:
> Hi Folks;
>
> Something puzzles me. (Actually, a lot puzzles me but thats a story
> for my psychologist). Considering the incredible sophistication of
> Mathematica, why is it so mysteriously hard for a beginner to write a pac=
kage
> and store it properly so that it can by accessed as easily as built-n
> packages?
>
> Has anyone put there mind to develop a template to make this stuff
> automatic. As a model, consider digital cameras, which have automatic
> mode for camera dummies like me, and a manual mode for the serious
> enthusiasts. I envisage a template in which the pertinent questions =
> are asked of the developer: Name of package, name of commands for
> users and the syntax of these commands, the private code and etc. Mathema=
tica
> then takes this info, does all the routine stuff needed to have a
> package ready to go.
>
> I suppose that this has not been done because it is far harder to do
> than I imagine it to be. But when I consider the sophistication of
> Resolve, I can't believe this is harder.
>
> Jack
[toc] | [prev] | [next] | [standalone]
| From | Alexey <lehin.p@gmail.com> |
|---|---|
| Date | 2011-04-07 12:06 +0000 |
| Message-ID | <ink9cj$gbh$1@smc.vnet.net> |
| In reply to | #1509 |
"Sjoerd C. de Vries" <sjoerd.c.devr...@gmail.com> wrote:
> This is from tutorial/SettingUpMathematicaPackages. It doesn't look
> that complicated to me...
>
> BeginPackage["Collatz`"]
>
> Collatz::usage =
> "Collatz[n] gives a list of the iterates in the 3n+1 problem,
> starting from n. The conjecture is that this sequence always
> terminates."
>
> Begin["`Private`"]
>
> Collatz[1] := {1}
> Collatz[n_Integer] := Prepend[Collatz[3 n + 1], n] /; OddQ[n] && n >
> 0
> Collatz[n_Integer] := Prepend[Collatz[n/2], n] /; EvenQ[n] && n > 0
>
> End[ ]
> EndPackage[ ]
The key thing that should be added here is that one must create (= use
in any way) all the symbols that must be accessible outside of the
package *before* Begin["`Private`"]. In this case they will be in the
Collatz` context (in the example above) and they will be in the
$ContextPath after loading of the package.
Alexey
[toc] | [prev] | [next] | [standalone]
| From | "Nasser M. Abbasi" <nma@12000.org> |
|---|---|
| Date | 2011-04-06 09:14 +0000 |
| Message-ID | <inhauf$2bt$1@smc.vnet.net> |
| In reply to | #1491 |
On 4/5/2011 3:45 AM, Jack L Goldberg 1 wrote: > Hi Folks; > > Something puzzles me. (Actually, a lot puzzles me but thats a story > for my psychologist). Considering the incredible sophistication of > Mathematica, why is it so mysteriously hard for a beginner to write a package > and store it properly so that it can by accessed as easily as built-n > packages? > > Has anyone put there mind to develop a template to make this stuff > automatic. As a model, consider digital cameras, which have automatic > mode for camera dummies like me, and a manual mode for the serious > enthusiasts. I envisage a template in which the pertinent questions > are asked of the developer: Name of package, name of commands for > users and the syntax of these commands, the private code and etc. Mathematica > then takes this info, does all the routine stuff needed to have a > package ready to go. > > I suppose that this has not been done because it is far harder to do > than I imagine it to be. But when I consider the sophistication of > Resolve, I can't believe this is harder. > > Jack > > I do not think a template is needed. It is really simple to make a package. Here is a small note, fyi http://12000.org/my_notes/how_to_write_package_in_mathematica/index.htm --Nasser
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web