MathGroup Archive 2011

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

Search the Archive

Re: package construction

  • To: mathgroup at smc.vnet.net
  • Subject: [mg117960] Re: package construction
  • From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
  • Date: Wed, 6 Apr 2011 05:11:46 -0400 (EDT)
  • References: <inerrp$jae$1@smc.vnet.net>

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... at 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



  • Prev by Date: Re: package construction
  • Next by Date: Re: Mathematica 8.01 and the CDF plug-in
  • Previous by thread: Re: package construction
  • Next by thread: Re: package construction