home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / e / e032 / 3.ddi / FILES / PROGRAMM.PAK / SKELETON.M < prev    next >
Encoding:
Text File  |  1992-07-29  |  1.6 KB  |  66 lines

  1.  
  2. (*********************************************************************
  3.  
  4.         Adapted from
  5.         Roman E. Maeder: Programming in Mathematica,
  6.         Second Edition, Addison-Wesley, 1991.
  7.  
  8.  *********************************************************************)
  9.  
  10.  
  11. (* set up the package context, included any imports *)
  12.  
  13. BeginPackage["Skeleton`", "Package1`", "Package2`"]
  14.  
  15. Needs["Package3`"]    (* read in any hidden imports *)
  16.  
  17.  
  18. (* usage messages for the exported functions and the context itself *)
  19.  
  20. Skeleton::usage = "Skeleton.m is a package that does nothing."
  21.  
  22. Function1::usage = "Function1[n] does nothing."
  23.  
  24. Function2::usage = "Function2[n, (m:17)] does even more nothing."
  25.  
  26.  
  27. Begin["`Private`"]    (* begin the private context *)
  28.  
  29.  
  30. (* unprotect any system functions for which rules will be defined *)
  31.  
  32. protected = Unprotect[ Sin, Cos ]
  33.  
  34.  
  35. (* definition of auxiliary functions and local (static) variables *)
  36.  
  37. Aux[f_] := Do[something]
  38.  
  39. staticvar = 0
  40.  
  41.  
  42. (* error messages for the exported objects *)
  43.  
  44. Skeleton::badarg = "You twit, you called `1` with argument `2`!"
  45.  
  46.  
  47. (* definition of the exported functions *)
  48.  
  49. Function1[n_] := n
  50.  
  51. Function2[n_, m_:17] := n m /; n < 5 || Message[Skeleton::badarg, Function2, n]
  52.  
  53.  
  54. (* rules for system functions *)
  55.  
  56. Sin/: Sin[x_]^2 := 1 - Cos[x]^2
  57.  
  58.  
  59. Protect[ Evaluate[protected] ]      (* restore protection of system symbols *)
  60.  
  61. End[]         (* end the private context *)
  62.  
  63. Protect[ Function1, Function2 ]    (* protect exported symbols *)
  64.  
  65. EndPackage[]  (* end the package context *)
  66.