[Up] [Next] [Index]

# 1 The Example Package

### Sections

1. The main functions

This chapter describes the GAP package Example. As its name suggests it is an example of how to create a GAP package. It has little functionality except for being a package.

See Sections Installing the Example Package and Loading the Example Package for how to install and load the Example package.

If you are viewing this with on-line help, type:

    gap> ?>

to see the functions provided by the Example package.

## 1.1 The main functions

The following functions are available:

- `ListDirectory([`dir`]) F`

  lists the files in directory dir (a string) or the current directory if called with no arguments.

- `FindFile(` directory_name`,` file_name`) F`

  searches for the file file_name in the directory tree rooted at directory_name and returns the absolute path names of all occurrences of this file as a list of strings.

- `LoadedPackages() F`

  returns a list with the names of the packages that have been loaded so far.

- `Which(` prg`) F`

  returns the path of the program executed if `Exec(`prg`);` is called, e.g.

      gap> Which("date");
      "/bin/date"
      gap> Exec("date");
      Sun Oct  7 16:23:45 CEST 2001

- `WhereIsPkgProgram(` prg`) F`

  returns a list of paths of programs with name prg in the current packages loaded. Try:

      gap> WhereIsPkgProgram( "hello" );

- `HelloWorld() F`

  executes the C program `hello` provided by the Example package.

- `FruitCake V`

  is a record with the bits and pieces needed to make a boiled fruit cake. Its fields satisfy the criteria for `Recipe` (see Recipe);

- `Recipe(` cake`) M`

  displays the recipe for cooking cake, where cake is a record. The fields of cake recognised are `name` (a string giving the type of cake or cooked item), `ovenTemp` (a string), `cookingTime` (a string), `ingredients` (a list of strings each containing an `_` which is used to line up the entries and is replaced by a blank), `method` (a list of steps, each of which is a string or list of strings), and `notes` (a list of strings).

  [Up] [Next] [Index]