next | previous | forward | backward | up | top | index | toc | Macaulay2 website
Macaulay2Doc > The Macaulay2 language > packages > needsPackage

needsPackage -- load a package if not already loaded



For example, to load the sample package FirstPackage:

i1 : notify = true

o1 = true
i2 : needsPackage "FirstPackage"
--opening database /usr/lib/Macaulay2/FirstPackage/cache/rawdocumentation-dcba-8.db
 -- beginDocumentation: using documentation database, skipping the rest of /usr/share/Macaulay2/FirstPackage.m2
--package "FirstPackage" loaded
--loaded /usr/share/Macaulay2/FirstPackage.m2

o2 = FirstPackage

o2 : Package
i3 : needsPackage "FirstPackage"

o3 = FirstPackage

o3 : Package

The second time the package was not reloaded.

See also

Ways to use needsPackage :

For the programmer

The object needsPackage is a method function with options.