gap - reference manual · pdf filegap - reference manual release 4.8.10, 15-jan-2018 the gap...

1380
GAP - Reference Manual Release 4.8.10, 15-Jan-2018 The GAP Group The GAP Group Email: [email protected] Homepage: https://www.gap-system.org

Upload: vukhue

Post on 06-Feb-2018

232 views

Category:

Documents


8 download

TRANSCRIPT

  • GAP - Reference Manual

    Release 4.8.10, 15-Jan-2018

    The GAP Group

    The GAP Group Email: [email protected]: https://www.gap-system.org

    mailto://[email protected]://www.gap-system.org

  • GAP - Reference Manual 2

    CopyrightCopyright (1987-2018) for the core part of the GAP system by the GAP Group.

    Most parts of this distribution, including the core part of the GAP system are distributed under the terms ofthe GNU General Public License, see http://www.gnu.org/licenses/gpl.html or the file GPL in the etcdirectory of the GAP installation.

    More detailed information about copyright and licenses of parts of this distribution can be found in Section1.4 of this manual.

    GAP is developed over a long time and has many authors and contributors. More detailed information canbe found in Section 1.2 of this manual.

    http://www.gnu.org/licenses/gpl.html

  • Contents

    1 Preface 231.1 The GAP System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231.2 Authors and Maintainers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251.3 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251.4 Copyright and License . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261.5 Further Information about GAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

    2 The Help System 282.1 Invoking the Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282.2 Browsing through the Sections . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282.3 Changing the Help Viewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292.4 The Pager Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

    3 Running GAP 333.1 Command Line Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333.2 The gap.ini and gaprc files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383.3 Saving and Loading a Workspace . . . . . . . . . . . . . . . . . . . . . . . . . . . 413.4 Testing for the System Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . 423.5 Global Values that Control the GAP Session . . . . . . . . . . . . . . . . . . . . . 423.6 Coloring the Prompt and Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

    4 The Programming Language 454.1 Language Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454.2 Lexical Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464.3 Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 464.4 Whitespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474.5 Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484.6 Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484.7 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494.8 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 504.9 More About Global Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 514.10 Namespaces for GAP packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544.11 Function Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554.12 Comparisons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564.13 Arithmetic Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 574.14 Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

    3

  • GAP - Reference Manual 4

    4.15 Assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 594.16 Procedure Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604.17 If . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604.18 While . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 624.19 Repeat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 624.20 For . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 634.21 Break . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654.22 Continue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 654.23 Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 664.24 Return (With or without Value) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

    5 Functions 705.1 Information about a function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 705.2 Calling a function with a list argument that is interpreted as several arguments . . . 725.3 Calling a function with a time limit . . . . . . . . . . . . . . . . . . . . . . . . . . 735.4 Functions that do nothing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 745.5 Function Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 765.6 Naming Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

    6 Main Loop and Break Loop 796.1 Main Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 796.2 Special Rules for Input Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 816.3 View and Print . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 816.4 Break Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 856.5 Variable Access in a Break Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . 896.6 Error and ErrorCount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 916.7 Leaving GAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 926.8 Line Editing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 936.9 Editing using the readline library . . . . . . . . . . . . . . . . . . . . . . . . . . 966.10 Editing Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 996.11 Editor Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 996.12 Changing the Screen Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1006.13 Teaching Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100

    7 Debugging and Profiling Facilities 1027.1 Recovery from NoMethodFound-Errors . . . . . . . . . . . . . . . . . . . . . . . 1027.2 Inspecting Applicable Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1047.3 Tracing Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1047.4 Info Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1067.5 Assertions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1087.6 Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1097.7 Profiling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1107.8 Information about the version used . . . . . . . . . . . . . . . . . . . . . . . . . . 1187.9 Test Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1187.10 Debugging Recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1237.11 Global Memory Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124

  • GAP - Reference Manual 5

    8 Options Stack 1278.1 Functions Dealing with the Options Stack . . . . . . . . . . . . . . . . . . . . . . 1278.2 Options Stack an Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

    9 Files and Filenames 1309.1 Portability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1309.2 GAP Root Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1309.3 Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1319.4 File Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1339.5 Special Filenames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1349.6 File Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1349.7 File Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135

    10 Streams 13910.1 Categories for Streams and the StreamsFamily . . . . . . . . . . . . . . . . . . . . 13910.2 Operations applicable to All Streams . . . . . . . . . . . . . . . . . . . . . . . . . 14110.3 Operations for Input Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14110.4 Operations for Output Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14410.5 File Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14710.6 User Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14810.7 String Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14810.8 Input-Output Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14910.9 Dummy Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15110.10 Handling of Streams in the Background . . . . . . . . . . . . . . . . . . . . . . . . 15110.11 Comma separated files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152

    11 Processes 15311.1 Process and Exec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

    12 Objects and Elements 15612.1 Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1561