One Hat Cyber Team
Your IP :
216.73.216.115
Server IP :
194.44.31.54
Server :
Linux zen.imath.kiev.ua 4.18.0-553.77.1.el8_10.x86_64 #1 SMP Fri Oct 3 14:30:23 UTC 2025 x86_64
Server Software :
Apache/2.4.37 (Rocky Linux) OpenSSL/1.1.1k
PHP Version :
5.6.40
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
Macaulay2
/
View File Name :
PackageTemplate.m2
-- -*- coding: utf-8 -*- newPackage( "PackageTemplate", Version => "1.0", Date => "April 28, 2005", Authors => { {Name => "Jane Doe", Email => "doe@math.uiuc.edu"} }, HomePage => "http://www.math.uiuc.edu/~doe/", Headline => "an example Macaulay2 package", Keywords => {"Documentation"}, AuxiliaryFiles => false -- set to true if package comes with auxiliary files ) -- Any symbols or functions that the user is to have access to -- must be placed in one of the following two lists export {"firstFunction", "secondFunction", "MyOption"} exportMutable {} firstFunction = method(TypicalValue => String) firstFunction ZZ := String => n -> ( if n == 1 then "Hello, World!" else "D'oh!" ) -- A function with an optional argument secondFunction = method( TypicalValue => ZZ, Options => {MyOption => 0} ) secondFunction(ZZ,ZZ) := o -> (m,n) -> ( if not instance(o.MyOption,ZZ) then error "The optional MyOption argument must be an integer"; m + n + o.MyOption ) secondFunction(ZZ,List) := o -> (m,n) -> ( if not instance(o.MyOption,ZZ) then error "The optional MyOption argument must be an integer"; m + #n + o.MyOption ) beginDocumentation() document { Key => PackageTemplate, Headline => "an example Macaulay2 package", EM "PackageTemplate", " is an example package which can be used as a template for user packages." } document { Key => {firstFunction, (firstFunction,ZZ)}, Headline => "a silly first function", Usage => "firstFunction n", Inputs => { "n" => ZZ => {} }, Outputs => { String => {} }, "This function is provided by the package ", TO PackageTemplate, ".", EXAMPLE { "firstFunction 1", "firstFunction 0" } } document { Key => secondFunction, Headline => "a silly second function", "This function is provided by the package ", TO PackageTemplate, "." } document { Key => (secondFunction,ZZ,ZZ), Headline => "a silly second function", Usage => "secondFunction(m,n)", Inputs => { "m" => {}, "n" => {} }, Outputs => { {"The sum of ", TT "m", ", and ", TT "n", ", and "} }, EXAMPLE { "secondFunction(1,3)", "secondFunction(23213123,445326264, MyOption=>213)" } } document { Key => MyOption, Headline => "optional argument specifying a level", TT "MyOption", " -- an optional argument used to specify a level", PARA{}, "This symbol is provided by the package ", TO PackageTemplate, "." } document { Key => [secondFunction,MyOption], Headline => "add level to result", Usage => "secondFunction(...,MyOption=>n)", Inputs => { "n" => ZZ => "the level to use" }, Consequences => { {"The value ", TT "n", " is added to the result"} }, "Any more description can go ", BOLD "here", ".", EXAMPLE { "secondFunction(4,6,MyOption=>3)" }, SeeAlso => { "firstFunction" } } TEST /// assert(firstFunction 1 === "Hello, World!") assert(secondFunction(1,3) === 4) assert(secondFunction(1,3,MyOption=>5) === 9) /// end -- Here place M2 code that you find useful while developing this -- package. None of it will be executed when the file is loaded, -- because loading stops when the symbol "end" is encountered. installPackage "PackageTemplate" installPackage("PackageTemplate", RemakeAllDocumentation=>true) check PackageTemplate -- Local Variables: -- compile-command: "make -C $M2BUILDDIR/Macaulay2/packages PACKAGES=PackageTemplate pre-install" -- End: