CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

Views: 418346
1
2
1 The Example Package
3
4
This chapter describes the GAP package Example. As its name suggests it is
5
an example of how to create a GAP package. It has little functionality
6
except for being a package.
7
8
See Sections 2.1, 2.2 and 2.3 for how to install, compile and load the
9
Example package, or Appendix A for guidelines on how to write a GAP package.
10
11
If you are viewing this with on-line help, type:
12
13
 Example 
14
gap> ?Example package
15

16
17
to see the functions provided by the Example package.
18
19
20
1.1 The Main Functions
21
22
The following functions are available:
23
24
1.1-1 ListDirectory
25
26
ListDirectory( [dir] )  function
27
28
lists the files in directory dir (a string) or the current directory if
29
called with no arguments.
30
31
1.1-2 FindFile
32
33
FindFile( directory_name, file_name )  function
34
35
searches for the file file_name in the directory tree rooted at
36
directory_name and returns the absolute path names of all occurrences of
37
this file as a list of strings.
38
39
1.1-3 LoadedPackages
40
41
LoadedPackages( )  function
42
43
returns a list with the names of the packages that have been loaded so far.
44
All this does is execute
45
46
 Example 
47
gap> RecNames( GAPInfo.PackagesLoaded );
48

49
50
You might like to check out some of the other information in the GAPInfo
51
record (see 'Reference: GAPInfo').
52
53
1.1-4 Which
54
55
Which( prg )  function
56
57
returns the path of the program executed if Exec(prg); is called, e.g.
58
59
 Example 
60
gap> Which("date"); 
61
"/bin/date"
62
gap> Exec("date");
63
Fri 28 Jan 2011 16:22:53 GMT
64

65
66
1.1-5 WhereIsPkgProgram
67
68
WhereIsPkgProgram( prg )  function
69
70
returns a list of paths of programs with name prg in the current packages
71
loaded. Try:
72
73
 Example 
74
gap> WhereIsPkgProgram( "hello" );
75

76
77
1.1-6 HelloWorld
78
79
HelloWorld( )  function
80
81
executes the C program hello provided by the Example package.
82
83
1.1-7 FruitCake
84
85
FruitCake global variable
86
87
is a record with the bits and pieces needed to make a boiled fruit cake. Its
88
fields satisfy the criteria for Recipe (1.1-8).
89
90
1.1-8 Recipe
91
92
Recipe( cake )  operation
93
94
displays the recipe for cooking cake, where cake is a record satisfying
95
certain criteria explained here: its recognised fields are name (a string
96
giving the type of cake or cooked item), ovenTemp (a string), cookingTime (a
97
string), ingredients (a list of strings each containing an _ which is used
98
to line up the entries and is replaced by a blank), method (a list of steps,
99
each of which is a string or list of strings), and notes (a list of
100
strings). The global variable FruitCake (1.1-7) provides an example of such
101
a string.
102
103
104