File: examples-doc.m2

package info (click to toggle)
macaulay2 1.25.05%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 172,152 kB
  • sloc: cpp: 107,824; ansic: 16,193; javascript: 4,189; makefile: 3,899; lisp: 702; yacc: 604; sh: 476; xml: 177; perl: 114; lex: 65; python: 33
file content (133 lines) | stat: -rw-r--r-- 4,052 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
--- status: Rewritten July 2020
--- author(s): Mahrud
--- notes: functions below are all defined in exam.m2

doc ///
Node
  Key
     capture
    (capture, Net)
    (capture, List)
    (capture, String)
    (capture, TestInput)
    [capture, UserMode]
    [capture, PackageExports]
  Headline
    evaluate Macaulay2 code and capture the output
  Usage
    (err, output) := capture str
  Inputs
    str:{Net,List,String,TestInput}
      the Macaulay2 code to be evaluated
    UserMode=>Boolean
      indicates whether currently loaded packages and exported symbols
      should be accessible while @TT "str"@ is being evaluated.
    PackageExports=>List
      of packages to be loaded before evaluating @TT "str"@.  The current package, as given by @TO currentPackage@, will be included.
  Outputs
    err:Boolean
      whether the evaluation was interrupted because of an error
    output:String
      the result of the evaluation
  Description
    Text
      This function evaluates the given Macaulay2 code within the same process in order to
      speed up tasks such as generating example results or checking the package tests.
    Example
      (err, output) = capture examples(resolution, Ideal) -* no-capture-flag *-
      assert not err
    Text
      If @TT "UserMode => false"@ given, the dictionaries available to the user will not be
      affected by the evaluation and @TO collectGarbage@ is called afterwards.

      Errors occurred while evaluating @TT "str"@ do not cause an error outside of @TT "capture"@.
    Example
      (err, output) = capture //// stderr << "Checking a false statement:" << endl; 1/0 ////
      assert err
    Text
      Certain examples or tests might not be compatible with @TT "capture"@. In such cases,
      use the string @CODE "-* no-capture-flag *-"@ somewhere within @TT "str"@ so that the
      code is run in a separate Macaulay2 subprocess instead.
  SeeAlso
    check
    examples

Node
  Key
     examples
    (examples, Thing)
    (examples, ZZ)
    (examples, List)
    (examples, DocumentTag)
  Headline
    list the examples in documentation
  Usage
    examples s
  Inputs
    s:Thing
      a descriptor for a documentation node, acceptable by @TO makeDocumentTag@
  Outputs
    :Net
      containing examples of code provided in the documentation of @TT "s"@
  Description
    Text
      The output is returned as a @TO Net@ of height 0, so the examples will be
      displayed indented by just white space, allowing immediate entry.
    Example
      ex := examples(resolution, Ideal)
      last capture ex -* no-capture-flag *-
    Text
      Alternatively, one could use @TO "print"@ to display them with no indentation.
    Example
      print ex
    Text
      If the input is an integer, then the examples will correspond to the
      documentation node with that index in the last call to @TO about@.
    Example
      about firstFunction
      examples 0
    Text
      If the input is a list, then the examples for all of its elements will be
      gathered into a single net.
    Example
      examples about firstFunction
  SeeAlso
    "reading the documentation"
    capture
    EXAMPLE
    help

Node
  Key
    EXAMPLE
   (EXAMPLE, PRE)
   (EXAMPLE, String)
   (EXAMPLE, VisibleList)
  Headline
    construct a hypertext item from a Macaulay2 input string
  Usage
    EXAMPLE x
  Inputs
    x:{String,VisibleList,PRE}
      containing strings or objects of class @TO "PRE"@
  Outputs
    :TABLE
      a table containing the examples
  Description
    Text
      If the table is included in the input provided to @TO "document"@, the input string will be
      evaluated by @TO "installPackage"@ and the result will be displayed in the documentation.
      Each object of class @TO "PRE"@ will be inserted unchanged into the documentation as example output.
      For example, the code
    Pre
      EXAMPLE { "1+1" }
    Text
      produces a display that looks like this:
    Code
      EXAMPLE { "1+1" }
  SeeAlso
    examples
    hypertext
    document
    installPackage
///