Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/1998/REC-html40-19980424/loose.dtd">
- <html lang="en">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>PicoLisp Reference</title>
- <link rel="stylesheet" href="doc.css" type="text/css">
- </head>
- <body>
- <a href="mailto:abu@software-lab.de">abu@software-lab.de</a>
- <p align=right>
- <i>Perfection is attained</i><br>
- <i>not when there is nothing left to add</i><br>
- <i>but when there is nothing left to take away</i><br>
- <i>(Antoine de Saint-Exupéry)</i><br>
- <h1>The PicoLisp Reference</h1>
- <p align=right>(c) Software Lab. Alexander Burger
- <p>This document describes the concepts, data types, and kernel functions of the
- <a href="http://software-lab.de/down.html">PicoLisp</a> system.
- <p>This is <i>not</i> a Lisp tutorial. For an introduction to Lisp, a
- traditional Lisp book like "Lisp" by Winston/Horn (Addison-Wesley 1981) is
- recommended. Note, however, that there are significant differences between
- PicoLisp and Maclisp (and even greater differences to Common Lisp).
- <p>Please take a look at the <a href="tut.html">PicoLisp Tutorial</a> for an
- explanation of some aspects of PicoLisp, and scan through the list of <a
- href="faq.html">Frequently Asked Questions (FAQ)</a>.
- <p><ul>
- <li><a href="#intro">Introduction</a>
- <li><a href="#vm">The PicoLisp Machine</a>
- <ul>
- <li><a href="#cell">The Cell</a>
- <li><a href="#data">Data Types</a>
- <ul>
- <li><a href="#number">Numbers</a>
- <li><a href="#symbol">Symbols</a>
- <ul>
- <li><a href="#nilSym">NIL</a>
- <li><a href="#internal">Internal Symbols</a>
- <li><a href="#transient">Transient Symbols</a>
- <li><a href="#external">External Symbols</a>
- </ul>
- <li><a href="#lst">Lists</a>
- </ul>
- <li><a href="#mem">Memory Management</a>
- </ul>
- <li><a href="#penv">Programming Environment</a>
- <ul>
- <li><a href="#inst">Installation</a>
- <li><a href="#invoc">Invocation</a>
- <li><a href="#io">Input/Output</a>
- <ul>
- <li><a href="#num-io">Numbers</a>
- <li><a href="#sym-io">Symbols</a>
- <ul>
- <li><a href="#nilSym-io">NIL</a>
- <li><a href="#internal-io">Internal Symbols</a>
- <li><a href="#transient-io">Transient Symbols</a>
- <li><a href="#external-io">External Symbols</a>
- </ul>
- <li><a href="#lst-io">Lists</a>
- <li><a href="#macro-io">Read-Macros</a>
- </ul>
- <li><a href="#ev">Evaluation</a>
- <li><a href="#libs">Shared Libraries</a>
- <li><a href="#coroutines">Coroutines</a>
- <li><a href="#int">Interrupt</a>
- <li><a href="#errors">Error Handling</a>
- <li><a href="#atres">@ Result</a>
- <li><a href="#cmp">Comparing</a>
- <li><a href="#oop">OO Concepts</a>
- <li><a href="#dbase">Database</a>
- <ul>
- <li><a href="#trans">Transactions</a>
- <li><a href="#er">Entities / Relations</a>
- </ul>
- <li><a href="#pilog">Pilog (PicoLisp Prolog)</a>
- <li><a href="#conv">Naming Conventions</a>
- <li><a href="#trad">Breaking Traditions</a>
- <li><a href="#bugs">Bugs</a>
- </ul>
- <li><a href="#fun">Function Reference</a>
- <li><a href="#down">Download</a>
- </ul>
- <p><hr>
- <h2><a name="intro">Introduction</a></h2>
- <p>PicoLisp is the result of a language design study, trying to answer the
- question "What is a minimal but useful architecture for a virtual machine?".
- Because opinions differ about what is meant by "minimal" and "useful", there are
- many answers to that question, and people might consider other solutions more
- "minimal" or more "useful". But from a practical point of view, PicoLisp has
- proven to be a valuable answer to that question.
- <p>First of all, PicoLisp is a virtual machine architecture, and then a
- programming language. It was designed in a "bottom up" way, and "bottom up" is
- also the most natural way to understand and to use it: <i>Form Follows
- Function</i>.
- <p>PicoLisp has been used in several commercial and research programming
- projects since 1988. Its internal structures are simple enough, allowing an
- experienced programmer always to fully understand what's going on under the
- hood, and its language features, efficiency and extensibility make it suitable
- for almost any practical programming task.
- <p>In a nutshell, emphasis was put on four design objectives. The PicoLisp
- system should be
- <p><dl>
- <dt>Simple
- <dd>The internal data structure should be as simple as possible. Only one single
- data structure is used to build all higher level constructs.
- <dt>Unlimited
- <dd>There are no limits imposed upon the language due to limitations of the
- virtual machine architecture. That is, there is no upper bound in symbol name
- length, number digit counts, stack depth, or data structure and buffer sizes,
- except for the total memory size of the host machine.
- <dt>Dynamic
- <dd>Behavior should be as dynamic as possible ("run"-time vs. "compile"-time).
- All decisions are delayed until runtime where possible. This involves matters
- like memory management, dynamic symbol binding, and late method binding.
- <dt>Practical
- <dd>PicoLisp is not just a toy of theoretical value. It is in use since 1988 in
- actual application development, research and production.
- </dl>
- <p><hr>
- <h2><a name="vm">The PicoLisp Machine</a></h2>
- <p>An important point in the PicoLisp philosophy is the knowledge about the
- architecture and data structures of the internal machinery. The high-level
- constructs of the programming language directly map to that machinery, making
- the whole system both understandable and predictable.
- <p>This is similar to assembly language programming, where the programmer has
- complete control over the machine.
- <p><hr>
- <h3><a name="cell">The Cell</a></h3>
- <p>The PicoLisp virtual machine is both simpler and more powerful than most
- current (hardware) processors. At the lowest level, it is constructed from a
- single data structure called "cell":
- <pre><code>
- +-----+-----+
- | CAR | CDR |
- +-----+-----+
- </code></pre>
- <p>A cell is a pair of machine words, which traditionally are called CAR and CDR
- in the Lisp terminology. These words can represent either a numeric value
- (scalar) or the address of another cell (pointer). All higher level data
- structures are built out of cells.
- <p>The type information of higher level data is contained in the pointers to
- these data. Assuming the implementation on a byte-addressed physical machine,
- and a pointer size of typically 4 bytes, each cell has a size of 8 bytes.
- Therefore, the pointer to a cell must point to an 8-byte boundary, and its
- bit-representation will look like:
- <pre><code>
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxx000
- </code></pre>
- <p>(the '<code>x</code>' means "don't care"). For the individual data types, the
- pointer is adjusted to point to other parts of a cell, in effect setting some of
- the lower three bits to non-zero values. These bits are then used by the
- interpreter to determine the data type.
- <p>In any case, bit(0) - the least significant of these bits - is reserved as a
- mark bit for garbage collection.
- <p>Initially, all cells in the memory are unused (free), and linked together to
- form a "free list". To create higher level data types at runtime, cells are
- taken from that free list, and returned by the garbage collector when they are
- no longer needed. All memory management is done via that free list; there are no
- additional buffers, string spaces or special memory areas, with two exceptions:
- <p><ul>
- <li>A certain fixed area of memory is set aside to contain the executable code
- and global variables of the interpreter itself, and
- <li>a standard push down stack for return addresses and temporary storage. Both
- are not directly accessible by the programmer).
- </ul>
- <p><hr>
- <h3><a name="data">Data Types</a></h3>
- <p>On the virtual machine level, PicoLisp supports
- <p><ul>
- <li>three base data types: Numbers, Symbols and Cons Pairs (Lists),
- <li>the three scope variations of symbols: Internal, Transient and External, and
- <li>the special symbol <code>NIL</code>.
- </ul>
- <p>They are all built from the single cell data structure, and all runtime data
- cannot consist of any other types than these three.
- <p>The following diagram shows the complete data type hierarchy, consisting of
- the three base types and the symbol variations:
- <pre><code>
- cell
- |
- +--------+--------+
- | | |
- Number Symbol Pair
- |
- |
- +--------+--------+--------+
- | | | |
- NIL Internal Transient External
- </code></pre>
- <p><hr>
- <h4><a name="number">Numbers</a></h4>
- <p>A number can represent a signed integral value of arbitrary size. The CARs of
- one or more cells hold the number's "digits" (each in the machine's word size),
- to store the number's binary representation.
- <pre><code>
- Number
- |
- V
- +-----+-----+
- | DIG | | |
- +-----+--+--+
- |
- V
- +-----+-----+
- | DIG | | |
- +-----+--+--+
- |
- V
- ...
- </code></pre>
- <p>The first cell holds the least significant digit. The least significant bit
- of that digit represents the sign.
- <p>The pointer to a number points into the middle of the CAR, with an offset of
- 2 from the cell's start address. Therefore, the bit pattern of a number will be:
- <pre><code>
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxx010
- </code></pre>
- <p>Thus, a number is recognized by the interpreter when bit(1) is non-zero.
- <p><hr>
- <h4><a name="symbol">Symbols</a></h4>
- <p>A symbol is more complex than a number. Each symbol has a value, and
- optionally a name and an arbitrary number of properties. The CDR of a symbol
- cell is also called VAL, and the CAR points to the symbol's tail. As a minimum,
- a symbol consists of a single cell, and has no name or properties:
- <pre><code>
- Symbol
- |
- V
- +-----+-----+
- | / | VAL |
- +-----+-----+
- </code></pre>
- <p>That is, the symbol's tail is empty (points to <code>NIL</code>, as indicated
- by the '<code>/</code>' character).
- <p>The pointer to a symbol points to the CDR of the cell, with an offset of 4
- from the cell's start address. Therefore, the bit pattern of a symbol will be:
- <pre><code>
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxx100
- </code></pre>
- <p>Thus, a symbol is recognized by the interpreter when bit(2) is non-zero.
- <p>A property is a key-value pair, represented by a cons pair in the symbol's
- tail. This is called a "property list". The property list may be terminated by a
- number representing the symbol's name. In the following example, a symbol with
- the name <code>"abc"</code> has three properties: A KEY/VAL pair, a cell with
- only a KEY, and another KEY/VAL pair.
- <pre><code>
- Symbol
- |
- V
- +-----+-----+
- | | | VAL |
- +--+--+-----+
- | tail
- |
- V name
- +-----+-----+ +-----+-----+ +-----+-----+ +-----+-----+
- | | | ---+---> | KEY | ---+---> | | | ---+---> |'cba'| / |
- +--+--+-----+ +-----+-----+ +--+--+-----+ +-----+-----+
- | |
- V V
- +-----+-----+ +-----+-----+
- | VAL | KEY | | VAL | KEY |
- +-----+-----+ +-----+-----+
- </code></pre>
- <p>Each property in a symbol's tail is either a symbol (like the single KEY
- above, then it represents the boolean value <code>T</code>), or a cons pair with
- the property key in its CDR and the property value in its CAR. In both cases,
- the key should be a symbol, because searches in the property list are performed
- using pointer comparisons.
- <p>The name of a symbol is stored as a number at the end of the tail. It
- contains the characters of the name in UTF-8 encoding, using between one and
- three 8-bit-bytes per character. The first byte of the first character is stored
- in the lowest 8 bits of the number.
- <p>All symbols have the above structure, but depending on scope and
- accessibility there are actually four types of symbols: <code><a
- href="#nilSym">NIL</a></code>, <a href="#internal">internal</a>, <a
- href="#transient">transient</a> and <a href="#external">external</a> symbols.
- <p><hr>
- <h5><a name="nilSym">NIL</a></h5>
- <p><code>NIL</code> is a special symbol which exists exactly once in the whole
- system. It is used
- <p><ul>
- <li>as an end-of-list marker
- <li>to represent the empty list
- <li>to represent the boolean value "false"
- <li>to represent the absolute minimum
- <li>to represent a string of length zero
- <li>to represent the value "Not a Number"
- <li>as the root of all class hierarchies
- </ul>
- <p>For that, <code>NIL</code> has a special structure:
- <pre><code>
- NIL: /
- |
- V
- +-----+-----+-----+-----+
- | / | / | / | / |
- +-----+--+--+-----+-----+
- </code></pre>
- <p>The reason for that structure is <code>NIL</code>'s dual nature both as a
- symbol and as a list:
- <p><ul>
- <li>As a symbol, it should give <code>NIL</code> for its VAL, and be without
- properties
- <li>For the empty list, <code>NIL</code> should give <code>NIL</code> both for
- its CAR and for its CDR
- </ul>
- <p>These requirements are fulfilled by the above structure.
- <p><hr>
- <h5><a name="internal">Internal Symbols</a></h5>
- <p>Internal Symbols are all those "normal" symbols, as they are used for
- function definitions and variable names. They are "interned" into an index
- structure, so that it is possible to find an internal symbol by searching for
- its name.
- <p>There cannot be two different internal symbols with the same name.
- <p>Initially, a new internal symbol's VAL is <code>NIL</code>.
- <p><hr>
- <h5><a name="transient">Transient Symbols</a></h5>
- <p>Transient symbols are only interned into a index structure for a certain time
- (e.g. while reading the current source file), and are released after that. That
- means, a transient symbol cannot be accessed then by its name, and there may be
- several transient symbols in the system having the same name.
- <p>Transient symbols are used
- <p><ul>
- <li>as text strings
- <li>as identifiers with a limited access scope (like, for example,
- <code>static</code> identifiers in the C language family)
- <li>as anonymous, dynamically created objects (without a name)
- </ul>
- <p>Initially, a new transient symbol's VAL is that symbol itself.
- <p>A transient symbol without a name can be created with the <code><a
- href="#box">box</a></code> or <code><a
- href="#new">new</a></code> functions.
- <p><hr>
- <h5><a name="external">External Symbols</a></h5>
- <p>External symbols reside in a database file (or a similar resources, see
- <code><a href="#*Ext">*Ext</a></code>), and are loaded into memory -
- and written back to the file - dynamically as needed, and transparently to the
- programmer. They are kept in memory ("cached") as long as they are accessible
- ("referred to") from other parts of the program, or when they were modified but
- not yet written to the database file (by <code><a
- href="#commit">commit</a></code>).
- <p>The interpreter recognizes external symbols internally by an additional tag
- bit in the tail structure.
- <p>There cannot be two different external symbols with the same name. External
- symbols are maintained in index structures while they are loaded into memory,
- and have their external location (disk file and block offset) directly coded
- into their names (more details <a href="#external-io">here</a>).
- <p>Initially, a new external symbol's VAL is <code>NIL</code>, unless otherwise
- specified at creation time.
- <p><hr>
- <h4><a name="lst">Lists</a></h4>
- <p>A list is a sequence of one or more cells (cons pairs), holding numbers,
- symbols, or cons pairs.
- <pre><code>
- |
- V
- +-----+-----+
- | any | | |
- +-----+--+--+
- |
- V
- +-----+-----+
- | any | | |
- +-----+--+--+
- |
- V
- ...
- </code></pre>
- <p>Lists are used in PicoLisp to emulate composite data structures like arrays,
- trees, stacks or queues.
- <p>In contrast to lists, numbers and symbols are collectively called "Atoms".
- <p>Typically, the CDR of each cell in a list points to the following cell,
- except for the last cell which points to <code>NIL</code>. If, however, the CDR of
- the last cell points to an atom, that cell is called a "dotted pair" (because of
- its I/O syntax with a dot '<code>.</code>' between the two values).
- <p><hr>
- <h3><a name="mem">Memory Management</a></h3>
- <p>The PicoLisp interpreter has complete knowledge of all data in the system,
- due to the type information associated with every pointer. Therefore, an
- efficient garbage collector mechanism can easily be implemented. PicoLisp
- employs a simple but fast mark-and-sweep garbage collector.
- <p>As the collection process is very fast (in the order of milliseconds per
- megabyte), it was not necessary to develop more complicated, time-consuming and
- error-prone garbage collection algorithms (e.g. incremental collection). A
- compacting garbage collector is also not necessary, because the single cell data
- type cannot cause heap fragmentation.
- <p><hr>
- <h2><a name="penv">Programming Environment</a></h2>
- <p>Lisp was chosen as the programming language, because of its clear and simple
- structure.
- <p>In some previous versions, a Forth-like syntax was also implemented on top of
- a similar virtual machine (Lifo). Though that language was more flexible and
- expressive, the traditional Lisp syntax proved easier to handle, and the virtual
- machine can be kept considerably simpler.
- PicoLisp inherits the major advantages of classical Lisp systems like
- <p><ul>
- <li>Dynamic data types and structures
- <li>Formal equivalence of code and data
- <li>Functional programming style
- <li>An interactive environment
- </ul>
- <p>In the following, some concepts and peculiarities of the PicoLisp language
- and environment are described.
- <p><hr>
- <h3><a name="inst">Installation</a></h3>
- <p>PicoLisp supports two installation strategies: Local and Global.
- <p>Normally, if you didn't build PicoLisp yourself but installed it with your
- operating system's package manager, you will have a global installation. This
- allows system-wide access to the executable and library/documentation files.
- <p>To get a local installation, you can directly download the PicoLisp tarball,
- and follow the instructions in the INSTALL file.
- <p>A local installation will not interfere in any way with the world outside its
- directory. There is no need to touch any system locations, and you don't have to
- be root to install it. Many different versions - or local modifications - of
- PicoLisp can co-exist on a single machine.
- <p>Note that you are still free to have local installations along with a global
- installation, and invoke them explicitly as desired.
- <p>Most examples in the following apply to a global installation.
- <p><hr>
- <h3><a name="invoc">Invocation</a></h3>
- <p>When PicoLisp is invoked from the command line, an arbitrary number of
- arguments may follow the command name.
- <p>By default, each argument is the name of a file to be executed by the
- interpreter. If, however, the argument's first character is a hyphen
- '<code>-</code>', then the rest of that argument is taken as a Lisp function
- call (without the surrounding parentheses), and a hyphen by itself as an
- argument stops evaluation of the rest of the command line (it may be processed
- later using the <code><a href="#argv">argv</a></code> and <code><a
- href="#opt">opt</a></code> functions). This whole mechanism corresponds
- to calling <code>(<a href="#load">load</a> T)</code>.
- <p>A special case is if the last argument is a single '<code>+</code>'. This
- will switch on debug mode (the <code><a href="#*Dbg">*Dbg</a></code>
- global variable) and discard the '<code>+</code>'.
- <p>As a convention, PicoLisp source files have the extension "<code>.l</code>".
- <p>Note that the PicoLisp executable itself does not expect or accept any
- command line flags or options (except the '<code>+</code>', see above). They are
- reserved for application programs.
- <p>The simplest and shortest invocation of PicoLisp does nothing, and exits
- immediately by calling <code><a href="#bye">bye</a></code>:
- <pre><code>
- $ picolisp -bye
- $
- </code></pre>
- <p>In interactive mode, the PicoLisp interpreter (see <code><a
- href="#load">load</a></code>) will also exit when <code>Ctrl-D</code>
- is entered:
- <pre><code>
- $ picolisp
- : $ # Typed Ctrl-D
- </code></pre>
- <p>To start up the standard PicoLisp environment, several files should be
- loaded. The most commonly used things are in "lib.l" and in a bunch of other
- files, which are in turn loaded by "ext.l". Thus, a typical call would be:
- <pre><code>
- $ picolisp lib.l ext.l
- </code></pre>
- <p>The recommended way, however, is to call the "pil" shell script, which
- includes "lib.l" and "ext.l". Given that your current project is loaded by some
- file "myProject.l" and your startup function is <code>main</code>, your
- invocation would look like:
- <pre><code>
- $ pil myProject.l -main
- </code></pre>
- <p>For interactive development it is recommended to enable debugging mode, to
- get the vi-style line editor, single-stepping, tracing and other debugging
- utilities.
- <pre><code>
- $ pil myProject.l -main +
- </code></pre>
- <p>This is - in a local installation - equivalent to
- <pre><code>
- $ ./pil myProject.l -main +
- </code></pre>
- <p>In any case, the directory part of the first file name supplied (normally,
- the path to "lib.l" as called by 'pil') is remembered internally as the
- <i>PicoLisp Home Directory</i>. This path is later automatically substituted for
- any leading "<code>@</code>" character in file name arguments to I/O functions
- (see <code><a href="#path">path</a></code>).
- <p>Instead of the default vi-style line editor, an emacs-style editor can be
- used. It can be switched on permanently by calling the function
- <code>(em)</code> (i.e. without arguments), or by passing <code>-em</code> on
- the command line:
- <pre><code>
- $ pil -em +
- :
- </code></pre>
- <p>A single call is enough, because the style will be remembered in a file
- "~/.pil/editor", and used in all subsequent PicoLisp sessions.
- <p>To switch back to 'vi' style, call <code>(vi)</code>, use the
- <code>-vi</code> command line option, or simply remove "~/.pil/editor".
- <p><hr>
- <h3><a name="io">Input/Output</a></h3>
- <p>In Lisp, each internal data structure has a well-defined external
- representation in human-readable format. All kinds of data can be written to a
- file, and restored later to their original form by reading that file.
- <p>In normal operation, the PicoLisp interpreter continuously executes an
- infinite "read-eval-print loop". It reads one expression at a time, evaluates
- it, and prints the result to the console. Any input into the system, like data
- structures and function definitions, is done in a consistent way no matter
- whether it is entered at the console or read from a file.
- <p>Comments can be embedded in the input stream with the hash <code>#</code>
- character. Everything up to the end of that line will be ignored by the reader.
- <pre><code>
- : (* 1 2 3) # This is a comment
- -> 6
- </code></pre>
- <p>A comment spanning several lines may be enclosed between <code>#{</code> and
- <code>}#</code>.
- <p>Here is the I/O syntax for the individual PicoLisp data types (numbers,
- symbols and lists) and for read-macros:
- <p><hr>
- <h4><a name="num-io">Numbers</a></h4>
- <p>A number consists of an arbitrary number of digits ('<code>0</code>' through
- '<code>9</code>'), optionally preceded by a sign character ('<code>+</code>' or
- '<code>-</code>'). Legal number input is:
- <pre><code>
- : 7
- -> 7
- : -12345678901245678901234567890
- -> -12345678901245678901234567890
- </code></pre>
- <p>Fixpoint numbers can be input by embedding a decimal point '<code>.</code>',
- and setting the global variable <code><a href="#*Scl">*Scl</a></code>
- appropriately:
- <pre><code>
- : *Scl
- -> 0
- : 123.45
- -> 123
- : 456.78
- -> 457
- : (setq *Scl 3)
- -> 3
- : 123.45
- -> 123450
- : 456.78
- -> 456780
- </code></pre>
- <p>Thus, fixpoint input simply scales the number to an integer value
- corresponding to the number of digits in <code><a
- href="#*Scl">*Scl</a></code>.
- <p>Formatted output of scaled fixpoint values can be done with the <code><a
- href="#format">format</a></code> and <code><a
- href="#round">round</a></code> functions:
- <pre><code>
- : (format 1234567890 2)
- -> "12345678.90"
- : (format 1234567890 2 "." ",")
- -> "12,345,678.90"
- </code></pre>
- <p><hr>
- <h4><a name="sym-io">Symbols</a></h4>
- <p>The reader is able to recognize the individual symbol types from their
- syntactic form. A symbol name should - of course - not look like a legal number
- (see above).
- <p>In general, symbol names are case-sensitive. <code>car</code> is not the same
- as CAR.
- <p><hr>
- <h5><a name="nilSym-io">NIL</a></h5>
- <p>Besides for standard normal form, <code>NIL</code> is also recognized as
- <code>()</code>, <code>[]</code> or <code>""</code>.
- <pre><code>
- : NIL
- -> NIL
- : ()
- -> NIL
- : ""
- -> NIL
- </code></pre>
- <p>Output will always appear as <code>NIL</code>.
- <p><hr>
- <h5><a name="internal-io">Internal Symbols</a></h5>
- <p>Internal symbol names can consist of any printable (non-whitespace)
- character, except for the following meta characters:
- <pre><code>
- " ' ( ) , [ ] ` ~ { }
- </code></pre>
- <p>It is possible, though, to include these special characters into symbol names
- by escaping them with a backslash '<code>\</code>'.
- <p>The dot '<code>.</code>' has a dual nature. It is a meta character when
- standing alone, denoting a <a href="#dotted">dotted pair</a>, but can otherwise
- be used in symbol names.
- <p>As a rule, anything not recognized by the reader as another data type will be
- returned as an internal symbol.
- <p><hr>
- <h5><a name="transient-io">Transient Symbols</a></h5>
- <p>A transient symbol is anything surrounded by double quotes '<code>"</code>'.
- With that, it looks - and can be used - like a string constant in other
- languages. However, it is a real symbol, and may be assigned a value or a
- function definition, and properties.
- <p>Initially, a transient symbol's value is that symbol itself, so that it does
- not need to be quoted for evaluation:
- <p><pre><code>
- : "This is a string"
- -> "This is a string"
- </code></pre>
- <p>However, care must be taken when assigning a value to a transient symbol.
- This may cause unexpected behavior:
- <p><pre><code>
- : (setq "This is a string" 12345)
- -> 12345
- : "This is a string"
- -> 12345
- </code></pre>
- <p>The name of a transient symbol can contain any character except the
- null-byte. A double quote character can be escaped with a backslash
- '<code>\</code>', and a backslash itself has to be escaped with another
- backslash. Control characters can be written with a preceding hat
- '<code>^</code>' character.
- <p><pre><code>
- : "We^Ird\\Str\"ing"
- -> "We^Ird\\Str\"ing"
- : (chop @)
- -> ("W" "e" "^I" "r" "d" "\\" "S" "t" "r" "\"" "i" "n" "g")
- </code></pre>
- <p>A backslash '<code>\</code>' in a transient symbol name at the end of a line
- discards the newline, and continues the name in the next line. In that case, all
- leading spaces and tabs in that line are discarded, to allow proper source code
- indentation.
- <p><pre><code>
- : "abc\
- def"
- -> "abcdef"
- </code></pre>
- <p>The index for transient symbols is cleared automatically before and after
- <code><a href="#load">load</a></code>ing a source file, or it can be
- reset explicitly with the <code><a href="#====">====</a></code>
- function. With that mechanism, it is possible to create symbols with a local
- access scope, not accessible from other parts of the program.
- <p>A special case of transient symbols are <i>anonymous symbols</i>. These are
- symbols without name (see <code><a href="#box">box</a></code>, <code><a
- href="#box?">box?</a></code> or <code><a
- href="#new">new</a></code>). They print as a dollar sign
- (<code>$</code>) followed by a decimal digit string (actually their machine
- address).
- <p><hr>
- <h5><a name="external-io">External Symbols</a></h5>
- <p>External symbol names are surrounded by braces ('<code>{</code>' and
- '<code>}</code>'). The characters of the symbol's name itself identify the
- physical location of the external object. This is
- <ul>
- <li>in the 32-bit version: The number of the database file, and - separated by a
- hyphen - the starting block in the database file. Both numbers are encoded in
- base-64 notation (characters '<code>0</code>' through '<code>9</code>',
- '<code>:</code>', '<code>;</code>', '<code>A</code>' through '<code>Z</code>'
- and '<code>a</code>' through '<code>z</code>').
- <li>in the 64-bit version: The number of the database file minus 1 in "hax"
- notation (i.e. hexadecimal/alpha notation, where '<code>@</code>' is zero,
- '<code>A</code>' is 1 and '<code>O</code>' is 15 (from "alpha" to "omega")),
- immediately followed (without a hyphen) the starting block in octal
- ('<code>0</code>' through '<code>7</code>').
- </ul>
- <p>In both cases, the database file (and possibly the hypen) are omitted for the
- first (default) file.
- <p><hr>
- <h4><a name="lst-io">Lists</a></h4>
- <p>Lists are surrounded by parentheses ('<code>(</code>' and '<code>)</code>').
- <p><code>(A)</code> is a list consisting of a single cell, with the symbol
- <code>A</code> in its CAR, and <code>NIL</code> in its CDR.
- <p><code>(A B C)</code> is a list consisting of three cells, with the symbols
- <code>A</code>, <code>B</code> and <code>C</code> respectively in their CAR, and
- <code>NIL</code> in the last cell's CDR.
- <p><a name="dotted"><code>(A . B)</code></a> is a "dotted pair", a list
- consisting of a single cell, with the symbol <code>A</code> in its CAR, and
- <code>B</code> in its CDR.
- <p>PicoLisp has built-in support for reading and printing simple circular lists.
- If the dot in a dotted-pair notation is immediately followed by a closing
- parenthesis, it indicates that the CDR of the last cell points back to the
- beginning of that list.
- <pre><code>
- : (let L '(a b c) (conc L L))
- -> (a b c .)
- : (cdr '(a b c .))
- -> (b c a .)
- : (cddddr '(a b c .))
- -> (b c a .)
- </code></pre>
- <p>A similar result can be achieved with the function <code><a
- href="#circ">circ</a></code>. Such lists must be used with care,
- because many functions won't terminate or will crash when given such a list.
- <p><hr>
- <h4><a name="macro-io">Read-Macros</a></h4>
- <p>Read-macros in PicoLisp are special forms that are recognized by the reader,
- and modify its behavior. Note that they take effect immediately while <code><a
- href="#read">read</a></code>ing an expression, and are not seen by the
- <code>eval</code> in the main loop.
- <p>The most prominent read-macro in Lisp is the single quote character
- "<code>'</code>", which expands to a call of the <code><a
- href="#quote">quote</a></code> function. Note that the single quote
- character is also printed instead of the full function name.
- <pre><code>
- : '(a b c)
- -> (a b c)
- : '(quote . a)
- -> 'a
- : (cons 'quote 'a) # (quote . a)
- -> 'a
- : (list 'quote 'a) # (quote a)
- -> '(a)
- </code></pre>
- <p>A comma (<code>,</code>) will cause the reader to collect the following data
- item into an <code><a href="#idx">idx</a></code> tree in the global
- variable <code><a href="#*Uni">*Uni</a></code>, and to return a
- previously inserted equal item if present. This makes it possible to create a
- unique list of references to data which do normally not follow the rules of
- pointer equality. If the value of <code>*Uni</code> is <code>T</code>, the
- comma read macro mechanism is disabled.
- <p>A single backquote character "<code>`</code>" will cause the reader to
- evaluate the following expression, and return the result.
- <pre><code>
- : '(a `(+ 1 2 3) z)
- -> (a 6 z)
- </code></pre>
- <p>A tilde character <code>~</code> inside a list will cause the reader to
- evaluate the following expression, and (destructively) splice the result into
- the list.
- <pre><code>
- : '(a b c ~(list 'd 'e 'f) g h i)
- -> (a b c d e f g h i)
- </code></pre>
- <p>When a tilde character is used to separate two symbol names (without
- surrounding whitespace), the first is taken as a namespace to look up the second
- (64-bit version only).
- <pre><code>
- : 'libA~foo # Look up 'foo' in namespace 'libA'
- -> "foo" # "foo" is not interned in the current namespace
- </code></pre>
- <p>Reading <code>libA~foo</code> is equivalent to switching the current
- namespace to <code>libA</code> (with <code><a
- href="#symbols">symbols</a></code>), reading the symbol
- <code>foo</code>, and then switching back to the original namespace.
- <p>Brackets ('<code>[</code>' and '<code>]</code>') can be used as super
- parentheses. A closing bracket will match the innermost opening bracket, or all
- currently open parentheses.
- <pre><code>
- : '(a (b (c (d]
- -> (a (b (c (d))))
- : '(a (b [c (d]))
- -> (a (b (c (d))))
- </code></pre>
- <p>Finally, reading the sequence '<code>{}</code>' will result in a new
- anonymous symbol with value <code>NIL</code>, equivalent to a call to <code><a
- href="#box">box</a></code> without arguments.
- <pre><code>
- : '({} {} {})
- -> ($134599965 $134599967 $134599969)
- : (mapcar val @)
- -> (NIL NIL NIL)
- </code></pre>
- <p><hr>
- <h3><a name="ev">Evaluation</a></h3>
- <p>PicoLisp tries to evaluate any expression encountered in the read-eval-print
- loop. Basically, it does so by applying the following three rules:
- <p><ul>
- <li>A number evaluates to itself.
- <li>A symbol evaluates to its value (VAL).
- <li>A list is evaluated as a function call, with the CAR as the function and the
- CDR the arguments to that function. These arguments are in turn evaluated
- according to these three rules.
- </ul>
- <pre><code>
- : 1234
- -> 1234 # Number evaluates to itself
- : *Pid
- -> 22972 # Symbol evaluates to its VAL
- : (+ 1 2 3)
- -> 6 # List is evaluated as a function call
- </code></pre>
- <p>For the third rule, however, things get a bit more involved. First - as a
- special case - if the CAR of the list is a number, the whole list is returned as
- it is:
- <pre><code>
- : (1 2 3 4 5 6)
- -> (1 2 3 4 5 6)
- </code></pre>
- <p>This is not really a function call but just a convenience to avoid having to
- quote simple data lists.
- <p>Otherwise, if the CAR is a symbol or a list, PicoLisp tries to obtain an
- executable function from that, by either using the symbol's value, or by
- evaluating the list.
- <p>What is an executable function? Or, said in another way, what can be applied
- to a list of arguments, to result in a function call? A legal function in
- PicoLisp is
- <p><dl>
- <dt>either
- <dd>a <i>number</i>. When a number is used as a function, it is simply taken as
- a pointer to executable code that will be called with the list of (unevaluated)
- arguments as its single parameter. It is up to that code to evaluate the
- arguments, or not. Some functions do not evaluate their arguments (e.g.
- <code>quote</code>) or evaluate only some of their arguments (e.g.
- <code>setq</code>).
- <dt>or
- <dd>a <i>lambda expression</i>. A lambda expression is a list, whose CAR is
- either a symbol or a list of symbols, and whose CDR is a list of expressions.
- Note: In contrast to other Lisp implementations, the symbol LAMBDA itself does
- not exist in PicoLisp but is implied from context.
- </dl>
- <p>A few examples should help to understand the practical consequences of these
- rules. In the most common case, the CAR will be a symbol defined as a function,
- like the <code>*</code> in:
- <pre><code>
- : (* 1 2 3) # Call the function '*'
- -> 6
- </code></pre>
- <p>Inspecting the VAL of <code>*</code> gives
- <pre><code>
- : * # Get the VAL of the symbol '*'
- -> 67318096
- </code></pre>
- <p>The VAL of <code>*</code> is a number. In fact, it is the numeric
- representation of a C-function pointer, i.e. a pointer to executable code. This
- is the case for all built-in functions of PicoLisp.
- <p>Other functions in turn are written as Lisp expressions:
- <pre><code>
- : (de foo (X Y) # Define the function 'foo'
- (* (+ X Y) (+ X Y)) )
- -> foo
- : (foo 2 3) # Call the function 'foo'
- -> 25
- : foo # Get the VAL of the symbol 'foo'
- -> ((X Y) (* (+ X Y) (+ X Y)))
- </code></pre>
- <p>The VAL of <code>foo</code> is a list. It is the list that was assigned to
- <code>foo</code> with the <code>de</code> function. It would be perfectly legal
- to use <code>setq</code> instead of <code>de</code>:
- <pre><code>
- : (setq foo '((X Y) (* (+ X Y) (+ X Y))))
- -> ((X Y) (* (+ X Y) (+ X Y)))
- : (foo 2 3)
- -> 25
- </code></pre>
- <p>If the VAL of <code>foo</code> were another symbol, that symbol's VAL would
- be used instead to search for an executable function.
- <p>As we said above, if the CAR of the evaluated expression is not a symbol but
- a list, that list is evaluated to obtain an executable function.
- <pre><code>
- : ((intern (pack "c" "a" "r")) (1 2 3))
- -> 1
- </code></pre>
- <p>Here, the <code>intern</code> function returns the symbol <code>car</code>
- whose VAL is used then. It is also legal, though quite dangerous, to use the <a
- name="codePointer">code-pointer</a> directly:
- <pre><code>
- : *
- -> 67318096
- : ((* 2 33659048) 1 2 3)
- -> 6
- : ((quote . 67318096) 1 2 3)
- -> 6
- : ((quote . 1234) (1 2 3))
- Segmentation fault
- </code></pre>
- <p>When an executable function is defined in Lisp itself, we call it a <a
- name="lambda"><i>lambda expression</i></a>. A lambda expression always has a
- list of executable expressions as its CDR. The CAR, however, must be a either a
- list of symbols, or a single symbol, and it controls the evaluation of the
- arguments to the executable function according to the following rules:
- <p><dl>
- <dt>When the CAR is a list of symbols
- <dd>For each of these symbols an argument is evaluated, then the symbols are
- bound simultaneously to the results. The body of the lambda expression is
- executed, then the VAL's of the symbols are restored to their original values.
- This is the most common case, a fixed number of arguments is passed to the
- function.
- <dt>Otherwise, when the CAR is the symbol <code>@</code>
- <dd>All arguments are evaluated and the results kept internally in a list. The
- body of the lambda expression is executed, and the evaluated arguments can be
- accessed sequentially with the <code><a href="#args">args</a></code>,
- <code><a href="#next">next</a></code>, <code><a
- href="#arg">arg</a></code> and <code><a
- href="#rest">rest</a></code> functions. This allows to define functions
- with a variable number of evaluated arguments.
- <dt>Otherwise, when the CAR is a single symbol
- <dd>The symbol is bound to the whole unevaluated argument list. The body of the
- lambda expression is executed, then the symbol is restored to its original
- value. This allows to define functions with unevaluated arguments. Any kind of
- interpretation and evaluation of the argument list can be done inside the
- expression body.
- </dl>
- <p>In all cases, the return value is the result of the last expression in the
- body.
- <pre><code>
- : (de foo (X Y Z) # CAR is a list of symbols
- (list X Y Z) ) # Return a list of all arguments
- -> foo
- : (foo (+ 1 2) (+ 3 4) (+ 5 6))
- -> (3 7 11) # all arguments are evaluated
- </code></pre>
- <pre><code>
- : (de foo @ # CAR is the symbol '@'
- (list (next) (next) (next)) ) # Return the first three arguments
- -> foo
- : (foo (+ 1 2) (+ 3 4) (+ 5 6))
- -> (3 7 11) # all arguments are evaluated
- </code></pre>
- <pre><code>
- : (de foo X # CAR is a single symbol
- X ) # Return the argument
- -> foo
- : (foo (+ 1 2) (+ 3 4) (+ 5 6))
- -> ((+ 1 2) (+ 3 4) (+ 5 6)) # the whole unevaluated list is returned
- </code></pre>
- <p>Note that these forms can also be combined. For example, to evaluate only the
- first two arguments, bind the results to <code>X</code> and <code>Y</code>, and
- bind all other arguments (unevaluated) to <code>Z</code>:
- <pre><code>
- : (de foo (X Y . Z) # CAR is a list with a dotted-pair tail
- (list X Y Z) ) # Return a list of all arguments
- -> foo
- : (foo (+ 1 2) (+ 3 4) (+ 5 6))
- -> (3 7 ((+ 5 6))) # Only the first two arguments are evaluated
- </code></pre>
- <p>Or, a single argument followed by a variable number of arguments:
- <pre><code>
- : (de foo (X . @) # CAR is a dotted-pair with '@'
- (println X) # print the first evaluated argument
- (while (args) # while there are more arguments
- (println (next)) ) ) # print the next one
- -> foo
- : (foo (+ 1 2) (+ 3 4) (+ 5 6))
- 3 # X
- 7 # next argument
- 11 # and the last argument
- -> 11
- </code></pre>
- <p>In general, if more than the expected number of arguments is supplied to a
- function, these extra arguments will be ignored. Missing arguments default to
- <code>NIL</code>.
- <p><hr>
- <h3><a name="libs">Shared Libraries</a></h3>
- <p>Analogous to built-in functions (which are written in assembly (64-bit
- version) or C (32-bit version) in the interpreter kernel), PicoLisp functions
- may also be defined in shared object files (called "DLLs" on some systems). The
- coding style, register usage, argument passing etc. follow the same rules as for
- normal built-in functions.
- <p>Note that this has nothing to do with external (e.g. third-party) library
- functions called with <a href="#native">native</a>.
- <p>When the interpreter encounters a symbol supposed to be called as a function,
- without a function definition, but with a name of the form
- "<code>lib:sym</code>", then - instead of throwing an "undefined"-error - it
- tries to locate a shared object file with the name <code>lib</code> and a
- function <code>sym</code>, and stores a pointer to this code in the symbol's
- value. From that point, this symbol <code>lib:sym</code> keeps that function
- definition, and is undistinguishable from built-in functions. Future calls to
- this function do not require another library search.
- <p>A consequence of this lookup mechanism, however, is the fact that such
- symbols cannot be used directly in a function-passing context (i.e.
- "<code>apply</code>" them) like
- <pre><code>
- (apply + (1 2 3))
- (mapcar inc (1 2 3))
- </code></pre>
- <p>These calls work because <code>+</code> and <code>inc</code> already have a
- (function) value at this point. Applying a shared library function like
- <pre><code>
- (mapcar ext:Base64 (1 2 3))
- </code></pre>
- <p>works <i>only</i> if <code>ext:Base64</code> was either called before (and
- thus automatically received a function definition), or was fetched explicitly
- with <code>(getd 'ext:Base64)</code>.
- <p>Therefore, it is recommended to always apply such functions by passing the
- symbol itself and not just the value:
- <pre><code>
- (mapcar 'ext:Base64 (1 2 3))
- </code></pre>
- <p><hr>
- <h3><a name="coroutines">Coroutines</a></h3>
- <p>Coroutines are independent execution contexts. They may have multiple entry
- and exit points, and preserve their environment between invocations.
- <p>They are available only in the 64-bit version.
- <p>A coroutine is identified by a tag. This tag can be passed to other
- functions, and (re)invoked as needed. In this regard coroutines are similar to
- "continuations" in other languages.
- <p>When the tag goes out of scope while it is not actively running, the
- coroutine will be garbage collected. In cases where this is desired, using a <a
- href="#transient">transient</a> symbol for the tag is recommended.
- <p>A coroutine is created by calling <code><a href="#co">co</a></code>.
- Its <code>prg</code> body will be executed, and unless <code><a
- href="#yield">yield</a></code> is called at some point, the coroutine
- will "fall off" at the end and disappear.
- <p>When <code><a href="#yield">yield</a></code> is called, control is
- either transferred back to the caller, or to some other - explicitly specified,
- and already running - coroutine.
- <p>A coroutine is stopped and disposed when
- <p><ul>
- <li>execution falls off the end
- <li>some other (co)routine calls <code><a href="#co">co</a></code> with
- that tag but without a <code>prg</code> body
- <li>a <code><a href="#throw">throw</a></code> into another (co)routine
- environment is executed
- <li>an error occurred, and <a href="#errors">error handling</a> was entered
- </ul>
- <p>Reentrant coroutines are not supported: A coroutine cannot resume itself
- directly or indirectly.
- <p>Before using many coroutines, make sure you have sufficient stack space, e.g.
- by calling
- <pre><code>
- $ ulimit -s unlimited
- </code></pre>
- <p>Without that, the stack limit in Linux is typically 8 MB.
- <p><hr>
- <h3><a name="int">Interrupt</a></h3>
- <p>During the evaluation of an expression, the PicoLisp interpreter can be
- interrupted at any time by hitting <code>Ctrl-C</code>. It will then enter the
- breakpoint routine, as if <code><a href="#!">!</a></code> were called.
- <p>Hitting ENTER at that point will continue evaluation, while <code>(<a
- href="#quit">quit</a>)</code> will abort evaluation and return the
- interpreter to the top level. See also <code><a
- href="#debug">debug</a></code>, <code><a
- href="#e">e</a></code>, <code><a href="ref_.html#^">^</a></code> and
- <code><a href="#*Dbg">*Dbg</a></code>
- <p>Other interrupts may be handled by <code><a
- href="#alarm">alarm</a></code>, <code><a
- href="#sigio">sigio</a></code>, <code><a
- href="#*Hup">*Hup</a></code> and <code><a
- href="#*Sig1">*Sig[12]</a></code>.
- <p><hr>
- <h3><a name="errors">Error Handling</a></h3>
- <p>When a runtime error occurs, execution is stopped and an error handler is
- entered.
- <p>The error handler resets the I/O channels to the console, and displays the
- location (if possible) and the reason of the error, followed by an error
- message. That message is also stored in the global <code><a
- href="#*Msg">*Msg</a></code>, and the location of the error in <code><a
- href="#^">^</a></code>. If the VAL of the global <code><a
- href="#*Err">*Err</a></code> is non-<code>NIL</code> it is executed as
- a <code>prg</code> body. If the standard input is from a terminal, a
- read-eval-print loop (with a question mark "<code>?</code>" as prompt) is
- entered (the loop is exited when an empty line is input). Then all pending
- <code><a href="#finally">finally</a></code> expressions are executed,
- all variable bindings restored, and all files closed. If the standard input is
- not from a terminal, the interpreter terminates. Otherwise it is reset to its
- top-level state.
- <pre><code>
- : (de foo (A B) (badFoo A B)) # 'foo' calls an undefined symbol
- -> foo
- : (foo 3 4) # Call 'foo'
- !? (badFoo A B) # Error handler entered
- badFoo -- Undefined
- ? A # Inspect 'A'
- -> 3
- ? B # Inspect 'B'
- -> 4
- ? # Empty line: Exit
- :
- </code></pre>
- <p>Errors can be caught with <code><a href="#catch">catch</a></code>,
- if a list of substrings of possible error messages is supplied for the first
- argument. In such a case, the matching substring (or the whole error message if
- the substring is <code>NIL</code>) is returned.
- <p>An arbitrary error can be thrown explicitly with <code><a
- href="#quit">quit</a></code>.
- <p><hr>
- <h3><a name="atres">@ Result</a></h3>
- <p>In certain situations, the result of the last evaluation is stored in the VAL
- of the symbol <code>@</code>. This can be very convenient, because it often
- makes the assignment to temporary variables unnecessary.
- <p>This happens in two - only superficially similar - situations:
- <p><dl>
- <dt><code><a href="#load">load</a></code>
- <dd>In read-eval loops, the last three results which were printed at the console
- are available in <code>@@@</code>, <code>@@</code> and <code>@</code>, in that
- order (i.e the latest result is in <code>@</code>).
- <pre><code>
- : (+ 1 2 3)
- -> 6
- : (/ 128 4)
- -> 32
- : (- @ @@) # Subtract the last two results
- -> 26
- </code></pre>
- <p><dt>Flow functions
- <dd>Flow- and logic-functions store the result of their controlling expression -
- respectively non-<code>NIL</code> results of their conditional expression - in
- <code>@</code>.
- <pre><code>
- : (while (read) (println 'got: @))
- abc # User input
- got: abc # print result
- 123 # User input
- got: 123 # print result
- NIL
- -> 123
- : (setq L (1 2 3 4 5 1 2 3 4 5))
- -> (1 2 3 4 5 1 2 3 4 5)
- : (and (member 3 L) (member 3 (cdr @)) (set @ 999))
- -> 999
- : L
- -> (1 2 3 4 5 1 2 999 4 5)
- </code></pre>
- <p>Functions with controlling expressions are
- <a href="#case">case</a>,
- <a href="#casq">casq</a>,
- <a href="#prog1">prog1</a>,
- <a href="#prog2">prog2</a>,
- and the bodies of <code><a href="#*Run">*Run</a></code> tasks.
- <p>Functions with conditional expressions are
- <a href="#and">and</a>,
- <a href="#cond">cond</a>,
- <a href="#do">do</a>,
- <a href="#for">for</a>,
- <a href="#if">if</a>,
- <a href="#if2">if2</a>,
- <a href="#ifn">ifn</a>,
- <a href="#loop">loop</a>,
- <a href="#nand">nand</a>,
- <a href="#nond">nond</a>,
- <a href="#nor">nor</a>,
- <a href="#not">not</a>,
- <a href="#or">or</a>,
- <a href="#state">state</a>,
- <a href="#unless">unless</a>,
- <a href="#until">until</a>,
- <a href="#when">when</a> and
- <a href="#while">while</a>.
- </dl>
- <p><code>@</code> is generally local to functions and methods, its value is
- automatically saved upon function entry and restored at exit.
- <p><hr>
- <h3><a name="cmp">Comparing</a></h3>
- <p>In PicoLisp, it is legal to compare data items of arbitrary type. Any two
- items are either
- <p><dl>
- <dt>Identical
- <dd>They are the same memory object (pointer equality). For example, two
- internal symbols with the same name are identical. In the 64-bit version, also
- short numbers (up to 60 bits plus sign) are pointer-equal.
- <dt>Equal
- <dd>They are equal in every respect (structure equality), but need not to be
- identical. Examples are numbers with the same value, transient symbols with the
- same name or lists with equal elements.
- <dt>Or they have a well-defined ordinal relationship
- <dd>Numbers are comparable by their numeric value, strings by their name, and
- lists recursively by their elements (if the CAR's are equal, their CDR's are
- compared). For differing types, the following rule applies: Numbers are less
- than symbols, and symbols are less than lists. As special cases,
- <code>NIL</code> is always less than anything else, and <code>T</code> is always
- greater than anything else.
- </dl>
- <p>To demonstrate this, <code><a href="#sort">sort</a></code> a list of
- mixed data types:
- <pre><code>
- : (sort '("abc" T (d e f) NIL 123 DEF))
- -> (NIL 123 DEF "abc" (d e f) T)
- </code></pre>
- <p>See also <code><a href="#max">max</a></code>, <code><a
- href="#min">min</a></code>, <code><a
- href="#rank">rank</a></code>, <code><a href="ref_.html#<"><</a></code>,
- <code><a href="#=">=</a></code>, <code><a
- href="#>">></a></code> etc.
- <p><hr>
- <h3><a name="oop">OO Concepts</a></h3>
- <p>PicoLisp comes with built-in object oriented extensions. There seems to be a
- common agreement upon three criteria for object orientation:
- <p><dl>
- <dt>Encapsulation
- <dd>Code and data are encapsulated into <u>objects</u>, giving them both a
- <u>behavior</u> and a <u>state</u>. Objects communicate by sending and receiving
- <u>messages</u>.
- <dt>Inheritance
- <dd>Objects are organized into <u>classes</u>. The behavior of an object is
- inherited from its class(es) and superclass(es).
- <dt>Polymorphism
- <dd>Objects of different classes may behave differently in response to the same
- message. For that, classes may define different methods for each message.
- </dl>
- <p>PicoLisp implements both objects and classes with symbols. Object-local data
- are stored in the symbol's property list, while the code (methods) and links to
- the superclasses are stored in the symbol's VAL (encapsulation).
- <p>In fact, there is no formal difference between objects and classes (except
- that objects usually are anonymous symbols containing mostly local data, while
- classes are named internal symbols with an emphasis on method definitions). At
- any time, a class may be assigned its own local data (class variables), and any
- object can receive individual method definitions in addition to (or overriding)
- those inherited from its (super)classes.
- <p>PicoLisp supports multiple inheritance. The VAL of each object is a (possibly
- empty) association list of message symbols and method bodies, concatenated with
- a list of classes. When a message is sent to an object, it is searched in the
- object's own method list, and then (with a left-to-right depth-first search) in
- the tree of its classes and superclasses. The first method found is executed and
- the search stops. The search may be explicitly continued with the <code><a
- href="#extra">extra</a></code> and <code><a
- href="#super">super</a></code> functions.
- <p>Thus, which method is actually executed when a message is sent to an object
- depends on the classes that the object is currently linked to (polymorphism). As
- the method search is fully dynamic (late binding), an object's type (i.e. its
- classes and method definitions) can be changed even at runtime!
- <p>While a method body is being executed, the global variable <code><a
- href="#This">This</a></code> is set to the current object, allowing
- the use of the short-cut property functions <code><a
- href="#=:">=:</a></code>, <code><a href="ref_.html#:">:</a></code>
- and <code><a href="#::">::</a></code>.
- <p><hr>
- <h3><a name="dbase">Database</a></h3>
- <p>On the lowest level, a PicoLisp database is just a collection of <a
- href="#external">external symbols</a>. They reside in a database file, and are
- dynamically swapped in and out of memory. Only one database can be open at a
- time (<code><a href="#pool">pool</a></code>).
- <p>In addition, further external symbols can be specified to originate from
- arbitrary sources via the <code><a href="#*Ext">*Ext</a></code>
- mechanism.
- <p>Whenever an external symbol's value or property list is accessed, it will be
- automatically fetched into memory, and can then be used like any other symbol.
- Modifications will be written to disk only when <code><a
- href="#commit">commit</a></code> is called. Alternatively, all
- modifications since the last call to <code>commit</code> can be discarded by
- calling <code><a href="#rollback">rollback</a></code>.
- <p><hr>
- <h4><a name="trans">Transactions</a></h4>
- <p>In the typical case there will be multiple processes operating on the same
- database. These processes should be all children of the same parent process,
- which takes care of synchronizing read/write operations and heap contents. Then
- a database transaction is normally initiated by calling <code>(<a
- href="#dbSync">dbSync</a>)</code>, and closed by calling <code>(<a
- href="#commit">commit</a> 'upd)</code>. Short transactions, involving
- only a single DB operation, are available in functions like <code><a
- href="#new!">new!</a></code> and methods like <code><a
- href="#entityMesssages">put!></a></code> (by convention with an
- exclamation mark), which implicitly call <code>(dbSync)</code> and <code>(commit
- 'upd)</code> themselves.
- <p>A transaction proceeds through five phases:
- <p><ol>
- <li><code><a href="#dbSync">dbSync</a></code> waits to get a <code><a
- href="#lock">lock</a></code> on the root object <code><a
- href="#*DB">*DB</a></code>. Other processes continue reading and
- writing meanwhile.
- <li><code><a href="#dbSync">dbSync</a></code> calls <code><a
- href="#sync">sync</a></code> to synchronize with changes from other
- processes. We hold the shared lock, but other processes may continue reading.
- <li>We make modifications to the internal state of external symbols with
- <code><a href="#entityMesssages">put>, set>, lose></a></code> etc. We -
- and also other processes - can still read the DB.
- <li>We call <code>(<a href="#commit">commit</a> 'upd)</code>.
- <code>commit</code> obtains an exclusive lock (no more read operations by other
- processes), writes an optional transaction log, and then all modified symbols.
- As <code><a href="#upd">upd</a></code> is passed to 'commit', other
- processes synchronize with these changes.
- <li>Finally, all locks are released by 'commit'
- </ol>
- <p><hr>
- <h4><a name="er">Entities / Relations</a></h4>
- <p>The symbols in a database can be used to store arbitrary information
- structures. In typical use, some symbols represent nodes of search trees, by
- holding keys, values, and links to subtrees in their VAL's. Such a search tree
- in the database is called <u>index</u>.
- <p>For the most part, other symbols in the database are objects derived from the
- <code><a href="#+Entity">+Entity</a></code> class.
- <p>Entities depend on objects of the <code><a
- href="#+relation">+relation</a></code> class hierarchy.
- Relation-objects manage the property values of entities, they define the
- application database model and are responsible for the integrity of mutual
- object references and index trees.
- <p>Relations are stored as properties in the entity classes, their methods are
- invoked as daemons whenever property values in an entity are changed. When
- defining an <code><a href="#+Entity">+Entity</a></code> class, relations are defined - in addition to
- the method definitions of a normal class - with the <code><a
- href="#rel">rel</a></code> function. Predefined relation classes
- include
- <p><ul>
- <li>Scalar relations like
- <dl>
- <dt><code><a href="#+Symbol">+Symbol</a></code>
- <dd>Symbolic data
- <dt><code><a href="#+String">+String</a></code>
- <dd>Strings (just a general case of symbols)
- <dt><code><a href="#+Number">+Number</a></code>
- <dd>Integers and fixpoint numbers
- <dt><code><a href="#+Date">+Date</a></code>
- <dd>Calendar date values, represented by a number
- <dt><code><a href="#+Time">+Time</a></code>
- <dd>Time-of-the-day values, represented by a number
- <dt><code><a href="#+Blob">+Blob</a></code>
- <dd>"Binary large objects" stored in separate files
- <dt><code><a href="#+Bool">+Bool</a></code>
- <dd><code>T</code> or <code>NIL</code>
- </dl>
- <li>Object-to-object relations
- <dl>
- <dt><code><a href="#+Link">+Link</a></code>
- <dd>A reference to some other entity
- <dt><code><a href="#+Hook">+Hook</a></code>
- <dd>A reference to an entity holding object-local index trees
- <dt><code><a href="#+Joint">+Joint</a></code>
- <dd>A bidirectional reference to some other entity
- </dl>
- <li>Container prefix classes like
- <dl>
- <dt><code><a href="#+List">+List</a></code>
- <dd>A list of any of the other primitive or object relation types
- <dt><code><a href="#+Bag">+Bag</a></code>
- <dd>A list containing a mixture of any of the other types
- </dl>
- <li>Index prefix classes
- <dl>
- <dt><code><a href="#+Ref">+Ref</a></code>
- <dd>An index with other primitives or entities as key
- <dt><code><a href="#+Key">+Key</a></code>
- <dd>A unique index with other primitives or entities as key
- <dt><code><a href="#+Idx">+Idx</a></code>
- <dd>A full-text index, typically for strings
- <dt><code><a href="#+Fold">+Fold</a></code>
- <dd>A folded text index
- <dt><code><a href="#+IdxFold">+IdxFold</a></code>
- <dd>Folded substring index
- <dt><code><a href="#+Sn">+Sn</a></code>
- <dd>Tolerant index, using a modified Soundex-Algorithm
- </dl>
- <li>And a catch-all class
- <dl>
- <dt><code><a href="#+Any">+Any</a></code>
- <dd>Not specified, may be any of the above relations
- </dl>
- </ul>
- <p><hr>
- <h3><a name="pilog">Pilog (PicoLisp Prolog)</a></h3>
- <p>A declarative language is built on top of PicoLisp, that has the semantics of
- Prolog, but uses the syntax of Lisp.
- <p>For an explanation of Prolog's declarative programming style, an introduction
- like "Programming in Prolog" by Clocksin/Mellish (Springer-Verlag 1981) is
- recommended.
- <p>Facts and rules can be declared with the <code><a
- href="#be">be</a></code> function. For example, a Prolog fact
- '<code>likes(john,mary).</code>' is written in Pilog as:
- <pre><code>
- (be likes (John Mary))
- </code></pre>
- <p>and a rule '<code>likes(john,X) :- likes(X,wine), likes(X,food).</code>' is
- in Pilog:
- <pre><code>
- (be likes (John @X) (likes @X wine) (likes @X food))
- </code></pre>
- <p>As in Prolog, the difference between facts and rules is that the latter ones
- have conditions, and usually contain variables.
- <p>A variable in Pilog is any symbol starting with an at-mark character
- ("<code>@</code>"). The symbol <code>@</code> itself can be used as an anonymous
- variable: It will match during unification, but will not be bound to the matched
- values.
- <p>The <i>cut</i> operator of Prolog (usually written as an exclamation mark
- (<code>!</code>)) is the symbol <code>T</code> in Pilog.
- <p>An interactive query can be done with the <code><a
- href="#?">?</a></code> function:
- <pre><code>
- (? (likes John @X))
- </code></pre>
- <p>This will print all solutions, waiting for user input after each line. If a
- non-empty line (not just a ENTER key, but for example a dot (<code>.</code>)
- followed by ENTER) is typed, it will terminate.
- <p>Pilog can be called from Lisp and vice versa:
- <ul>
- <li>The interface from Lisp is via the functions <code><a
- href="#goal">goal</a></code> (prepare a query from Lisp data) and
- <code><a href="#prove">prove</a></code> (return an association list of
- successful bindings), and the application level functions <code><a
- href="#pilog">pilog</a></code> and <code><a
- href="#solve">solve</a></code>.
- <li>When the CAR of a Pilog clause is the symbol <code>^</code>, then the CDDR
- is executed as a Lisp <code>prg</code> body and the result unified with the
- CADR.
- <li>Within such a Lisp expression in a Pilog clause, the current bindings of
- Pilog variables can be accessed with the <code><a
- href="#->">-></a></code> function.
- </ul>
- <p><hr>
- <h3><a name="conv">Naming Conventions</a></h3>
- <p>It was necessary to introduce - and adhere to - a set of conventions for
- PicoLisp symbol names. Because all (internal) symbols have a global scope (there
- are no packages or name spaces), and each symbol can only have either a value or
- function definition, it would otherwise be very easy to introduce name
- conflicts. Besides this, source code readability is increased when the scope of
- a symbol is indicated by its name.
- <p>These conventions are not hard-coded into the language, but should be so into
- the head of the programmer. Here are the most commonly used ones:
- <p><ul>
- <li>Global variables start with an asterisk "<code>*</code>"
- <li>Functions and other global symbols start with a lower case letter
- <li>Locally bound symbols start with an upper case letter
- <li>Local functions start with an underscore "<code>_</code>"
- <li>Classes start with a plus-sign "<code>+</code>", where the first letter
- <ul>
- <li>is in lower case for abstract classes
- <li>and in upper case for normal classes
- </ul>
- <li>Methods end with a right arrow "<code>></code>"
- <li>Class variables may be indicated by an upper case letter
- </ul>
- <p>For historical reasons, the global constant symbols <code>T</code> and
- <code>NIL</code> do not obey these rules, and are written in upper case.
- <p>For example, a local variable could easily overshadow a function definition:
- <pre><code>
- : (de max-speed (car)
- (.. (get car 'speeds) ..) )
- -> max-speed
- </code></pre>
- <p>Inside the body of <code>max-speed</code> (and all other functions called
- during that execution) the kernel function <code>car</code> is redefined to some
- other value, and will surely crash if something like <code>(car Lst)</code> is
- executed. Instead, it is safe to write:
- <pre><code>
- : (de max-speed (Car) # 'Car' with upper case first letter
- (.. (get Car 'speeds) ..) )
- -> max-speed
- </code></pre>
- <p>Note that there are also some strict naming rules (as opposed to the
- voluntary conventions) that are required by the corresponding kernel
- functionalities, like:
- <p><ul>
- <li>Transient symbols are enclosed in double quotes (see <a
- href="#transient-io">Transient Symbols</a>)
- <li>External symbols are enclosed in braces (see <a href="#external-io">External
- Symbols</a>)
- <li>Pattern-Wildcards start with an at-mark "<code>@</code>" (see <a
- href="#match">match</a> and <a href="refF.html#fill">fill</a>)
- <li>Symbols referring to a shared library contain a colon "<code>lib:sym</code>"
- </ul>
- <p>With that, the last of the above conventions (local functions start with an
- underscore) is not really necessary, because true local scope can be enforced
- with transient symbols.
- <p><hr>
- <h3><a name="trad">Breaking Traditions</a></h3>
- <p>PicoLisp does not try very hard to be compatible with traditional Lisp
- systems. If you are used to some other Lisp dialects, you may notice the
- following differences:
- <p><dl>
- <dt>Case Sensitivity
- <dd>PicoLisp distinguishes between upper case and lower case characters in
- symbol names. Thus, <code>CAR</code> and <code>car</code> are different symbols,
- which was not the case in traditional Lisp systems.
- <dt><code>QUOTE</code>
- <dd>In traditional Lisp, the <code>QUOTE</code> function returns its
- <i>first</i> unevaluated argument. In PicoLisp, on the other hand,
- <code>quote</code> returns <i>all</i> (unevaluated) argument(s).
- <dt><code>LAMBDA</code>
- <dd>The <code>LAMBDA</code> function, in some way at the heart of traditional
- Lisp, is completely missing (and <code>quote</code> is used instead).
- <dt><code>PROG</code>
- <dd>The <code>PROG</code> function of traditional Lisp, with its GOTO and ENTER
- functionality, is also missing. PicoLisp's <code>prog</code> function is just a
- simple sequencer (as <code>PROGN</code> in some Lisps).
- <dt>Function/Value
- <dd>In PicoLisp, a symbol cannot have a value <i>and</i> a function definition
- at the same time. Though this is a disadvantage at first sight, it allows a
- completely uniform handling of functional data.
- </dl>
- <p><hr>
- <h3><a name="bugs">Bugs</a></h3>
- <p>The names of the symbols <code>T</code> and <code>NIL</code> violate the <a
- href="#conv">naming conventions</a>. They are global symbols, and should
- therefore start with an asterisk "<code>*</code>". It is too easy to bind them
- to some other value by mistake:
- <pre><code>
- (de foo (R S T)
- ...
- </code></pre>
- <p>However, <code><a href="#lint">lint</a></code> will issue a warning
- in such a case.
- <p><hr>
- <h2><a name="fun">Function Reference</a></h2>
- <p>This section provides a reference manual for the kernel functions, and some
- extensions. See the thematically grouped list of indexes below.
- <p>Though PicoLisp is a dynamically typed language (resolved at runtime, as
- opposed to statically (compile-time) typed languages), many functions can only
- accept and/or return a certain set of data types. For each function, the
- expected argument types and return values are described with the following
- abbreviations:
- <p>The primary data types:
- <p><ul>
- <li><code>num</code> - Number
- <li><code>sym</code> - Symbol
- <li><code>lst</code> - List
- </ul>
- <p>Other (derived) data types
- <p><ul>
- <li><code>any</code> - Anything: Any data type
- <li><code>flg</code> - Flag: Boolean value (<code>NIL</code> or non-<code>NIL</code>)
- <li><code>cnt</code> - A count or a small number
- <li><code>dat</code> - Date: Days, starting first of March of the year 0 A.D.
- <li><code>tim</code> - Time: Seconds since midnight
- <li><code>obj</code> - Object/Class: A symbol with methods and/or classes
- <li><code>var</code> - Variable: Either a symbol or a cons pair
- <li><code>exe</code> - Executable: An executable expression (<code>eval</code>)
- <li><code>prg</code> - Prog-Body: A list of executable expressions (<code>run</code>)
- <li><code>fun</code> - Function: Either a number (code-pointer), a symbol (message) or a list (lambda)
- <li><code>msg</code> - Message: A symbol sent to an object (to invoke a method)
- <li><code>cls</code> - Class: A symbol defined as an object's class
- <li><code>typ</code> - Type: A list of <code>cls</code> symbols
- <li><code>pat</code> - Pattern: A symbol whose name starts with an at-mark "<code>@</code>"
- <li><code>pid</code> - Process ID: A number, the ID of a Unix process
- <li><code>tree</code> - Database index tree specification
- <li><code>hook</code> - Database hook object
- </ul>
- <p>Arguments evaluated by the function (depending on the context) are quoted
- (prefixed with the single quote character "<code>'</code>").
- <p>
- <a href="#A">A</a>
- <a href="#B">B</a>
- <a href="#C">C</a>
- <a href="#D">D</a>
- <a href="#E">E</a>
- <a href="#F">F</a>
- <a href="#G">G</a>
- <a href="#H">H</a>
- <a href="#I">I</a>
- <a href="#J">J</a>
- <a href="#K">K</a>
- <a href="#L">L</a>
- <a href="#M">M</a>
- <a href="#N">N</a>
- <a href="#O">O</a>
- <a href="#P">P</a>
- <a href="#Q">Q</a>
- <a href="#R">R</a>
- <a href="#S">S</a>
- <a href="#T">T</a>
- <a href="#U">U</a>
- <a href="#V">V</a>
- <a href="#W">W</a>
- <a href="#X">X</a>
- <a href="#Y">Y</a>
- <a href="#Z">Z</a>
- <a href="#_">Other</a>
- <p><span id="sortBtnHome"></span><dl>
- <dt>Symbol Functions
- <dd><code>
- <a href="#new">new</a>
- <a href="#sym">sym</a>
- <a href="#str">str</a>
- <a href="#char">char</a>
- <a href="#name">name</a>
- <a href="#sp?">sp?</a>
- <a href="#pat?">pat?</a>
- <a href="#fun?">fun?</a>
- <a href="#all">all</a>
- <a href="#symbols">symbols</a>
- <a href="#local">local</a>
- <a href="#import">import</a>
- <a href="#intern">intern</a>
- <a href="#extern">extern</a>
- <a href="#====">====</a>
- <a href="#qsym">qsym</a>
- <a href="#loc">loc</a>
- <a href="#box?">box?</a>
- <a href="#str?">str?</a>
- <a href="#ext?">ext?</a>
- <a href="#touch">touch</a>
- <a href="#zap">zap</a>
- <a href="#length">length</a>
- <a href="#size">size</a>
- <a href="#format">format</a>
- <a href="#chop">chop</a>
- <a href="#pack">pack</a>
- <a href="#glue">glue</a>
- <a href="#pad">pad</a>
- <a href="#align">align</a>
- <a href="#center">center</a>
- <a href="#text">text</a>
- <a href="#wrap">wrap</a>
- <a href="#pre?">pre?</a>
- <a href="#sub?">sub?</a>
- <a href="#low?">low?</a>
- <a href="#upp?">upp?</a>
- <a href="#lowc">lowc</a>
- <a href="#uppc">uppc</a>
- <a href="#fold">fold</a>
- <a href="#val">val</a>
- <a href="#getd">getd</a>
- <a href="#set">set</a>
- <a href="#setq">setq</a>
- <a href="#def">def</a>
- <a href="#de">de</a>
- <a href="#dm">dm</a>
- <a href="#recur">recur</a>
- <a href="#undef">undef</a>
- <a href="#redef">redef</a>
- <a href="#daemon">daemon</a>
- <a href="#patch">patch</a>
- <a href="#swap">swap</a>
- <a href="#xchg">xchg</a>
- <a href="#on">on</a>
- <a href="#off">off</a>
- <a href="#onOff">onOff</a>
- <a href="#zero">zero</a>
- <a href="#one">one</a>
- <a href="#default">default</a>
- <a href="#expr">expr</a>
- <a href="#subr">subr</a>
- <a href="#let">let</a>
- <a href="#let?">let?</a>
- <a href="#use">use</a>
- <a href="#accu">accu</a>
- <a href="#push">push</a>
- <a href="#push1">push1</a>
- <a href="#push1q">push1q</a>
- <a href="#pop">pop</a>
- <a href="#cut">cut</a>
- <a href="#del">del</a>
- <a href="#queue">queue</a>
- <a href="#fifo">fifo</a>
- <a href="#idx">idx</a>
- <a href="#lup">lup</a>
- <a href="#cache">cache</a>
- <a href="#locale">locale</a>
- <a href="#dirname">dirname</a>
- </code>
- <dt>Property Access
- <dd><code>
- <a href="#put">put</a>
- <a href="#get">get</a>
- <a href="#prop">prop</a>
- <a href="#;">;</a>
- <a href="#=:">=:</a>
- <a href="#:">:</a>
- <a href="#::">::</a>
- <a href="#putl">putl</a>
- <a href="#getl">getl</a>
- <a href="#wipe">wipe</a>
- <a href="#meta">meta</a>
- </code>
- <dt>Predicates
- <dd><code>
- <a href="#atom">atom</a>
- <a href="#pair">pair</a>
- <a href="#circ?">circ?</a>
- <a href="#lst?">lst?</a>
- <a href="#num?">num?</a>
- <a href="#sym?">sym?</a>
- <a href="#flg?">flg?</a>
- <a href="#sp?">sp?</a>
- <a href="#pat?">pat?</a>
- <a href="#fun?">fun?</a>
- <a href="#box?">box?</a>
- <a href="#str?">str?</a>
- <a href="#ext?">ext?</a>
- <a href="#bool">bool</a>
- <a href="#not">not</a>
- <a href="#==">==</a>
- <a href="#n==">n==</a>
- <a href="#=">=</a>
- <a href="#<>"><></a>
- <a href="#=0">=0</a>
- <a href="#=T">=T</a>
- <a href="#n0">n0</a>
- <a href="#nT">nT</a>
- <a href="#<"><</a>
- <a href="#<="><=</a>
- <a href="#>">></a>
- <a href="#>=">>=</a>
- <a href="#match">match</a>
- </code>
- <dt>Arithmetics
- <dd><code>
- <a href="#+">+</a>
- <a href="#-">-</a>
- <a href="#*">*</a>
- <a href="#/">/</a>
- <a href="#%">%</a>
- <a href="#*/">*/</a>
- <a href="#**">**</a>
- <a href="#inc">inc</a>
- <a href="#dec">dec</a>
- <a href="#>>">>></a>
- <a href="#lt0">lt0</a>
- <a href="#le0">le0</a>
- <a href="#ge0">ge0</a>
- <a href="#gt0">gt0</a>
- <a href="#abs">abs</a>
- <a href="#bit?">bit?</a>
- <a href="#&">&</a>
- <a href="#|">|</a>
- <a href="#x|">x|</a>
- <a href="#sqrt">sqrt</a>
- <a href="#seed">seed</a>
- <a href="#hash">hash</a>
- <a href="#rand">rand</a>
- <a href="#max">max</a>
- <a href="#min">min</a>
- <a href="#length">length</a>
- <a href="#size">size</a>
- <a href="#accu">accu</a>
- <a href="#format">format</a>
- <a href="#pad">pad</a>
- <a href="#money">money</a>
- <a href="#round">round</a>
- <a href="#bin">bin</a>
- <a href="#oct">oct</a>
- <a href="#hex">hex</a>
- <a href="#hax">hax</a>
- <a href="#fmt64">fmt64</a>
- </code>
- <dt>List Processing
- <dd><code>
- <a href="#car">car</a>
- <a href="#cdr">cdr</a>
- <a href="#caar">caar</a>
- <a href="#cadr">cadr</a>
- <a href="#cdar">cdar</a>
- <a href="#cddr">cddr</a>
- <a href="#caaar">caaar</a>
- <a href="#caadr">caadr</a>
- <a href="#cadar">cadar</a>
- <a href="#caddr">caddr</a>
- <a href="#cdaar">cdaar</a>
- <a href="#cdadr">cdadr</a>
- <a href="#cddar">cddar</a>
- <a href="#cdddr">cdddr</a>
- <a href="#caaaar">caaaar</a>
- <a href="#caaadr">caaadr</a>
- <a href="#caadar">caadar</a>
- <a href="#caaddr">caaddr</a>
- <a href="#cadaar">cadaar</a>
- <a href="#cadadr">cadadr</a>
- <a href="#caddar">caddar</a>
- <a href="#cadddr">cadddr</a>
- <a href="#cdaaar">cdaaar</a>
- <a href="#cdaadr">cdaadr</a>
- <a href="#cdadar">cdadar</a>
- <a href="#cdaddr">cdaddr</a>
- <a href="#cddaar">cddaar</a>
- <a href="#cddadr">cddadr</a>
- <a href="#cdddar">cdddar</a>
- <a href="#cddddr">cddddr</a>
- <a href="#nth">nth</a>
- <a href="#con">con</a>
- <a href="#cons">cons</a>
- <a href="#conc">conc</a>
- <a href="#circ">circ</a>
- <a href="#rot">rot</a>
- <a href="#list">list</a>
- <a href="#need">need</a>
- <a href="#range">range</a>
- <a href="#full">full</a>
- <a href="#make">make</a>
- <a href="#made">made</a>
- <a href="#chain">chain</a>
- <a href="#link">link</a>
- <a href="#yoke">yoke</a>
- <a href="#copy">copy</a>
- <a href="#mix">mix</a>
- <a href="#append">append</a>
- <a href="#delete">delete</a>
- <a href="#delq">delq</a>
- <a href="#replace">replace</a>
- <a href="#insert">insert</a>
- <a href="#remove">remove</a>
- <a href="#place">place</a>
- <a href="#strip">strip</a>
- <a href="#split">split</a>
- <a href="#reverse">reverse</a>
- <a href="#flip">flip</a>
- <a href="#trim">trim</a>
- <a href="#clip">clip</a>
- <a href="#head">head</a>
- <a href="#tail">tail</a>
- <a href="#stem">stem</a>
- <a href="#fin">fin</a>
- <a href="#last">last</a>
- <a href="#member">member</a>
- <a href="#memq">memq</a>
- <a href="#mmeq">mmeq</a>
- <a href="#sect">sect</a>
- <a href="#diff">diff</a>
- <a href="#index">index</a>
- <a href="#offset">offset</a>
- <a href="#prior">prior</a>
- <a href="#assoc">assoc</a>
- <a href="#rassoc">rassoc</a>
- <a href="#asoq">asoq</a>
- <a href="#rank">rank</a>
- <a href="#sort">sort</a>
- <a href="#uniq">uniq</a>
- <a href="#group">group</a>
- <a href="#length">length</a>
- <a href="#size">size</a>
- <a href="#bytes">bytes</a>
- <a href="#val">val</a>
- <a href="#set">set</a>
- <a href="#xchg">xchg</a>
- <a href="#push">push</a>
- <a href="#push1">push1</a>
- <a href="#push1q">push1q</a>
- <a href="#pop">pop</a>
- <a href="#cut">cut</a>
- <a href="#queue">queue</a>
- <a href="#fifo">fifo</a>
- <a href="#idx">idx</a>
- <a href="#balance">balance</a>
- <a href="#get">get</a>
- <a href="#fill">fill</a>
- <a href="#apply">apply</a>
- </code>
- <dt>Control Flow
- <dd><code>
- <a href="#load">load</a>
- <a href="#args">args</a>
- <a href="#next">next</a>
- <a href="#arg">arg</a>
- <a href="#rest">rest</a>
- <a href="#pass">pass</a>
- <a href="#quote">quote</a>
- <a href="#as">as</a>
- <a href="#lit">lit</a>
- <a href="#eval">eval</a>
- <a href="#run">run</a>
- <a href="#macro">macro</a>
- <a href="#curry">curry</a>
- <a href="#def">def</a>
- <a href="#de">de</a>
- <a href="#dm">dm</a>
- <a href="#recur">recur</a>
- <a href="#recurse">recurse</a>
- <a href="#undef">undef</a>
- <a href="#box">box</a>
- <a href="#new">new</a>
- <a href="#type">type</a>
- <a href="#isa">isa</a>
- <a href="#method">method</a>
- <a href="#meth">meth</a>
- <a href="#send">send</a>
- <a href="#try">try</a>
- <a href="#super">super</a>
- <a href="#extra">extra</a>
- <a href="#with">with</a>
- <a href="#bind">bind</a>
- <a href="#job">job</a>
- <a href="#let">let</a>
- <a href="#let?">let?</a>
- <a href="#use">use</a>
- <a href="#and">and</a>
- <a href="#or">or</a>
- <a href="#nand">nand</a>
- <a href="#nor">nor</a>
- <a href="#xor">xor</a>
- <a href="#bool">bool</a>
- <a href="#not">not</a>
- <a href="#nil">nil</a>
- <a href="#t">t</a>
- <a href="#prog">prog</a>
- <a href="#prog1">prog1</a>
- <a href="#prog2">prog2</a>
- <a href="#if">if</a>
- <a href="#if2">if2</a>
- <a href="#ifn">ifn</a>
- <a href="#when">when</a>
- <a href="#unless">unless</a>
- <a href="#cond">cond</a>
- <a href="#nond">nond</a>
- <a href="#case">case</a>
- <a href="#casq">casq</a>
- <a href="#state">state</a>
- <a href="#while">while</a>
- <a href="#until">until</a>
- <a href="#loop">loop</a>
- <a href="#do">do</a>
- <a href="#at">at</a>
- <a href="#for">for</a>
- <a href="#catch">catch</a>
- <a href="#throw">throw</a>
- <a href="#finally">finally</a>
- <a href="#co">co</a>
- <a href="#yield">yield</a>
- <a href="#!">!</a>
- <a href="#e">e</a>
- <a href="#$">$</a>
- <a href="#call">call</a>
- <a href="#tick">tick</a>
- <a href="#ipid">ipid</a>
- <a href="#opid">opid</a>
- <a href="#kill">kill</a>
- <a href="#quit">quit</a>
- <a href="#task">task</a>
- <a href="#fork">fork</a>
- <a href="#pipe">pipe</a>
- <a href="#later">later</a>
- <a href="#timeout">timeout</a>
- <a href="#abort">abort</a>
- <a href="#bye">bye</a>
- </code>
- <dt>Mapping
- <dd><code>
- <a href="#apply">apply</a>
- <a href="#pass">pass</a>
- <a href="#maps">maps</a>
- <a href="#map">map</a>
- <a href="#mapc">mapc</a>
- <a href="#maplist">maplist</a>
- <a href="#mapcar">mapcar</a>
- <a href="#mapcon">mapcon</a>
- <a href="#mapcan">mapcan</a>
- <a href="#filter">filter</a>
- <a href="#extract">extract</a>
- <a href="#seek">seek</a>
- <a href="#find">find</a>
- <a href="#pick">pick</a>
- <a href="#fully">fully</a>
- <a href="#cnt">cnt</a>
- <a href="#sum">sum</a>
- <a href="#maxi">maxi</a>
- <a href="#mini">mini</a>
- <a href="#fish">fish</a>
- <a href="#by">by</a>
- </code>
- <dt>Input/Output
- <dd><code>
- <a href="#path">path</a>
- <a href="#in">in</a>
- <a href="#out">out</a>
- <a href="#err">err</a>
- <a href="#ctl">ctl</a>
- <a href="#ipid">ipid</a>
- <a href="#opid">opid</a>
- <a href="#pipe">pipe</a>
- <a href="#any">any</a>
- <a href="#sym">sym</a>
- <a href="#str">str</a>
- <a href="#load">load</a>
- <a href="#hear">hear</a>
- <a href="#tell">tell</a>
- <a href="#key">key</a>
- <a href="#poll">poll</a>
- <a href="#peek">peek</a>
- <a href="#char">char</a>
- <a href="#skip">skip</a>
- <a href="#eol">eol</a>
- <a href="#eof">eof</a>
- <a href="#from">from</a>
- <a href="#till">till</a>
- <a href="#line">line</a>
- <a href="#format">format</a>
- <a href="#scl">scl</a>
- <a href="#read">read</a>
- <a href="#print">print</a>
- <a href="#println">println</a>
- <a href="#printsp">printsp</a>
- <a href="#prin">prin</a>
- <a href="#prinl">prinl</a>
- <a href="#msg">msg</a>
- <a href="#space">space</a>
- <a href="#beep">beep</a>
- <a href="#tab">tab</a>
- <a href="#flush">flush</a>
- <a href="#rewind">rewind</a>
- <a href="#rd">rd</a>
- <a href="#pr">pr</a>
- <a href="#wr">wr</a>
- <a href="#wait">wait</a>
- <a href="#sync">sync</a>
- <a href="#echo">echo</a>
- <a href="#info">info</a>
- <a href="#file">file</a>
- <a href="#dir">dir</a>
- <a href="#lines">lines</a>
- <a href="#open">open</a>
- <a href="#close">close</a>
- <a href="#port">port</a>
- <a href="#listen">listen</a>
- <a href="#accept">accept</a>
- <a href="#host">host</a>
- <a href="#connect">connect</a>
- <a href="#udp">udp</a>
- <a href="#script">script</a>
- <a href="#once">once</a>
- <a href="#rc">rc</a>
- <a href="#acquire">acquire</a>
- <a href="#release">release</a>
- <a href="#tmp">tmp</a>
- <a href="#pretty">pretty</a>
- <a href="#pp">pp</a>
- <a href="#show">show</a>
- <a href="#view">view</a>
- <a href="#here">here</a>
- <a href="#prEval">prEval</a>
- <a href="#mail">mail</a>
- </code>
- <dt>Object Orientation
- <dd><code>
- <a href="#*Class">*Class</a>
- <a href="#class">class</a>
- <a href="#dm">dm</a>
- <a href="#rel">rel</a>
- <a href="#var">var</a>
- <a href="#var:">var:</a>
- <a href="#new">new</a>
- <a href="#type">type</a>
- <a href="#isa">isa</a>
- <a href="#method">method</a>
- <a href="#meth">meth</a>
- <a href="#send">send</a>
- <a href="#try">try</a>
- <a href="#object">object</a>
- <a href="#extend">extend</a>
- <a href="#super">super</a>
- <a href="#extra">extra</a>
- <a href="#with">with</a>
- <a href="#This">This</a>
- <a href="#can">can</a>
- <a href="#dep">dep</a>
- </code>
- <dt>Database
- <dd><code>
- <a href="#pool">pool</a>
- <a href="#journal">journal</a>
- <a href="#id">id</a>
- <a href="#seq">seq</a>
- <a href="#lieu">lieu</a>
- <a href="#lock">lock</a>
- <a href="#commit">commit</a>
- <a href="#rollback">rollback</a>
- <a href="#mark">mark</a>
- <a href="#free">free</a>
- <a href="#dbck">dbck</a>
- <a href="#dbs">dbs</a>
- <a href="#dbs+">dbs+</a>
- <a href="#db:">db:</a>
- <a href="#tree">tree</a>
- <a href="#db">db</a>
- <a href="#aux">aux</a>
- <a href="#collect">collect</a>
- <a href="#genKey">genKey</a>
- <a href="#genStrKey">genStrKey</a>
- <a href="#useKey">useKey</a>
- <a href="#+relation">+relation</a>
- <a href="#+Any">+Any</a>
- <a href="#+Bag">+Bag</a>
- <a href="#+Bool">+Bool</a>
- <a href="#+Number">+Number</a>
- <a href="#+Date">+Date</a>
- <a href="#+Time">+Time</a>
- <a href="#+Symbol">+Symbol</a>
- <a href="#+String">+String</a>
- <a href="#+Link">+Link</a>
- <a href="#+Joint">+Joint</a>
- <a href="#+Blob">+Blob</a>
- <a href="#+Hook">+Hook</a>
- <a href="#+Hook2">+Hook2</a>
- <a href="#+index">+index</a>
- <a href="#+Key">+Key</a>
- <a href="#+Ref">+Ref</a>
- <a href="#+Ref2">+Ref2</a>
- <a href="#+Idx">+Idx</a>
- <a href="#+Sn">+Sn</a>
- <a href="#+Fold">+Fold</a>
- <a href="#+IdxFold">+IdxFold</a>
- <a href="#+Aux">+Aux</a>
- <a href="#+UB">+UB</a>
- <a href="#+Dep">+Dep</a>
- <a href="#+List">+List</a>
- <a href="#+Need">+Need</a>
- <a href="#+Mis">+Mis</a>
- <a href="#+Alt">+Alt</a>
- <a href="#+Swap">+Swap</a>
- <a href="#+Entity">+Entity</a>
- <a href="#blob">blob</a>
- <a href="#dbSync">dbSync</a>
- <a href="#new!">new!</a>
- <a href="#set!">set!</a>
- <a href="#put!">put!</a>
- <a href="#inc!">inc!</a>
- <a href="#blob!">blob!</a>
- <a href="#upd">upd</a>
- <a href="#rel">rel</a>
- <a href="#request">request</a>
- <a href="#obj">obj</a>
- <a href="#fmt64">fmt64</a>
- <a href="#root">root</a>
- <a href="#fetch">fetch</a>
- <a href="#store">store</a>
- <a href="#count">count</a>
- <a href="#leaf">leaf</a>
- <a href="#minKey">minKey</a>
- <a href="#maxKey">maxKey</a>
- <a href="#init">init</a>
- <a href="#step">step</a>
- <a href="#scan">scan</a>
- <a href="#iter">iter</a>
- <a href="#ubIter">ubIter</a>
- <a href="#prune">prune</a>
- <a href="#zapTree">zapTree</a>
- <a href="#chkTree">chkTree</a>
- <a href="#db/3">db/3</a>
- <a href="#db/4">db/4</a>
- <a href="#db/5">db/5</a>
- <a href="#val/3">val/3</a>
- <a href="#lst/3">lst/3</a>
- <a href="#map/3">map/3</a>
- <a href="#isa/2">isa/2</a>
- <a href="#same/3">same/3</a>
- <a href="#bool/3">bool/3</a>
- <a href="#range/3">range/3</a>
- <a href="#head/3">head/3</a>
- <a href="#fold/3">fold/3</a>
- <a href="#part/3">part/3</a>
- <a href="#tolr/3">tolr/3</a>
- <a href="#select/3">select/3</a>
- <a href="#remote/2">remote/2</a>
- </code>
- <dt>Pilog
- <dd><code>
- <a href="#prove">prove</a>
- <a href="#->">-></a>
- <a href="#unify">unify</a>
- <a href="#be">be</a>
- <a href="#clause">clause</a>
- <a href="#repeat">repeat</a>
- <a href="#asserta">asserta</a>
- <a href="#assertz">assertz</a>
- <a href="#retract">retract</a>
- <a href="#rules">rules</a>
- <a href="#goal">goal</a>
- <a href="#fail">fail</a>
- <a href="#pilog">pilog</a>
- <a href="#solve">solve</a>
- <a href="#query">query</a>
- <a href="#?">?</a>
- <a href="#repeat/0">repeat/0</a>
- <a href="#fail/0">fail/0</a>
- <a href="#true/0">true/0</a>
- <a href="#not/1">not/1</a>
- <a href="#call/1">call/1</a>
- <a href="#or/2">or/2</a>
- <a href="#nil/1">nil/1</a>
- <a href="#equal/2">equal/2</a>
- <a href="#different/2">different/2</a>
- <a href="#append/3">append/3</a>
- <a href="#member/2">member/2</a>
- <a href="#delete/3">delete/3</a>
- <a href="#permute/2">permute/2</a>
- <a href="#uniq/2">uniq/2</a>
- <a href="#asserta/1">asserta/1</a>
- <a href="#assertz/1">assertz/1</a>
- <a href="#retract/1">retract/1</a>
- <a href="#clause/2">clause/2</a>
- <a href="#show/1">show/1</a>
- <a href="#for/2">for/2</a>
- <a href="#for/3">for/3</a>
- <a href="#for/4">for/4</a>
- <a href="#db/3">db/3</a>
- <a href="#db/4">db/4</a>
- <a href="#db/5">db/5</a>
- <a href="#val/3">val/3</a>
- <a href="#lst/3">lst/3</a>
- <a href="#map/3">map/3</a>
- <a href="#isa/2">isa/2</a>
- <a href="#same/3">same/3</a>
- <a href="#bool/3">bool/3</a>
- <a href="#range/3">range/3</a>
- <a href="#head/3">head/3</a>
- <a href="#fold/3">fold/3</a>
- <a href="#part/3">part/3</a>
- <a href="#tolr/3">tolr/3</a>
- <a href="#select/3">select/3</a>
- <a href="#remote/2">remote/2</a>
- </code>
- <dt>Debugging
- <dd><code>
- <a href="#pretty">pretty</a>
- <a href="#pp">pp</a>
- <a href="#show">show</a>
- <a href="#loc">loc</a>
- <a href="#*Dbg">*Dbg</a>
- <a href="#doc">doc</a>
- <a href="#more">more</a>
- <a href="#depth">depth</a>
- <a href="#what">what</a>
- <a href="#who">who</a>
- <a href="#can">can</a>
- <a href="#dep">dep</a>
- <a href="#debug">debug</a>
- <a href="#d">d</a>
- <a href="#unbug">unbug</a>
- <a href="#u">u</a>
- <a href="#vi">vi</a>
- <a href="#em">em</a>
- <a href="#ld">ld</a>
- <a href="#trace">trace</a>
- <a href="#untrace">untrace</a>
- <a href="#traceAll">traceAll</a>
- <a href="#proc">proc</a>
- <a href="#hd">hd</a>
- <a href="#bench">bench</a>
- <a href="#bt">bt</a>
- <a href="#edit">edit</a>
- <a href="#lint">lint</a>
- <a href="#lintAll">lintAll</a>
- <a href="#select">select</a>
- <a href="#update">update</a>
- </code>
- <dt>System Functions
- <dd><code>
- <a href="#cmd">cmd</a>
- <a href="#argv">argv</a>
- <a href="#opt">opt</a>
- <a href="#version">version</a>
- <a href="#gc">gc</a>
- <a href="#raw">raw</a>
- <a href="#alarm">alarm</a>
- <a href="#sigio">sigio</a>
- <a href="#kids">kids</a>
- <a href="#protect">protect</a>
- <a href="#heap">heap</a>
- <a href="#stack">stack</a>
- <a href="#adr">adr</a>
- <a href="#env">env</a>
- <a href="#trail">trail</a>
- <a href="#up">up</a>
- <a href="#sys">sys</a>
- <a href="#date">date</a>
- <a href="#time">time</a>
- <a href="#usec">usec</a>
- <a href="#stamp">stamp</a>
- <a href="#dat$">dat$</a>
- <a href="#$dat">$dat</a>
- <a href="#datSym">datSym</a>
- <a href="#datStr">datStr</a>
- <a href="#strDat">strDat</a>
- <a href="#expDat">expDat</a>
- <a href="#day">day</a>
- <a href="#week">week</a>
- <a href="#ultimo">ultimo</a>
- <a href="#tim$">tim$</a>
- <a href="#$tim">$tim</a>
- <a href="#telStr">telStr</a>
- <a href="#expTel">expTel</a>
- <a href="#locale">locale</a>
- <a href="#allowed">allowed</a>
- <a href="#allow">allow</a>
- <a href="#pwd">pwd</a>
- <a href="#cd">cd</a>
- <a href="#chdir">chdir</a>
- <a href="#ctty">ctty</a>
- <a href="#info">info</a>
- <a href="#dir">dir</a>
- <a href="#dirname">dirname</a>
- <a href="#errno">errno</a>
- <a href="#native">native</a>
- <a href="#struct">struct</a>
- <a href="#lisp">lisp</a>
- <a href="#exec">exec</a>
- <a href="#call">call</a>
- <a href="#tick">tick</a>
- <a href="#kill">kill</a>
- <a href="#quit">quit</a>
- <a href="#task">task</a>
- <a href="#fork">fork</a>
- <a href="#forked">forked</a>
- <a href="#pipe">pipe</a>
- <a href="#timeout">timeout</a>
- <a href="#mail">mail</a>
- <a href="#assert">assert</a>
- <a href="#test">test</a>
- <a href="#bye">bye</a>
- </code>
- <dt>Globals
- <dd><code>
- <a href="#nilSym">NIL</a>
- <a href="#pico">pico</a>
- <a href="#*CPU">*CPU</a>
- <a href="#*OS">*OS</a>
- <a href="#*DB">*DB</a>
- <a href="#T">T</a>
- <a href="#*Solo">*Solo</a>
- <a href="#*PPid">*PPid</a>
- <a href="#*Pid">*Pid</a>
- <a href="#@">@</a>
- <a href="#@@">@@</a>
- <a href="#@@@">@@@</a>
- <a href="#This">This</a>
- <a href="#*Prompt">*Prompt</a>
- <a href="#*Dbg">*Dbg</a>
- <a href="#*Zap">*Zap</a>
- <a href="#*Scl">*Scl</a>
- <a href="#*Class">*Class</a>
- <a href="#*Dbs">*Dbs</a>
- <a href="#*Run">*Run</a>
- <a href="#*Hup">*Hup</a>
- <a href="#*Sig1">*Sig1</a>
- <a href="#*Sig2">*Sig2</a>
- <a href="#^">^</a>
- <a href="#*Err">*Err</a>
- <a href="#*Msg">*Msg</a>
- <a href="#*Uni">*Uni</a>
- <a href="#*Led">*Led</a>
- <a href="#*Tsm">*Tsm</a>
- <a href="#*Adr">*Adr</a>
- <a href="#*Allow">*Allow</a>
- <a href="#*Fork">*Fork</a>
- <a href="#*Bye">*Bye</a>
- </code>
- </dl>
- <p><hr>
- <h2><a name="down">Download</a></h2>
- <p>The <code>PicoLisp</code> system can be downloaded from the <a
- href="http://software-lab.de/down.html">PicoLisp Download</a> page.
- <script type="text/javascript">
- var sortBtn;
- if (document.querySelectorAll) {
- sortBtn = document.createElement("input");
- sortBtn.setAttribute("type", "button");
- sortBtn.setAttribute("onclick", "sortFunWords()");
- sortBtn.value = "Sort Words Alphabetically";
- document.getElementById("sortBtnHome").appendChild(sortBtn);
- };
- function sortFunWords() {
- var dls = document.querySelectorAll("dl"), funDl = dls[dls.length-1];
- var cats = funDl.querySelectorAll("dd code");
- for (var c=0; c<cats.length; c++) {
- var aElems = cats[c].querySelectorAll("a"), aArr = [];
- for (var i=0; i<aElems.length; i++) { aArr.push(aElems[i]); }
- aArr.sort(function(a,b) { return (a.innerHTML < b.innerHTML) ? -1 : 1; });
- var dd = cats[c].parentNode;
- dd.removeChild(cats[c]);
- var newCode = document.createElement("code");
- dd.appendChild(newCode);
- for (var i=0; i<aArr.length; i++) {
- newCode.appendChild(aArr[i]);
- newCode.appendChild(document.createTextNode(" "));
- }
- }
- sortBtn.setAttribute("disabled", "disabled");
- }
- </script>
- </body>
- </html>
- <h1><a name="A">A</a></h1>
- <dl>
- <dt><a name="*Adr"><code>*Adr</code></a>
- <dd>A global variable holding the IP address of last recently accepted client.
- See also <code><a href="#listen">listen</a></code> and <code><a
- href="#accept">accept</a></code>.
- <pre><code>
- : *Adr
- -> "127.0.0.1"
- </code></pre>
- <dt><a name="adr"><code>(adr 'var) -> num</code></a>
- <dt><code>(adr 'num) -> var</code>
- <dd>Converts, in the first form, a variable <code>var</code> (a symbol or a cons
- pair) into <code>num</code> (actually an encoded pointer). A symbol will result
- in a negative number, and a cons pair in a positive number. The second form
- converts a pointer back into the original <code>var</code>.
- <pre><code>
- : (setq X (box 7))
- -> $53063416137450
- : (adr X)
- -> -2961853431592
- : (adr @)
- -> $53063416137450
- : (val @)
- -> 7
- </code></pre>
- <dt><a name="*Allow"><code>*Allow</code></a>
- <dd>A global variable holding allowed access patterns. If its value is
- non-<code>NIL</code>, it should contain a list where the CAR is an <code><a
- href="#idx">idx</a></code> tree of allowed items, and the CDR a list of
- prefix strings. See also <code><a href="#allow">allow</a></code>,
- <code><a href="#allowed">allowed</a></code> and <code><a
- href="#pre?">pre?</a></code>.
- <pre><code>
- : (allowed ("app/") # Initialize
- "!start" "!stop" "lib.css" "!psh" )
- -> NIL
- : (allow "!myFoo") # additional item
- -> "!myFoo"
- : (allow "myDir/" T) # additional prefix
- -> "myDir/"
- : *Allow
- -> (("!start" ("!psh" ("!myFoo")) "!stop" NIL "lib.css") "app/" "myDir/")
- : (idx *Allow) # items
- -> ("!myFoo" "!psh" "!start" "!stop" "lib.css")
- : (cdr *Allow) # prefixes
- -> ("app/" "myDir/")
- </code></pre>
- <dt><a name="+Alt"><code>+Alt</code></a>
- <dd>Prefix class specifying an alternative class for a <code><a
- href="#+relation">+relation</a></code>. This allows indexes or other
- side effects to be maintained in a class different from the current one. See
- also <a href="#dbase">Database</a>.
- <pre><code>
- (class +EuOrd +Ord) # EU-specific order subclass
- (rel nr (+Alt +Key +Number) +XyOrd) # Maintain the key in the +XyOrd index
- </code></pre>
- <dt><a name="+Any"><code>+Any</code></a>
- <dd>Class for unspecified relations, a subclass of <code><a
- href="#+relation">+relation</a></code>. Objects of that class accept
- and maintain any type of Lisp data. Used often when there is no other suitable
- relation class available. See also <a href="#dbase">Database</a>.
- <p>In the following example <code>+Any</code> is used simply for the reason that
- there is no direct way to specify dotted pairs:
- <pre><code>
- (rel loc (+Any)) # Locale, e.g. ("DE" . "de")
- </code></pre>
- <dt><a name="+Aux"><code>+Aux</code></a>
- <dd>Prefix class maintaining auxiliary keys for <code><a
- href="#+relation">+relation</a></code>s, in addition to <code><a
- href="#+Ref">+Ref</a></code> or <code><a
- href="#+Idx">+Idx</a></code> indexes. Expects a list of auxiliary
- attributes of the same object, and combines all keys in that order into a single
- index key. See also <code><a href="#+UB">+UB</a></code>, <code><a
- href="#aux">aux</a></code> and <a href="ref.html#dbase">Database</a>.
- <pre><code>
- (rel nr (+Ref +Number)) # Normal, non-unique index
- (rel nm (+Aux +Ref +String) (nr txt)) # Combined name/number/text index
- (rel txt (+Aux +Sn +Idx +String) (nr)) # Text/number plus tolerant text index
- </code></pre>
- <dt><a name="abort"><code>(abort 'cnt . prg) -> any</code></a>
- <dd>Aborts the execution of <code>prg</code> if it takes longer than
- <code>cnt</code> seconds, and returns <code>NIL</code>. Otherwise, the result of
- <code>prg</code> is returned. <code><a href="#alarm">alarm</a></code>
- is used internally, so care must be taken not to interfer with other calls to
- <code>alarm</code>.
- <pre><code>
- : (abort 20 (in Sock (rd))) # Wait maximally 20 seconds for socket data
- </code></pre>
- <dt><a name="abs"><code>(abs 'num) -> num</code></a>
- <dd>Returns the absolute value of the <code>num</code> argument.
- <pre><code>
- : (abs -7)
- -> 7
- : (abs 7)
- -> 7
- </code></pre>
- <dt><a name="accept"><code>(accept 'cnt) -> cnt | NIL</code></a>
- <dd>Accepts a connection on descriptor <code>cnt</code> (as received by <code><a
- href="#port">port</a></code>), and returns the new socket descriptor
- <code>cnt</code>. The global variable <code>*Adr</code> is set to the IP address
- of the client. See also <code><a href="#listen">listen</a></code>,
- <code><a href="#connect">connect</a></code> and <code><a
- href="#*Adr">*Adr</a></code>.
- <pre><code>
- : (setq *Socket
- (accept (port 6789)) ) # Accept connection at port 6789
- -> 4
- </code></pre>
- <dt><a name="accu"><code>(accu 'var 'any 'num)</code></a>
- <dd>Accumulates <code>num</code> into a sum, using the key <code>any</code> in
- an association list stored in <code>var</code>. See also <code><a
- href="#assoc">assoc</a></code>.
- <pre><code>
- : (off Sum)
- -> NIL
- : (accu 'Sum 'a 1)
- -> (a . 1)
- : (accu 'Sum 'a 5)
- -> 6
- : (accu 'Sum 22 100)
- -> (22 . 100)
- : Sum
- -> ((22 . 100) (a . 6))
- </code></pre>
- <dt><a name="acquire"><code>(acquire 'sym) -> flg</code></a>
- <dd>Tries to acquire the mutex represented by the file <code>sym</code>, by
- obtaining an exclusive lock on that file with <code><a
- href="#ctl">ctl</a></code>, and then trying to write the PID of the
- current process into that file. It fails if the file already holds the PID of
- some other existing process. See also <code><a
- href="#release">release</a></code>, <code><a
- href="#*Pid">*Pid</a></code> and <code><a
- href="#rc">rc</a></code>.
- <pre><code>
- : (acquire "sema1")
- -> 28255
- </code></pre>
- <dt><a name="alarm"><code>(alarm 'cnt . prg) -> cnt</code></a>
- <dd>Sets an alarm timer scheduling <code>prg</code> to be executed after
- <code>cnt</code> seconds, and returns the number of seconds remaining until any
- previously scheduled alarm was due to be delivered. Calling <code>(alarm
- 0)</code> will cancel an alarm. See also <code><a
- href="#abort">abort</a></code>, <code><a
- href="#sigio">sigio</a></code>, <code><a
- href="#*Hup">*Hup</a></code> and <code><a
- href="#*Sig1">*Sig[12]</a></code>.
- <pre><code>
- : (prinl (tim$ (time) T)) (alarm 10 (prinl (tim$ (time) T)))
- 16:36:14
- -> 0
- : 16:36:24
- : (alarm 10 (bye 0))
- -> 0
- $
- </code></pre>
- <dt><a name="align"><code>(align 'cnt 'any) -> sym</code></a>
- <dt><code>(align 'lst 'any ..) -> sym</code>
- <dd>Returns a transient symbol with all <code>any</code> arguments <code><a
- href="#pack">pack</a></code>ed in an aligned format. In the first form,
- <code>any</code> will be left-aligned if <code>cnt</code> ist negative,
- otherwise right-aligned. In the second form, all <code>any</code> arguments are
- packed according to the numbers in <code>lst</code>. See also <code><a
- href="#tab">tab</a></code>, <code><a
- href="#center">center</a></code> and <code><a
- href="#wrap">wrap</a></code>.
- <pre><code>
- : (align 4 "a")
- -> " a"
- : (align -4 12)
- -> "12 "
- : (align (4 4 4) "a" 12 "b")
- -> " a 12 b"
- </code></pre>
- <dt><a name="all"><code>(all ['T | '0]) -> lst</code></a>
- <dd>Returns a new list of all <a href="#internal">internal</a> symbols
- in the system (if called without arguments, or with <code>NIL</code>). Otherwise
- (if the argument is <code>T</code>), all current <a
- href="#transient">transient</a> symbols are returned. Else all current
- <a href="#external">external</a> symbols are returned.
- <pre><code>
- : (all) # All internal symbols
- -> (inc> leaf nil inc! accept ...
- # Find all symbols starting with an underscore character
- : (filter '((X) (= "_" (car (chop X)))) (all))
- -> (_put _nacs _oct _lintq _lst _map _iter _dbg2 _getLine _led ...
- </code></pre>
- <dt><a name="allow"><code>(allow 'sym ['flg]) -> sym</code></a>
- <dd>Maintains an index structure of allowed access patterns in the global
- variable <code><a href="#*Allow">*Allow</a></code>. If the value of
- <code>*Allow</code> is non-<code>NIL</code>, <code>sym</code> is added to the
- <code><a href="#idx">idx</a></code> tree in the CAR of
- <code>*Allow</code> (if <code>flg</code> is <code>NIL</code>), or to the list of
- prefix strings (if <code>flg</code> is non-<code>NIL</code>). See also <code><a
- href="#allowed">allowed</a></code>.
- <pre><code>
- : *Allow
- -> (("!start" ("!psh") "!stop" NIL "lib.css") "app/")
- : (allow "!myFoo") # additionally allowed item
- -> "!myFoo"
- : (allow "myDir/" T) # additionally allowed prefix
- -> "myDir/"
- </code></pre>
- <dt><a name="allowed"><code>(allowed lst [sym ..])</code></a>
- <dd>Creates an index structure of allowed access patterns in the global variable
- <code><a href="#*Allow">*Allow</a></code>. <code>lst</code> should
- consist of prefix strings (to be checked at runtime with <code><a
- href="#pre?">pre?</a></code>), and the <code>sym</code> arguments
- should specify the initially allowed items. See also <code><a
- href="#allow">allow</a></code>.
- <pre><code>
- : (allowed ("app/") # allowed prefixes
- "!start" "!stop" "lib.css" "!psh" ) # allowed items
- -> NIL
- </code></pre>
- <dt><a name="and"><code>(and 'any ..) -> any</code></a>
- <dd>Logical AND. The expressions <code>any</code> are evaluated from left to
- right. If <code>NIL</code> is encountered, <code>NIL</code> is returned
- immediately. Else the result of the last expression is returned.
- <pre><code>
- : (and (= 3 3) (read))
- abc # User input
- -> abc
- : (and (= 3 4) (read))
- -> NIL
- </code></pre>
- <dt><a name="any"><code>(any 'sym) -> any</code></a>
- <dd>Parses <code>any</code> from the name of <code>sym</code>. This is the
- reverse operation of <code><a href="#sym">sym</a></code>. See also
- <code><a href="#str">str</a></code>, <code>(any 'sym)</code> is
- equivalent to <code>(car (str 'sym))</code>.
- <pre><code>
- : (any "(a b # Comment^Jc d)")
- -> (a b c d)
- : (any "\"A String\"")
- -> "A String"
- </code></pre>
- <dt><a name="append"><code>(append 'lst ..) -> lst</code></a>
- <dd>Appends all argument lists. See also <code><a
- href="#conc">conc</a></code>, <code><a
- href="#insert">insert</a></code>, <code><a
- href="#delete">delete</a></code> and <code><a
- href="#remove">remove</a></code>.
- <pre><code>
- : (append '(a b c) (1 2 3))
- -> (a b c 1 2 3)
- : (append (1) (2) (3) 4)
- -> (1 2 3 . 4)
- </code></pre>
- <dt><a name="append/3"><code>append/3</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that succeeds if appending the
- first two list arguments is equal to the third argument. See also <code><a
- href="#append">append</a></code> and <code><a
- href="#member/2">member/2</a></code>.
- <pre><code>
- : (? (append @X @Y (a b c)))
- @X=NIL @Y=(a b c)
- @X=(a) @Y=(b c)
- @X=(a b) @Y=(c)
- @X=(a b c) @Y=NIL
- -> NIL
- </code></pre>
- <dt><a name="apply"><code>(apply 'fun 'lst ['any ..]) -> any</code></a>
- <dd>Applies <code>fun</code> to <code>lst</code>. If additional <code>any</code>
- arguments are given, they are applied as leading elements of <code>lst</code>.
- <code>(apply 'fun 'lst 'any1 'any2)</code> is equivalent to <code>(apply 'fun
- (cons 'any1 'any2 'lst))</code>.
- <pre><code>
- : (apply + (1 2 3))
- -> 6
- : (apply * (5 6) 3 4)
- -> 360
- : (apply '((X Y Z) (* X (+ Y Z))) (3 4 5))
- -> 27
- : (apply println (3 4) 1 2)
- 1 2 3 4
- -> 4
- </code></pre>
- <dt><a name="arg"><code>(arg ['cnt]) -> any</code></a>
- <dd>Can only be used inside functions with a variable number of arguments (with
- <code>@</code>). If <code>cnt</code> is not given, the value that was returned
- from the last call to <code>next</code>) is returned. Otherwise, the
- <code>cnt</code>'th remaining argument is returned. See also <code><a
- href="#args">args</a></code>, <code><a
- href="#next">next</a></code>, <code><a
- href="#rest">rest</a></code> and <code><a
- href="#pass">pass</a></code>.
- <pre><code>
- : (de foo @ (println (next) (arg))) # Print argument twice
- -> foo
- : (foo 123)
- 123 123
- -> 123
- : (de foo @
- (println (arg 1) (arg 2))
- (println (next))
- (println (arg 1) (arg 2)) )
- -> foo
- : (foo 'a 'b 'c)
- a b
- a
- b c
- -> c
- </code></pre>
- <dt><a name="args"><code>(args) -> flg</code></a>
- <dd>Can only be used inside functions with a variable number of arguments (with
- <code>@</code>). Returns <code>T</code> when there are more arguments to be
- fetched from the internal list. See also <code><a
- href="#next">next</a></code>, <code><a
- href="#arg">arg</a></code>, <code><a
- href="#rest">rest</a></code> and <code><a
- href="#pass">pass</a></code>.
- <pre><code>
- : (de foo @ (println (args))) # Test for arguments
- -> foo
- : (foo) # No arguments
- NIL
- -> NIL
- : (foo NIL) # One argument
- T
- -> T
- : (foo 123) # One argument
- T
- -> T
- </code></pre>
- <dt><a name="argv"><code>(argv [var ..] [. sym]) -> lst|sym</code></a>
- <dd>If called without arguments, <code>argv</code> returns a list of strings
- containing all remaining command line arguments. Otherwise, the
- <code>var/sym</code> arguments are subsequently bound to the command line
- arguments. A hyphen "<code>-</code>" can be used to inhibit the automatic
- <code>load</code>ing further arguments. See also <code><a
- href="#cmd">cmd</a></code>, <a href="ref.html#invoc">Invocation</a> and
- <code><a href="#opt">opt</a></code>.
- <pre><code>
- $ pil -"println 'OK" - abc 123 +
- OK
- : (argv)
- -> ("abc" "123")
- : (argv A B)
- -> "123"
- : A
- -> "abc"
- : B
- -> "123"
- : (argv . Lst)
- -> ("abc" "123")
- : Lst
- -> ("abc" "123")
- </code></pre>
- <dt><a name="as"><code>(as 'any1 . any2) -> any2 | NIL</code></a>
- <dd>Returns <code>any2</code> unevaluated when <code>any1</code> evaluates to
- non-<code>NIL</code>. Otherwise <code>NIL</code> is returned. <code>(as Flg A B
- C)</code> is equivalent to <code>(and Flg '(A B C))</code>. See also <code><a
- href="#quote">quote</a></code>.
- <pre><code>
- : (as (= 3 3) A B C)
- -> (A B C)
- </code></pre>
- <dt><a name="asoq"><code>(asoq 'any 'lst) -> lst</code></a>
- <dd>Searches an association list. Returns the first element from
- <code>lst</code> with <code>any</code> as its CAR, or <code>NIL</code> if no
- match is found. <code><a href="#==">==</a></code> is used for
- comparison (pointer equality). See also <code><a
- href="#assoc">assoc</a></code>, <code><a
- href="#push1q">push1q</a></code>, <code><a
- href="#delq">delq</a></code>, <code><a
- href="#memq">memq</a></code>, <code><a
- href="#mmeq">mmeq</a></code> and <a href="ref.html#cmp">Comparing</a>.
- <pre><code>
- : (asoq 999 '((999 1 2 3) (b . 7) ("ok" "Hello")))
- -> NIL
- : (asoq 'b '((999 1 2 3) (b . 7) ("ok" "Hello")))
- -> (b . 7)
- </code></pre>
- <dt><a name="assert"><code>(assert exe ..) -> prg | NIL</code></a>
- <dd>When in debug mode (<code><a href="#*Dbg">*Dbg</a></code> is
- non-<code>NIL</code>), <code>assert</code> returns a <code>prg</code> list which
- tests all <code>exe</code> conditions, and issues an error via <code><a
- href="#quit">quit</a></code> if one of the results evaluates to
- <code>NIL</code>. Otherwise, <code>NIL</code> is returned. Used typically in
- combination with the <code>~</code> tilde <code><a
- href="#macro-io">read-macro</a></code> to insert the test code only when
- in debug mode. See also <code><a href="#test">test</a></code>.
- <pre><code>
- # Start in debug mode
- $ pil +
- : (de foo (N)
- ~(assert (>= 90 N 10))
- (bar N) )
- -> foo
- : (pp 'foo) # Pretty-print 'foo'
- (de foo (N)
- (unless (>= 90 N 10) # Assertion code exists
- (quit "'assert' failed" '(>= 90 N 10)) )
- (bar N) )
- -> foo
- : (foo 7) # Try it
- (>= 90 N 10) -- Assertion failed
- ?
- # Start in non-debug mode
- $ pil
- : (de foo (N)
- ~(assert (>= 90 N 10))
- (bar N) )
- -> foo
- : (pp 'foo) # Pretty-print 'foo'
- (de foo (N)
- (bar N) ) # Assertion code does not exist
- -> foo
- </code></pre>
- <dt><a name="asserta"><code>(asserta 'lst) -> lst</code></a>
- <dd>Inserts a new <a href="#pilog">Pilog</a> fact or rule before all
- other rules. See also <code><a href="#be">be</a></code>, <code><a
- href="#clause">clause</a></code>, <code><a
- href="#assertz">assertz</a></code> and <code><a
- href="#retract">retract</a></code>.
- <pre><code>
- : (be a (2)) # Define two facts
- -> a
- : (be a (3))
- -> a
- : (asserta '(a (1))) # Insert new fact in front
- -> ((1))
- : (? (a @N)) # Query
- @N=1
- @N=2
- @N=3
- -> NIL
- </code></pre>
- <dt><a name="asserta/1"><code>asserta/1</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that inserts a new fact or rule
- before all other rules. See also <code><a
- href="#asserta">asserta</a></code>, <code><a
- href="#assertz/1">assertz/1</a></code> and <code><a
- href="#retract/1">retract/1</a></code>.
- <pre><code>
- : (? (asserta (a (2))))
- -> T
- : (? (asserta (a (1))))
- -> T
- : (rules 'a)
- 1 (be a (1))
- 2 (be a (2))
- -> a
- </code></pre>
- <dt><a name="assertz"><code>(assertz 'lst) -> lst</code></a>
- <dd>Appends a new <a href="#pilog">Pilog</a> fact or rule behind all
- other rules. See also <code><a href="#be">be</a></code>, <code><a
- href="#clause">clause</a></code>, <code><a
- href="#asserta">asserta</a></code> and <code><a
- href="#retract">retract</a></code>.
- <pre><code>
- : (be a (1)) # Define two facts
- -> a
- : (be a (2))
- -> a
- : (assertz '(a (3))) # Append new fact at the end
- -> ((3))
- : (? (a @N)) # Query
- @N=1
- @N=2
- @N=3
- -> NIL
- </code></pre>
- <dt><a name="assertz/1"><code>assertz/1</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that appends a new fact or rule
- behind all other rules. See also <code><a
- href="#assertz">assertz</a></code>, <code><a
- href="#asserta/1">asserta/1</a></code> and <code><a
- href="#retract/1">retract/1</a></code>.
- <pre><code>
- : (? (assertz (a (1))))
- -> T
- : (? (assertz (a (2))))
- -> T
- : (rules 'a)
- 1 (be a (1))
- 2 (be a (2))
- -> a
- </code></pre>
- <dt><a name="assoc"><code>(assoc 'any 'lst) -> lst</code></a>
- <dd>Searches an association list. Returns the first element from
- <code>lst</code> with its CAR equal to <code>any</code>, or <code>NIL</code> if
- no match is found. See also <code><a href="#asoq">asoq</a></code> and
- <code><a href="#rassoc">rassoc</a></code>.
- <pre><code>
- : (assoc "b" '((999 1 2 3) ("b" . 7) ("ok" "Hello")))
- -> ("b" . 7)
- : (assoc 999 '((999 1 2 3) ("b" . 7) ("ok" "Hello")))
- -> (999 1 2 3)
- : (assoc 'u '((999 1 2 3) ("b" . 7) ("ok" "Hello")))
- -> NIL
- </code></pre>
- <dt><a name="at"><code>(at '(cnt1 . cnt2|NIL) . prg) -> any</code></a>
- <dd>Increments <code>cnt1</code> (destructively), and returns <code>NIL</code>
- when it is less than <code>cnt2</code>. Both <code>cnt1</code> and
- <code>cnt2</code> should be positive. Otherwise, <code>cnt1</code> is reset to
- zero and <code>prg</code> is executed. Returns the result of <code>prg</code>.
- If <code>cnt2</code> is <code>NIL</code>, nothing is done, and <code>NIL</code>
- is returned immediately.
- <pre><code>
- : (do 11 (prin ".") (at (0 . 3) (prin "!")))
- ...!...!...!..-> NIL
- </code></pre>
- <dt><a name="atom"><code>(atom 'any) -> flg</code></a> <dd>Returns
- <code>T</code> when the argument <code>any</code> is an atom (a number or a
- symbol). See also <code><a href="#num?">num?</a></code>, <code><a
- href="#sym?">sym?</a></code> and <code><a
- href="#pair">pair</a></code>.
- <pre><code>
- : (atom 123)
- -> T
- : (atom 'a)
- -> T
- : (atom NIL)
- -> T
- : (atom (123))
- -> NIL
- </code></pre>
- <dt><a name="aux"><code>(aux 'sym 'cls ['hook] 'any ..) -> sym</code></a>
- <dd>Returns a database object of class <code>cls</code>, where the value for
- <code>sym</code> corresponds to <code>any</code> and the following arguments.
- <code>sym</code>, <code>cls</code> and <code>hook</code> should specify a
- <code><a href="#tree">tree</a></code> for <code>cls</code> or one of
- its superclasses, for a relation with auxiliary keys. For multi-key accesses,
- <code>aux</code> is similar to - but faster than - <code>db</code>, because it
- can use a single tree access. See also <code><a
- href="#db">db</a></code>, <code><a
- href="#collect">collect</a></code>, <code><a
- href="#fetch">fetch</a></code>, <code><a
- href="#init">init</a></code>, <code><a
- href="#step">step</a></code> and <code><a
- href="#+Aux">+Aux</a></code>.
- <pre><code>
- (class +PS +Entity)
- (rel par (+Dep +Joint) (sup) ps (+Part)) # Part
- (rel sup (+Aux +Ref +Link) (par) NIL (+Supp)) # Supplier
- ...
- (aux 'sup '+PS # Access PS object
- (db 'nr '+Supp 1234)
- (db 'nr '+Part 5678) )
- </code></pre>
- </dl>
- <h1><a name="B">B</a></h1>
- <dl>
- <dt><a name="*Blob"><code>*Blob</code></a>
- <dd>A global variable holding the pathname of the database blob directory. See
- also <code><a href="#blob">blob</a></code>.
- <pre><code>
- : *Blob
- -> "blob/app/"
- </code></pre>
- <dt><a name="*Bye"><code>*Bye</code></a>
- <dd>A global variable holding a (possibly empty) <code>prg</code> body, to be
- executed just before the termination of the PicoLisp interpreter. See also
- <code><a href="#bye">bye</a></code> and <code><a
- href="#tmp">tmp</a></code>.
- <pre><code>
- : (push1 '*Bye '(call 'rm "myfile.tmp")) # Remove a temporary file
- -> (call 'rm "myfile.tmp")
- </code></pre>
- <dt><a name="+Bag"><code>+Bag</code></a>
- <dd>Class for a list of arbitrary relations, a subclass of <code><a
- href="#+relation">+relation</a></code>. Objects of that class maintain
- a list of heterogeneous relations. Typically used in combination with the
- <code><a href="#+List">+List</a></code> prefix class, to maintain small
- two-dimensional tables within objects. See also <a
- href="#dbase">Database</a>.
- <pre><code>
- (rel pos (+List +Bag) # Positions
- ((+Ref +Link) NIL (+Item)) # Item
- ((+Number) 2) # Price
- ((+Number)) # Quantity
- ((+String)) # Memo text
- ((+Number) 2) ) # Total amount
- </code></pre>
- <dt><a name="+Blob"><code>+Blob</code></a>
- <dd>Class for blob relations, a subclass of <code><a
- href="#+relation">+relation</a></code>. Objects of that class maintain
- blobs, as stubs in database objects pointing to actual files for arbitrary
- (often binary) data. The files themselves reside below the path specified by the
- <code><a href="#*Blob">*Blob</a></code> variable. See also <a
- href="#dbase">Database</a>.
- <pre><code>
- (rel jpg (+Blob)) # Picture
- </code></pre>
- <dt><a name="+Bool">+Bool<code></code></a>
- <dd>Class for boolean relations, a subclass of <code><a
- href="#+relation">+relation</a></code>. Objects of that class expect
- either <code>T</code> or <code>NIL</code> as value (though, as always, only
- non-<code>NIL</code> will be physically stored in objects). See also <a
- href="#dbase">Database</a>.
- <pre><code>
- (rel ok (+Ref +Bool)) # Indexed flag
- </code></pre>
- <dt><a name="balance"><code>(balance 'var 'lst ['flg])</code></a>
- <dd>Builds a balanced binary <code><a href="#idx">idx</a></code> tree
- in <code>var</code>, from the sorted list in <code>lst</code>. Normally (if
- random or, in the worst case, ordered data) are inserted with <code>idx</code>,
- the tree will not be balanced. But if <code>lst</code> is properly sorted, its
- contents will be inserted in an optimally balanced way. If <code>flg</code> is
- non-<code>NIL</code>, the index tree will be augmented instead of being
- overwritten. See also <code><a href="#cmp">Comparing</a></code> and
- <code><a href="#sort">sort</a></code>.
- <pre><code>
- # Normal idx insert
- : (off I)
- -> NIL
- : (for X (1 4 2 5 3 6 7 9 8) (idx 'I X T))
- -> NIL
- : (depth I)
- -> (7 . 4)
- # Balanced insert
- : (balance 'I (sort (1 4 2 5 3 6 7 9 8)))
- -> NIL
- : (depth I)
- -> 4
- # Augment
- : (balance 'I (sort (10 40 20 50 30 60 70 90 80)) T)
- -> NIL
- : (idx 'I)
- -> (1 2 3 4 5 6 7 8 9 10 20 30 40 50 60 70 80 90)
- </code></pre>
- <dt><a name="basename"><code>(basename 'any) -> sym</code></a>
- <dd>Returns the filename part of a path name <code>any</code>. See also <code><a
- href="#dirname">dirname</a></code> and <code><a
- href="#path">path</a></code>.
- <pre><code>
- : (basename "a/b/c/d")
- -> "d"
- </code></pre>
- <dt><a name="be"><code>(be sym . any) -> sym</code></a>
- <dd>Declares a <a href="#pilog">Pilog</a> fact or rule for the
- <code>sym</code> argument, by concatenating the <code>any</code> argument to the
- <code>T</code> property of <code>sym</code>. Groups of declarations are
- collected for a given <code>sym</code>. When <code>sym</code> changes, i.e. when
- it differs from the one in the previous declaration, the current group is
- considered to be complete and a new group is started. Later <code>be</code>
- declarations for a previously completed symbol will reset its rules, to allow
- repeated re<code><a href="#load">load</a></code>ing of source files.
- See also <code><a href="#clause">clause</a></code>, <code><a
- href="#asserta">asserta</a></code>, <code><a
- href="#assertz">assertz</a></code>, <code><a
- href="#retract">retract</a></code>, <code><a
- href="#rules">rules</a></code>, <code><a
- href="#goal">goal</a></code> and <code><a
- href="#prove">prove</a></code>.
- <pre><code>
- : (be likes (John Mary))
- -> likes
- : (be likes (John @X) (likes @X wine) (likes @X food))
- -> likes
- : (get 'likes T)
- -> (((John Mary)) ((John @X) (likes @X wine) (likes @X food)))
- : (rules 'likes)
- 1 (be likes (John Mary))
- 2 (be likes (John @X) (likes @X wine) (likes @X food))
- -> likes
- : (? (likes John @X))
- @X=Mary
- -> NIL
- </code></pre>
- <dt><a name="beep"><code>(beep) -> any</code></a>
- <dd>Send the bell character to the console. See also <code><a
- href="#space">space</a></code>, <code><a
- href="#prin">prin</a></code> and <code><a
- href="#char">char</a></code>.
- <pre><code>
- : (beep)
- -> "^G"
- </code></pre>
- <dt><a name="bench"><code>(bench . prg) -> any</code></a>
- <dd>(Debug mode only) Benchmarks <code>prg</code>, by printing the time it took
- to execute, and returns the result. See also <code><a
- href="#usec">usec</a></code>.
- <pre><code>
- : (bench (wait 2000))
- 1.996 sec
- -> NIL
- </code></pre>
- <dt><a name="bin"><code>(bin 'num ['num]) -> sym</code></a>
- <dt><code>(bin 'sym) -> num</code>
- <dd>Converts a number <code>num</code> to a binary string, or a binary string
- <code>sym</code> to a number. In the first case, if the second argument is
- given, the result is separated by spaces into groups of such many digits. See
- also <code><a href="#oct">oct</a></code>, <code><a
- href="#hex">hex</a></code>, <code><a
- href="#fmt64">fmt64</a></code>, <code><a
- href="#hax">hax</a></code> and <code><a
- href="#format">format</a></code>.
- <pre><code>
- : (bin 73)
- -> "1001001"
- : (bin "1001001")
- -> 73
- : (bin 1234567 4)
- -> "1 0010 1101 0110 1000 0111"
- </code></pre>
- <dt><a name="bind"><code>(bind 'sym|lst . prg) -> any</code></a>
- <dd>Binds value(s) to symbol(s). The first argument must evaluate to a symbol,
- or a list of symbols or symbol-value pairs. The values of these symbols are
- saved (and the symbols bound to the values in the case of pairs),
- <code>prg</code> is executed, then the symbols are restored to their original
- values. During execution of <code>prg</code>, the values of the symbols can be
- temporarily modified. The return value is the result of <code>prg</code>. See
- also <code><a href="#let">let</a></code>, <code><a
- href="#job">job</a></code> and <code><a
- href="#use">use</a></code>.
- <pre><code>
- : (setq X 123) # X is 123
- -> 123
- : (bind 'X (setq X "Hello") (println X)) # Set X to "Hello", print it
- "Hello"
- -> "Hello"
- : (bind '((X . 3) (Y . 4)) (println X Y) (* X Y))
- 3 4
- -> 12
- : X
- -> 123 # X is restored to 123
- </code></pre>
- <dt><a name="bit?"><code>(bit? 'num ..) -> num | NIL</code></a>
- <dd>Returns the first <code>num</code> argument when all bits which are 1 in the
- first argument are also 1 in all following arguments, otherwise
- <code>NIL</code>. When one of those arguments evaluates to <code>NIL</code>, it
- is returned immediately. See also <code><a href="#&">&</a></code>,
- <code><a href="#|">|</a></code> and <code><a
- href="#x|">x|</a></code>.
- <pre><code>
- : (bit? 7 15 255)
- -> 7
- : (bit? 1 3)
- -> 1
- : (bit? 1 2)
- -> NIL
- </code></pre>
- <dt><a name="blob"><code>(blob 'obj 'sym) -> sym</code></a>
- <dd>Returns the blob file name for <code>var</code> in <code>obj</code>. See
- also <code><a href="#*Blob">*Blob</a></code>, <code><a
- href="#blob!">blob!</a></code> and <code><a
- href="#pack">pack</a></code>.
- <pre><code>
- : (show (db 'nr '+Item 1))
- {3-1} (+Item)
- jpg
- pr 29900
- inv 100
- sup {2-1}
- nm "Main Part"
- nr 1
- -> {3-1}
- : (blob '{3-1} 'jpg)
- -> "blob/app/3/-/1.jpg"
- </code></pre>
- <dt><a name="blob!"><code>(blob! 'obj 'sym 'file)</code></a>
- <dd>Stores the contents of <code>file</code> in a <code><a
- href="#blob">blob</a></code>. See also <code><a
- href="#entityMesssages">put!></a></code>.
- <pre><code>
- (blob! *ID 'jpg "picture.jpg")
- </code></pre>
- <dt><a name="bool"><code>(bool 'any) -> flg</code></a>
- <dd>Returns <code>T</code> when the argument <code>any</code> is
- non-<code>NIL</code>. This function is only needed when <code>T</code> is
- strictly required for a "true" condition (Usually, any non-<code>NIL</code>
- value is considered to be "true"). See also <code><a
- href="#flg?">flg?</a></code>.
- <pre><code>
- : (and 3 4)
- -> 4
- : (bool (and 3 4))
- -> T
- </code></pre>
- <dt><a name="bool/3"><code>bool/3</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that succeeds if the first
- argument has the same truth value as the result of applying the <code><a
- href="#get">get</a></code> algorithm to the following arguments.
- Typically used as filter predicate in <code><a
- href="#select/3">select/3</a></code> database queries. See also
- <code><a href="#bool">bool</a></code>, <code><a
- href="#isa/2">isa/2</a></code>, <code><a
- href="#same/3">same/3</a></code>, <code><a
- href="#range/3">range/3</a></code>, <code><a
- href="#head/3">head/3</a></code>, <code><a
- href="#fold/3">fold/3</a></code>, <code><a
- href="#part/3">part/3</a></code> and <code><a
- href="#tolr/3">tolr/3</a></code>.
- <pre><code>
- : (? @OK NIL # Find orders where the 'ok' flag is not set
- (db nr +Ord @Ord)
- (bool @OK @Ord ok) )
- @OK=NIL @Ord={3-7}
- -> NIL
- </code></pre>
- <dt><a name="box"><code>(box 'any) -> sym</code></a>
- <dd>Creates and returns a new anonymous symbol. The initial value is set to the
- <code>any</code> argument. See also <code><a href="#new">new</a></code>
- and <code><a href="#box?">box?</a></code>.
- <pre><code>
- : (show (box '(A B C)))
- $134425627 (A B C)
- -> $134425627
- </code></pre>
- <dt><a name="box?"><code>(box? 'any) -> sym | NIL</code></a>
- <dd>Returns the argument <code>any</code> when it is an anonymous symbol,
- otherwise <code>NIL</code>. See also <code><a
- href="#box">box</a></code>, <code><a
- href="#str?">str?</a></code> and <code><a
- href="#ext?">ext?</a></code>.
- <pre><code>
- : (box? (new))
- -> $134563468
- : (box? 123)
- -> NIL
- : (box? 'a)
- -> NIL
- : (box? NIL)
- -> NIL
- </code></pre>
- <dt><a name="bt"><code>(bt ['flg]) -> flg</code></a>
- <dd>(Debug mode 64-bit version only) Formatted stack backtrace printing (see
- <code><a href="#trail">trail</a></code>) for the current point of
- program execution. For each bind frame, the function call (reduced with <code><a
- href="#less">less</a></code>) is <code><a
- href="#pretty">pretty</a></code>-printed, followed by indented
- variable-value-pairs. If <code>flg</code> is <code>NIL</code>, <code>bt</code>
- then waits for console input, and terminates when a non-empty line is entered
- (like <code><a href="#more">more</a></code>). See also <code><a
- href="#up">up</a></code> and <code><a
- href="#env">env</a></code>.
- <pre><code>
- : (de f (A B)
- (let F 7
- (g (inc A) (dec B)) ) )
- -> f
- : (de g (C D)
- (let G 8
- (/ C D) ) )
- -> g
- : (f 2 1)
- !? (/ C D)
- Div/0
- ? (bt)
- (g (inc A) (dec B))
- C 3
- D 0
- G 8
- (f 2 1)
- A 2
- B 1
- F 7
- -> NIL
- </code></pre>
- <dt><a name="by"><code>(by 'fun1 'fun2 'lst ..) -> lst</code></a>
- <dd>Applies <code>fun1</code> to each element of <code>lst</code>. When
- additional <code>lst</code> arguments are given, their elements are also passed
- to <code>fun1</code>. Each result of <code>fun1</code> is CONSed with its
- corresponding argument form the original <code>lst</code>, and collected into a
- list which is passed to <code>fun2</code>. For the list returned from
- <code>fun2</code>, the CAR elements returned by <code>fun1</code> are
- (destructively) removed from each element ("decorate-apply-undecorate" idiom).
- <pre><code>
- : (let (A 1 B 2 C 3) (by val sort '(C A B)))
- -> (A B C)
- : (by '((N) (bit? 1 N)) group (3 11 6 2 9 5 4 10 12 7 8 1))
- -> ((3 11 9 5 7 1) (6 2 4 10 12 8))
- </code></pre>
- <dt><a name="bye"><code>(bye 'cnt|NIL)</code></a>
- <dd>Executes all pending <code><a href="#finally">finally</a></code>
- expressions, closes all open files, executes the <code>VAL</code> of the global
- variable <code><a href="#*Bye">*Bye</a></code> (should be a
- <code>prg</code>), flushes standard output, and then exits the PicoLisp
- interpreter. The process return value is <code>cnt</code>, or 0 if the argument
- is missing or <code>NIL</code>.
- <pre><code>
- : (setq *Bye '((println 'OK) (println 'bye)))
- -> ((println 'OK) (println 'bye))
- : (bye)
- OK
- bye
- $
- </code></pre>
- <dt><a name="bytes"><code>(bytes 'any) -> cnt</code></a>
- <dd>Returns the number of bytes <code>any</code> would occupy in encoded binary
- format (as generated by <code><a href="#pr">pr</a></code>). See also
- <code><a href="#size">size</a></code> and <code><a
- href="#length">length</a></code>.
- <pre><code>
- : (bytes "abc")
- -> 4
- : (bytes "äbc")
- -> 5
- : (bytes 127)
- -> 2
- : (bytes 128)
- -> 3
- : (bytes (101 (102) 103))
- -> 10
- : (bytes (101 102 103 .))
- -> 9
- </code></pre>
- </dl>
- <h1><a name="C">C</a></h1>
- <dl>
- <dt><a name="*CPU"><code>*CPU</code></a>
- <dd>(64-bit version only) A global variable holding the target CPU
- (architecture). Possible values include <code>"x86-64"</code>,
- <code>"ppc64"</code>, <code>"emu"</code> or <code>"JVM"</code>. See also
- <code><a href="#*OS">*OS</a></code> and <code><a
- href="#version">version</a></code>.
- <pre><code>
- : *CPU
- -> "x86-64"
- </code></pre>
- <dt><a name="*Class"><code>*Class</code></a>
- <dd>A global variable holding the current class. See also <a
- href="#oop">OO Concepts</a>, <code><a
- href="#class">class</a></code>, <code><a
- href="#extend">extend</a></code>, <code><a
- href="#dm">dm</a></code> and <code><a
- href="#var">var</a></code> and <code><a
- href="#rel">rel</a></code>.
- <pre><code>
- : (class +Test)
- -> +Test
- : *Class
- -> +Test
- </code></pre>
- <dt><a name="cache"><code>(cache 'var 'any . prg) -> any</code></a>
- <dd>Speeds up some calculations by maintaining a tree of previously calculated
- results in an <code><a href="#idx">idx</a></code> structure
- ("memoization") in <code>var</code>. A <code><a
- href="#hash">hash</a></code> of the argument <code>any</code> is used
- internally to build the index key.
- <pre><code>
- : (de fibonacci (N)
- (cache '(NIL) N
- (if (>= 2 N)
- 1
- (+ (fibonacci (dec N)) (fibonacci (- N 2))) ) ) )
- -> fibonacci
- : (fibonacci 22)
- -> 17711
- : (fibonacci 10000)
- -> 3364476487643178326662161200510754331030 ... # (2090 digits)
- </code></pre>
- <dt><a name="call"><code>(call 'any ..) -> flg</code></a>
- <dd>Calls an external system command. The <code>any</code> arguments specify the
- command and its arguments. Returns <code>T</code> if the command was executed
- successfully. The (system dependent) exit status code of the child process is
- stored in the global variable <code><a href="#@@">@@</a></code>. See
- also <code><a href="#exec">exec</a></code>.
- <pre><code>
- : (when (call 'test "-r" "file.l") # Test if file exists and is readable
- (load "file.l") # Load it
- (call 'rm "file.l") ) # Remove it
- : (cons (call "sh" "-c" "kill -SEGV $$") @@ (hex @@))
- -> (NIL 11 . "B")
- </code></pre>
- <dt><a name="call/1"><code>call/1</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that succeeds if the argument
- term can be proven.
- <pre><code>
- : (be mapcar (@ NIL NIL))
- -> mapcar
- : (be mapcar (@P (@X . @L) (@Y . @M))
- (call @P @X @Y) # Call the given predicate
- (mapcar @P @L @M) )
- -> mapcar
- : (? (mapcar permute ((a b c) (d e f)) @X))
- @X=((a b c) (d e f))
- @X=((a b c) (d f e))
- @X=((a b c) (e d f))
- ...
- @X=((a c b) (d e f))
- @X=((a c b) (d f e))
- @X=((a c b) (e d f))
- ...
- </code></pre>
- <dt><a name="can"><code>(can 'msg) -> lst</code></a>
- <dd>(Debug mode only) Returns a list of all classes that accept the message
- <code>msg</code>. See also <a href="#oop">OO Concepts</a>, <code><a
- href="#class">class</a></code>, <code><a
- href="#has">has</a></code>, <code><a
- href="#dep">dep</a></code>, <code><a
- href="#what">what</a></code> and <code><a
- href="#who">who</a></code>.
- <pre><code>
- : (can 'zap>)
- -> ((zap> . +relation) (zap> . +Blob) (zap> . +Entity))
- : (more @ pp)
- (dm (zap> . +relation) (Obj Val))
- (dm (zap> . +Blob) (Obj Val)
- (and
- Val
- (call 'rm "-f" (blob Obj (: var))) ) )
- (dm (zap> . +Entity) NIL
- (for X (getl This)
- (let V (or (atom X) (pop 'X))
- (and (meta This X) (zap> @ This V)) ) ) )
- -> NIL
- </code></pre>
- <dt><a name="car"><code>(car 'var) -> any</code></a>
- <dd>List access: Returns the value of <code>var</code> if it is a symbol, or the
- first element if it is a list. See also <code><a
- href="#cdr">cdr</a></code> and <code><a
- href="#cXr">c..r</a></code>.
- <pre><code>
- : (car (1 2 3 4 5 6))
- -> 1
- </code></pre>
- <dt>
- <a name="caar"></a>
- <a name="cadr"></a>
- <a name="cdar"></a>
- <a name="cddr"></a>
- <a name="caaar"></a>
- <a name="caadr"></a>
- <a name="cadar"></a>
- <a name="caddr"></a>
- <a name="cdaar"></a>
- <a name="cdadr"></a>
- <a name="cddar"></a>
- <a name="cdddr"></a>
- <a name="caaaar"></a>
- <a name="caaadr"></a>
- <a name="caadar"></a>
- <a name="caaddr"></a>
- <a name="cadaar"></a>
- <a name="cadadr"></a>
- <a name="caddar"></a>
- <a name="cadddr"></a>
- <a name="cdaaar"></a>
- <a name="cdaadr"></a>
- <a name="cdadar"></a>
- <a name="cdaddr"></a>
- <a name="cddaar"></a>
- <a name="cddadr"></a>
- <a name="cdddar"></a>
- <a name="cddddr"></a>
- <a name="cXr"><code>(c[ad]*ar 'var) -> any</code></a>
- <dt><code>(c[ad]*dr 'lst) -> any</code>
- <dd>List access shortcuts. Combinations of the <code><a
- href="#car">car</a></code> and <code><a
- href="#cdr">cdr</a></code> functions, with up to four letters 'a' and
- 'd'.
- <pre><code>
- : (cdar '((1 . 2) . 3))
- -> 2
- </code></pre>
- <dt><a name="case"><code>(case 'any (any1 . prg1) (any2 . prg2) ..) -> any</code></a>
- <dd>Multi-way branch: <code>any</code> is evaluated and compared to the CAR
- elements <code>anyN</code> of each clause. If one of them is a list,
- <code>any</code> is in turn compared to all elements of that list.
- <code>T</code> is a catch-all for any value. If a comparison succeeds,
- <code>prgN</code> is executed, and the result returned. Otherwise
- <code>NIL</code> is returned. See also <code><a
- href="#casq">casq</a></code> and <code><a
- href="#state">state</a></code> .
- <pre><code>
- : (case (char 66) ("A" (+ 1 2 3)) (("B" "C") "Bambi") ("D" (* 1 2 3)))
- -> "Bambi"
- : (case 'b (a 1) ("b" 2) (b 3) (c 4))
- -> 2
- </code></pre>
- <dt><a name="casq"><code>(casq 'any (any1 . prg1) (any2 . prg2) ..) -> any</code></a>
- <dd>Multi-way branch: <code>any</code> is evaluated and compared to the CAR
- elements <code>anyN</code> of each clause. <code><a
- href="#==">==</a></code> is used for comparison (pointer equality). If
- one of them is a list, <code>any</code> is in turn compared to all elements of
- that list. <code>T</code> is a catch-all for any value. If a comparison
- succeeds, <code>prgN</code> is executed, and the result returned. Otherwise
- <code>NIL</code> is returned. See also <code><a
- href="#case">case</a></code> and <code><a
- href="#state">state</a></code>.
- <pre><code>
- : (casq 'b (a 1) ("b" 2) (b 3) (c 4))
- -> 3
- : (casq 'b (a 1) ("b" 2) ((a b c) 3) (c 4))
- -> 3
- </code></pre>
- <dt><a name="catch"><code>(catch 'any . prg) -> any</code></a>
- <dd>Sets up the environment for a non-local jump which may be caused by <code><a
- href="#throw">throw</a></code> or by a runtime error. If
- <code>any</code> is an atom, it is used by <code>throw</code> as a jump label
- (with <code>T</code> being a catch-all for any label), and a <code>throw</code>
- called during the execution of <code>prg</code> will immediately return the
- thrown value. Otherwise, <code>any</code> should be a list of strings, to catch
- any error whose message contains one of these strings, and this will immediately
- return the matching string. If neither <code>throw</code> nor an error occurs,
- the result of <code>prg</code> is returned. See also <code><a
- href="#finally">finally</a></code>, <code><a
- href="#quit">quit</a></code> and
- <code><a href="#errors">Error Handling</a></code>.
- <pre><code>
- : (catch 'OK (println 1) (throw 'OK 999) (println 2))
- 1
- -> 999
- : (catch '("No such file") (in "doesntExist" (foo)))
- -> "No such file"
- </code></pre>
- <dt><a name="cd"><code>(cd 'any) -> sym</code></a>
- <dd>Changes the current directory to <code>any</code>. The old directory is
- returned on success, otherwise <code>NIL</code>. See also <code><a
- href="#chdir">chdir</a></code>, <code><a
- href="#dir">dir</a></code> and <code><a
- href="#pwd">pwd</a></code>.
- <pre><code>
- : (when (cd "lib")
- (println (sum lines (dir)))
- (cd @) )
- 10955
- </code></pre>
- <dt><a name="cdr"><code>(cdr 'lst) -> any</code></a>
- <dd>List access: Returns all but the first element of <code>lst</code>. See also
- <code><a href="#car">car</a></code> and <code><a
- href="#cXr">c..r</a></code>.
- <pre><code>
- : (cdr (1 2 3 4 5 6))
- -> (2 3 4 5 6)
- </code></pre>
- <dt><a name="center"><code>(center 'cnt|lst 'any ..) -> sym</code></a>
- <dd>Returns a transient symbol with all <code>any</code> arguments <code><a
- href="#pack">pack</a></code>ed in a centered format. Trailing blanks
- are omitted. See also <code><a href="#align">align</a></code>, <code><a
- href="#tab">tab</a></code> and <code><a
- href="#wrap">wrap</a></code>.
- <pre><code>
- : (center 4 12)
- -> " 12"
- : (center 4 "a")
- -> " a"
- : (center 7 "a")
- -> " a"
- : (center (3 3 3) "a" "b" "c")
- -> " a b c"
- </code></pre>
- <dt><a name="chain"><code>(chain 'lst ..) -> lst</code></a>
- <dd>Concatenates (destructively) one or several new list elements
- <code>lst</code> to the end of the list in the current <code><a
- href="#make">make</a></code> environment. This operation is efficient
- also for long lists, because a pointer to the last element of the result list is
- maintained. <code>chain</code> returns the last linked argument. See also
- <code><a href="#link">link</a></code>, <code><a
- href="#yoke">yoke</a></code> and <code><a
- href="#made">made</a></code>.
- <pre><code>
- : (make (chain (list 1 2 3) NIL (cons 4)) (chain (list 5 6)))
- -> (1 2 3 4 5 6)
- </code></pre>
- <dt><a name="char"><code>(char) -> sym</code></a>
- <dt><code>(char 'cnt) -> sym</code>
- <dt><code>(char T) -> sym</code>
- <dt><code>(char 'sym) -> cnt</code>
- <dd>When called without arguments, the next character from the current input
- stream is returned as a single-character transient symbol, or <code>NIL</code>
- upon end of file. When called with a number <code>cnt</code>, a character with
- the corresponding unicode value is returned. As a special case, <code>T</code>
- is accepted to produce a byte value greater than any first byte in a UTF-8
- character (used as a top value in comparisons). Otherwise, when called with a
- symbol <code>sym</code>, the numeric unicode value of the first character of the
- name of that symbol is returned. See also <code><a
- href="#peek">peek</a></code>, <code><a
- href="#skip">skip</a></code>, <code><a
- href="#key">key</a></code>, <code><a
- href="#line">line</a></code>, <code><a
- href="#till">till</a></code> and <code><a
- href="#eof">eof</a></code>.
- <pre><code>
- : (char) # Read character from console
- A # (typed 'A' and a space/return)
- -> "A"
- : (char 100) # Convert unicode to symbol
- -> "d"
- : (char "d") # Convert symbol to unicode
- -> 100
- : (char T) # Special case
- -> # (not printable)
- : (char 0)
- -> NIL
- : (char NIL)
- -> 0
- </code></pre>
- <dt><a name="chdir"><code>(chdir 'any . prg) -> any</code></a>
- <dd>Changes the current directory to <code>any</code> with <code><a
- href="#cd">cd</a></code> during the execution of <code>prg</code>. Then
- the previous directory will be restored and the result of <code>prg</code>
- returned. See also <code><a href="#dir">dir</a></code> and <code><a
- href="#pwd">pwd</a></code>.
- <pre><code>
- : (pwd)
- -> "/usr/abu/pico"
- : (chdir "src" (pwd))
- -> "/usr/abu/pico/src"
- : (pwd)
- -> "/usr/abu/pico"
- </code></pre>
- <dt><a name="chkTree"><code>(chkTree 'sym ['fun]) -> num</code></a>
- <dd>Checks a database tree node (and recursively all sub-nodes) for consistency.
- Returns the total number of nodes checked. Optionally, <code>fun</code> is
- called with the key and value of each node, and should return <code>NIL</code>
- for failure. See also <code><a href="#tree">tree</a></code> and
- <code><a href="#root">root</a></code>.
- <pre><code>
- : (show *DB '+Item)
- {C} NIL
- sup (7 . {7-3})
- nr (7 . {7-1}) # 7 nodes in the 'nr' tree, base node is {7-1}
- pr (7 . {7-4})
- nm (77 . {7-6})
- -> {C}
- : (chkTree '{7-1}) # Check that node
- -> 7
- </code></pre>
- <dt><a name="chop"><code>(chop 'any) -> lst</code></a>
- <dd>Returns <code>any</code> as a list of single-character strings. If
- <code>any</code> is <code>NIL</code> or a symbol with no name, <code>NIL</code>
- is returned. A list argument is returned unchanged.
- <pre><code>
- : (chop 'car)
- -> ("c" "a" "r")
- : (chop "Hello")
- -> ("H" "e" "l" "l" "o")
- </code></pre>
- <dt><a name="circ"><code>(circ 'any ..) -> lst</code></a>
- <dd>Produces a circular list of all <code>any</code> arguments by <code><a
- href="#cons">cons</a></code>ing them to a list and then connecting the
- CDR of the last cell to the first cell. See also <code><a
- href="#circ?">circ?</a></code> and <code><a
- href="#list">list</a></code>.
- <pre><code>
- : (circ 'a 'b 'c)
- -> (a b c .)
- </code></pre>
- <dt><a name="circ?"><code>(circ? 'any) -> any</code></a> <dd>Returs the circular
- (sub)list if <code>any</code> is a circular list, else <code>NIL</code>. See
- also <code><a href="#circ">circ</a></code>.
- <pre><code>
- : (circ? 'a)
- -> NIL
- : (circ? (1 2 3))
- -> NIL
- : (circ? (1 . (2 3 .)))
- -> (2 3 .)
- </code></pre>
- <dt><a name="class"><code>(class sym . typ) -> obj</code></a>
- <dd>Defines <code>sym</code> as a class with the superclass(es)
- <code>typ</code>. As a side effect, the global variable <code><a
- href="#*Class">*Class</a></code> is set to <code>obj</code>. See also
- <code><a href="#extend">extend</a></code>, <code><a
- href="#dm">dm</a></code>, <code><a href="refV.html#var">var</a></code>,
- <code><a href="#rel">rel</a></code>, <code><a
- href="#type">type</a></code>, <code><a
- href="#isa">isa</a></code> and <code><a
- href="#object">object</a></code>.
- <pre><code>
- : (class +A +B +C +D)
- -> +A
- : +A
- -> (+B +C +D)
- : (dm foo> (X) (bar X))
- -> foo>
- : +A
- -> ((foo> (X) (bar X)) +B +C +D)
- </code></pre>
- <dt><a name="clause"><code>(clause '(sym . any)) -> sym</code></a>
- <dd>Declares a <a href="#pilog">Pilog</a> fact or rule for the
- <code>sym</code> argument, by concatenating the <code>any</code> argument to the
- <code>T</code> property of <code>sym</code>. See also <code><a
- href="#be">be</a></code>.
- <pre><code>
- : (clause '(likes (John Mary)))
- -> likes
- : (clause '(likes (John @X) (likes @X wine) (likes @X food)))
- -> likes
- : (? (likes @X @Y))
- @X=John @Y=Mary
- -> NIL
- </code></pre>
- <dt><a name="clause/2"><code>clause/2</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that succeeds if the first
- argument is a predicate which has the second argument defined as a clause.
- <pre><code>
- : (? (clause append ((NIL @X @X))))
- -> T
- : (? (clause append @C))
- @C=((NIL @X @X))
- @C=(((@A . @X) @Y (@A . @Z)) (append @X @Y @Z))
- -> NIL
- </code></pre>
- <dt><a name="clip"><code>(clip 'lst) -> lst</code></a>
- <dd>Returns a copy of <code>lst</code> with all whitespace characters or
- <code>NIL</code> elements removed from both sides. See also <code><a
- href="#trim">trim</a></code>.
- <pre><code>
- : (clip '(NIL 1 NIL 2 NIL))
- -> (1 NIL 2)
- : (clip '(" " a " " b " "))
- -> (a " " b)
- </code></pre>
- <dt><a name="close"><code>(close 'cnt) -> cnt | NIL</code></a>
- <dd>Closes a file descriptor <code>cnt</code>, and returns it when successful.
- Should not be called inside an <code><a href="#out">out</a></code> body
- for that descriptor. See also <code><a href="#open">open</a></code>,
- <code><a href="#poll">poll</a></code>,
- <code><a href="#listen">listen</a></code> and <code><a
- href="#connect">connect</a></code>.
- <pre><code>
- : (close 2) # Close standard error
- -> 2
- </code></pre>
- <dt><a name="cmd"><code>(cmd ['any]) -> sym</code></a>
- <dd>When called without an argument, the name of the command that invoked the
- picolisp interpreter is returned. Otherwise, the command name is set to
- <code>any</code>. Setting the name may not work on some operating systems. Note
- that the new name must not be longer than the original one. See also <code><a
- href="#argv">argv</a></code>, <code><a
- href="#file">file</a></code> and <a
- href="#invoc">Invocation</a>.
- <pre><code>
- $ pil +
- : (cmd)
- -> "/usr/bin/picolisp"
- : (cmd "!/bin/picolust")
- -> "!/bin/picolust"
- : (cmd)
- -> "!/bin/picolust"
- </code></pre>
- <dt><a name="cnt"><code>(cnt 'fun 'lst ..) -> cnt</code></a>
- <dd>Applies <code>fun</code> to each element of <code>lst</code>. When
- additional <code>lst</code> arguments are given, their elements are also passed
- to <code>fun</code>. Returns the count of non-<code>NIL</code> values returned
- from <code>fun</code>.
- <pre><code>
- : (cnt cdr '((1 . T) (2) (3 4) (5)))
- -> 2
- </code></pre>
- <dt><a name="collect"><code>(collect 'sym 'cls ['hook] ['any|beg ['end [sym|cnt ..]]])</code></a>
- <dd>Returns a list of all database objects of class <code>cls</code>, where the
- values for the <code>sym</code> arguments correspond to the <code>any</code>
- arguments, or where the values for the <code>sym</code> arguments are in the
- range <code>beg</code> .. <code>end</code>. <code>sym</code>, <code>cls</code>
- and <code>hook</code> should specify a <code><a
- href="#tree">tree</a></code> for <code>cls</code> or one of its
- superclasses. If additional <code>sym|cnt</code> arguments are given, the final
- values for the result list are obtained by applying the <code><a
- href="#get">get</a></code> algorithm. See also <code><a
- href="#db">db</a></code>, <code><a href="refA.html#aux">aux</a></code>,
- <code><a href="#fetch">fetch</a></code>, <code><a
- href="#init">init</a></code> and <code><a
- href="#step">step</a></code>.
- <pre><code>
- : (collect 'nr '+Item)
- -> ({3-1} {3-2} {3-3} {3-4} {3-5} {3-6} {3-8})
- : (collect 'nr '+Item 3 6 'nr)
- -> (3 4 5 6)
- : (collect 'nr '+Item 3 6 'nm)
- -> ("Auxiliary Construction" "Enhancement Additive" "Metal Fittings" "Gadget Appliance")
- : (collect 'nm '+Item "Main Part")
- -> ({3-1})
- </code></pre>
- <dt><a name="commit"><code>(commit ['any] [exe1] [exe2]) -> T</code></a>
- <dd>Closes a transaction, by writing all new or modified external symbols to,
- and removing all deleted external symbols from the database. When
- <code>any</code> is given, it is implicitly sent (with all modified objects) via
- the <code><a href="#tell">tell</a></code> mechanism to all family
- members. If <code>exe1</code> or <code>exe2</code> are given, they are executed
- as pre- or post-expressions while the database is <code><a
- href="#lock">lock</a></code>ed and <code><a
- href="#protect">protect</a></code>ed. See also <code><a
- href="#rollback">rollback</a></code>.
- <pre><code>
- : (pool "db")
- -> T
- : (put '{1} 'str "Hello")
- -> "Hello"
- : (commit)
- -> T
- </code></pre>
- <dt><a name="con"><code>(con 'lst 'any) -> any</code></a>
- <dd>Connects <code>any</code> to the first cell of <code>lst</code>, by
- (destructively) storing <code>any</code> in the CDR of <code>lst</code>. See
- also <code><a href="#conc">conc</a></code>.
- <pre><code>
- : (setq C (1 . a))
- -> (1 . a)
- : (con C '(b c d))
- -> (b c d)
- : C
- -> (1 b c d)
- </code></pre>
- <dt><a name="conc"><code>(conc 'lst ..) -> lst</code></a>
- <dd>Concatenates all argument lists (destructively). See also <code><a
- href="#append">append</a></code> and <code><a
- href="#con">con</a></code>.
- <pre><code>
- : (setq A (1 2 3) B '(a b c))
- -> (a b c)
- : (conc A B) # Concatenate lists in 'A' and 'B'
- -> (1 2 3 a b c)
- : A
- -> (1 2 3 a b c) # Side effect: List in 'A' is modified!
- </code></pre>
- <dt><a name="cond"><code>(cond ('any1 . prg1) ('any2 . prg2) ..) -> any</code></a>
- <dd>Multi-way conditional: If any of the <code>anyN</code> conditions evaluates
- to non-<code>NIL</code>, <code>prgN</code> is executed and the result returned.
- Otherwise (all conditions evaluate to <code>NIL</code>), <code>NIL</code> is
- returned. See also <code><a href="#nond">nond</a></code>, <code><a
- href="#if">if</a></code>, <code><a href="refI.html#if2">if2</a></code>
- and <code><a href="#when">when</a></code>.
- <pre><code>
- : (cond
- ((= 3 4) (println 1))
- ((= 3 3) (println 2))
- (T (println 3)) )
- 2
- -> 2
- </code></pre>
- <dt><a name="connect"><code>(connect 'any1 'any2) -> cnt | NIL</code></a>
- <dd>Tries to establish a TCP/IP connection to a server listening at host
- <code>any1</code>, port <code>any2</code>. <code>any1</code> may be either a
- hostname or a standard internet address in numbers-and-dots/colons notation
- (IPv4/IPv6). <code>any2</code> may be either a port number or a service name.
- Returns a socket descriptor <code>cnt</code>, or <code>NIL</code> if the
- connection cannot be established. See also <code><a
- href="#listen">listen</a></code> and <code><a
- href="#udp">udp</a></code>.
- <pre><code>
- : (connect "localhost" 4444)
- -> 3
- : (connect "some.host.org" "http")
- -> 4
- </code></pre>
- <dt><a name="cons"><code>(cons 'any ['any ..]) -> lst</code></a>
- <dd>Constructs a new list cell with the first argument in the CAR and the second
- argument in the CDR. If more than two arguments are given, a corresponding chain
- of cells is built. <code>(cons 'a 'b 'c 'd)</code> is equivalent to <code>(cons
- 'a (cons 'b (cons 'c 'd)))</code>. See also <code><a
- href="#list">list</a></code>.
- <pre><code>
- : (cons 1 2)
- -> (1 . 2)
- : (cons 'a '(b c d))
- -> (a b c d)
- : (cons '(a b) '(c d))
- -> ((a b) c d)
- : (cons 'a 'b 'c 'd)
- -> (a b c . d)
- </code></pre>
- <dt><a name="copy"><code>(copy 'any) -> any</code></a>
- <dd>Copies the argument <code>any</code>. For lists, the top level cells are
- copied, while atoms are returned unchanged.
- <pre><code>
- : (=T (copy T)) # Atoms are not copied
- -> T
- : (setq L (1 2 3))
- -> (1 2 3)
- : (== L L)
- -> T
- : (== L (copy L)) # The copy is not identical to the original
- -> NIL
- : (= L (copy L)) # But the copy is equal to the original
- -> T
- </code></pre>
- <dt><a name="co"><code>(co 'sym [. prg]) -> any</code></a>
- <dd>(64-bit version only) Starts, resumes or stops a <a
- href="#coroutines">coroutine</a> with the tag given by <code>sym</code>.
- If <code>prg</code> is not given, a coroutine with that tag will be stopped.
- Otherwise, if a coroutine running with that tag is found (pointer equality is
- used for comparison), its execution is resumed. Else a new coroutine with that
- tag is initialized and started. <code>prg</code> will be executed until it
- either terminates normally, or until <code><a
- href="#yield">yield</a></code> is called. In the latter case
- <code>co</code> returns, or transfers control to some other, already running,
- coroutine. A coroutine cannot resume itself directly or indirectly. See also
- <code><a href="#stack">stack</a></code>, <code><a
- href="#catch">catch</a></code> and <code><a
- href="#throw">throw</a></code>.
- <pre><code>
- : (de pythag (N) # A generator function
- (if (=T N)
- (co 'rt) # Stop
- (co 'rt
- (for X N
- (for Y (range X N)
- (for Z (range Y N)
- (when (= (+ (* X X) (* Y Y)) (* Z Z))
- (yield (list X Y Z)) ) ) ) ) ) ) )
- : (pythag 20)
- -> (3 4 5)
- : (pythag 20)
- -> (5 12 13)
- : (pythag 20)
- -> (6 8 10)
- </code></pre>
- <dt><a name="count"><code>(count 'tree) -> num</code></a>
- <dd>Returns the number of nodes in a database tree. See also <code><a
- href="#tree">tree</a></code> and <code><a
- href="#root">root</a></code>.
- <pre><code>
- : (count (tree 'nr '+Item))
- -> 7
- </code></pre>
- <dt><a name="ctl"><code>(ctl 'sym . prg) -> any</code></a>
- <dd>Waits until a write (exclusive) lock (or a read (shared) lock if the first
- character of <code>sym</code> is "<code>+</code>") can be set on the file
- <code>sym</code>, then executes <code>prg</code> and releases the lock. If the
- file does not exist, it will be created. When <code>sym</code> is
- <code>NIL</code>, a shared lock is tried on the current innermost I/O channel,
- and when it is <code>T</code>, an exclusive lock is tried instead. See also
- <code><a href="#in">in</a></code>, <code><a
- href="#out">out</a></code>, <code><a
- href="#err">err</a></code> and <code><a
- href="#pipe">pipe</a></code>.
- <pre><code>
- $ echo 9 >count # Write '9' to file "count"
- $ pil +
- : (ctl ".ctl" # Exclusive control, using ".ctl"
- (in "count"
- (let Cnt (read) # Read '9'
- (out "count"
- (println (dec Cnt)) ) ) ) ) # Write '8'
- -> 8
- :
- $ cat count # Check "count"
- 8
- </code></pre>
- <dt><a name="ctty"><code>(ctty 'sym|pid) -> flg</code></a>
- <dd>When called with a symbolic argument, <code>ctty</code> changes the current
- TTY device to <code>sym</code>. Otherwise, the local console is prepared for
- serving the PicoLisp process with the process ID <code>pid</code>. See also
- <code><a href="#raw">raw</a></code>.
- <pre><code>
- : (ctty "/dev/tty")
- -> T
- </code></pre>
- <dt><a name="curry"><code>(curry lst . fun) -> fun</code></a>
- <dd>Builds a new function from the list of symbols or symbol-value pairs
- <code>lst</code> and the functional expression <code>fun</code>. Each member in
- <code>lst</code> that is a <code><a href="#pat?">pat?</a></code> symbol
- is substituted inside <code>fun</code> by its value. All other symbols in
- <code>lst</code> are collected into a <code><a
- href="#job">job</a></code> environment.
- <pre><code>
- : (de multiplier (@X)
- (curry (@X) (N) (* @X N)) )
- -> multiplier
- : (multiplier 7)
- -> ((N) (* 7 N))
- : ((multiplier 7) 3)
- -> 21
- : (def 'fiboCounter
- (curry ((N1 . 0) (N2 . 1)) (Cnt)
- (do Cnt
- (println
- (prog1
- (+ N1 N2)
- (setq N1 N2 N2 @) ) ) ) ) )
- -> fiboCounter
- : (pp 'fiboCounter)
- (de fiboCounter (Cnt)
- (job '((N2 . 1) (N1 . 0))
- (do Cnt
- (println
- (prog1 (+ N1 N2) (setq N1 N2 N2 @)) ) ) ) )
- -> fiboCounter
- : (fiboCounter 5)
- 1
- 2
- 3
- 5
- 8
- -> 8
- : (fiboCounter 5)
- 13
- 21
- 34
- 55
- 89
- -> 89
- </code></pre>
- <dt><a name="cut"><code>(cut 'cnt 'var) -> lst</code></a>
- <dd>Pops the first <code>cnt</code> elements (CAR) from the stack in
- <code>var</code>. See also <code><a href="#pop">pop</a></code> and
- <code><a href="#del">del</a></code>.
- <pre><code>
- : (setq S '(1 2 3 4 5 6 7 8))
- -> (1 2 3 4 5 6 7 8)
- : (cut 3 'S)
- -> (1 2 3)
- : S
- -> (4 5 6 7 8)
- </code></pre>
- </dl>
- <h1><a name="D">D</a></h1>
- <dl>
- <dt><a name="*DB"><code>*DB</code></a>
- <dd>A global constant holding the external symbol <code>{1}</code>, the <a
- href="#dbase">database</a> root. All transient symbols in a database can
- be reached from that root. Except during debugging, any explicit literal access
- to symbols in the database should be avoided, because otherwise a memory leak
- might occur (The garbage collector temporarily sets <code>*DB</code> to
- <code>NIL</code> and restores its value after collection, thus disposing of all
- external symbols not currently used in the program).
- <pre><code>
- : (show *DB)
- {1} NIL
- +City {P}
- +Person {3}
- -> {1}
- : (show '{P})
- {P} NIL
- nm (566 . {AhDx})
- -> {P}
- : (show '{3})
- {3} NIL
- tel (681376 . {Agyl})
- nm (1461322 . {2gu7})
- -> {3}
- </code></pre>
- <dt><a name="*Dbg"><code>*Dbg</code></a>
- <dd>A boolean variable indicating "debug mode". It can be conveniently switched
- on with a trailing <code>+</code> command line argument (see <a
- href="#invoc">Invocation</a>). When non-<code>NIL</code>, the <code><a
- href="#$">$</a></code> (tracing) and <code><a
- href="#!">!</a></code> (breakpoint) functions are enabled, and the
- current line number and file name will be stored in symbol properties by
- <code><a href="#de">de</a></code>, <code><a
- href="#def">def</a></code> and <code><a
- href="#dm">dm</a></code>. See also <code><a
- href="#debug">debug</a></code>, <code><a
- href="#trace">trace</a></code> and <code><a
- href="#lint">lint</a></code>.
- <pre><code>
- : (de foo (A B) (* A B))
- -> foo
- : (trace 'foo)
- -> foo
- : (foo 3 4)
- foo : 3 4
- foo = 12
- -> 12
- : (let *Dbg NIL (foo 3 4))
- -> 12
- </code></pre>
- <dt><a name="*Dbs"><code>*Dbs</code></a>
- <dd>A global variable holding a list of numbers (block size scale factors, as
- needed by <code><a href="#pool">pool</a></code>). It is typically set
- by <code><a href="#dbs">dbs</a></code>
- and <code><a href="#dbs+">dbs+</a></code>.
- <pre><code>
- : *Dbs
- -> (1 2 1 0 2 3 3 3)
- </code></pre>
- <dt><a name="+Date"><code>+Date</code></a>
- <dd>Class for calender dates (as calculated by <code><a
- href="#date">date</a></code>), a subclass of <code><a
- href="#+Number">+Number</a></code>. See also <a
- href="#dbase">Database</a>.
- <pre><code>
- (rel dat (+Ref +Date)) # Indexed date
- </code></pre>
- <dt><a name="+Dep"><code>+Dep</code></a>
- <dd>Prefix class for maintaining dependencies between <code><a
- href="#+relation">+relation</a></code>s. Expects a list of (symbolic)
- attributes that depend on this relation. Whenever this relations is cleared
- (receives a value of <code>NIL</code>), the dependent relations will also be
- cleared, triggering all required side-effects. See also <a
- href="#dbase">Database</a>.
- <p>In the following example, the index entry for the item pointing to the
- position (and, therefore, to the order) is cleared in case the order is deleted,
- or this position is deleted from the order:
- <pre><code>
- (class +Pos +Entity) # Position class
- (rel ord (+Dep +Joint) # Order of that position
- (itm) # 'itm' specifies the dependency
- pos (+Ord) ) # Arguments to '+Joint'
- (rel itm (+Ref +Link) NIL (+Item)) # Item depends on the order
- </code></pre>
- <dt><a name="d"><code>(d) -> T</code></a>
- <dd>(Debug mode only) Inserts <code><a href="#!">!</a></code>
- breakpoints into all subexpressions of the current breakpoint. Typically used
- when single-stepping a function or method with <code><a
- href="#debug">debug</a></code>. See also <code><a
- href="#u">u</a></code> and <code><a
- href="#unbug">unbug</a></code>.
- <pre><code>
- ! (d) # Debug subexpression(s) at breakpoint
- -> T
- </code></pre>
- <dt><a name="daemon"><code>(daemon 'sym . prg) -> fun</code></a>
- <dt><code>(daemon '(sym . cls) . prg) -> fun</code>
- <dt><code>(daemon '(sym sym2 [. cls]) . prg) -> fun</code>
- <dd>Inserts <code>prg</code> in the beginning of the function (first form), the
- method body of <code>sym</code> in <code>cls</code> (second form) or in the
- class obtained by <code><a href="#get">get</a></code>ting
- <code>sym2</code> from <code><a href="#*Class">*Class</a></code> (or
- <code>cls</code> if given) (third form). Built-in functions (C-function pointer)
- are automatically converted to Lisp expressions. See also <code><a
- href="#trace">trace</a></code>, <code><a
- href="#expr">expr</a></code>, <code><a
- href="#patch">patch</a></code> and <code><a
- href="#redef">redef</a></code>.
- <pre><code>
- : (de hello () (prinl "Hello world!"))
- -> hello
- : (daemon 'hello (prinl "# This is the hello world program"))
- -> (NIL (prinl "# This is the hello world program") (prinl "Hello world!"))
- : (hello)
- # This is the hello world program
- Hello world!
- -> "Hello world!"
- : (daemon '* (msg 'Multiplying))
- -> (@ (msg 'Multiplying) (pass $134532148))
- : *
- -> (@ (msg 'Multiplying) (pass $134532148))
- : (* 1 2 3)
- Multiplying
- -> 6
- </code></pre>
- <dt><a name="dat$"><code>(dat$ 'dat ['sym]) -> sym</code></a>
- <dd>Formats a <code><a href="#date">date</a></code> <code>dat</code> in
- ISO format, with an optional delimiter character <code>sym</code>. See also
- <code><a href="#$dat">$dat</a></code>, <code><a
- href="#tim$">tim$</a></code>, <code><a
- href="#datStr">datStr</a></code> and <code><a
- href="#datSym">datSym</a></code>.
- <pre><code>
- : (dat$ (date))
- -> "20070601"
- : (dat$ (date) "-")
- -> "2007-06-01"
- </code></pre>
- <dt><a name="datStr"><code>(datStr 'dat ['flg]) -> sym</code></a>
- <dd>Formats a <code><a href="#date">date</a></code> according to the
- current <code><a href="#locale">locale</a></code>. If <code>flg</code>
- is non-<code>NIL</code>, the year will be formatted modulo 100. See also
- <code><a href="#dat$">dat$</a></code>, <code><a
- href="#datSym">datSym</a></code>, <code><a
- href="#strDat">strDat</a></code>, <code><a
- href="#expDat">expDat</a></code>, <code><a
- href="#expTel">expTel</a></code> and <code><a
- href="#day">day</a></code>.
- <pre><code>
- : (datStr (date))
- -> "2007-06-01"
- : (locale "DE" "de")
- -> NIL
- : (datStr (date))
- -> "01.06.2007"
- : (datStr (date) T)
- -> "01.06.07"
- </code></pre>
- <dt><a name="datSym"><code>(datSym 'dat) -> sym</code></a>
- <dd>Formats a <code><a href="#date">date</a></code> <code>dat</code> in
- in symbolic format (DDmmmYY). See also <code><a
- href="#dat$">dat$</a></code> and <code><a
- href="#datStr">datStr</a></code>.
- <pre><code>
- : (datSym (date))
- -> "01jun07"
- </code></pre>
- <dt><a name="date"><code>(date ['T]) -> dat</code></a>
- <dt><code>(date 'dat) -> (y m d)</code>
- <dt><code>(date 'y 'm 'd) -> dat | NIL</code>
- <dt><code>(date '(y m d)) -> dat | NIL</code>
- <dd>Calculates a (gregorian) calendar date. It is represented as a day number,
- starting first of March of the year 0 AD. When called without arguments, the
- current date is returned. When called with a <code>T</code> argument, the
- current Coordinated Universal Time (UTC) is returned. When called with a single
- number <code>dat</code>, it is taken as a date and a list with the corresponding
- year, month and day is returned. When called with three numbers (or a list of
- three numbers) for the year, month and day, the corresponding date is returned
- (or <code>NIL</code> if they do not represent a legal date). See also <code><a
- href="#time">time</a></code>, <code><a
- href="#stamp">stamp</a></code>, <code><a
- href="#$dat">$dat</a></code>, <code><a
- href="#dat$">dat$</a></code>, <code><a
- href="#datSym">datSym</a></code>, <code><a
- href="#datStr">datStr</a></code>, <code><a
- href="#strDat">strDat</a></code>, <code><a
- href="#expDat">expDat</a></code>, <code><a
- href="#day">day</a></code>, <code><a
- href="#week">week</a></code> and <code><a
- href="#ultimo">ultimo</a></code>.
- <pre><code>
- : (date) # Today
- -> 730589
- : (date 2000 6 12) # 12-06-2000
- -> 730589
- : (date 2000 22 5) # Illegal date
- -> NIL
- : (date (date)) # Today's year, month and day
- -> (2000 6 12)
- : (- (date) (date 2000 1 1)) # Number of days since first of January
- -> 163
- </code></pre>
- <dt><a name="day"><code>(day 'dat ['lst]) -> sym</code></a>
- <dd>Returns the name of the day for a given <code><a
- href="#date">date</a></code> <code>dat</code>, in the language of the
- current <code><a href="#locale">locale</a></code>. If <code>lst</code>
- is given, it should be a list of alternative weekday names. See also <code><a
- href="#week">week</a></code>, <code><a
- href="#datStr">datStr</a></code> and <code><a
- href="#strDat">strDat</a></code>.
- <pre><code>
- : (day (date))
- -> "Friday"
- : (locale "DE" "de")
- -> NIL
- : (day (date))
- -> "Freitag"
- : (day (date) '("Mo" "Tu" "We" "Th" "Fr" "Sa" "Su"))
- -> "Fr"
- </code></pre>
- <dt><a name="db"><code>(db 'sym 'cls ['hook] 'any ['sym 'any ..]) -> sym | NIL</code></a>
- <dd>Returns a database object of class <code>cls</code>, where the values for
- the <code>sym</code> arguments correspond to the <code>any</code> arguments. If
- a matching object cannot be found, <code>NIL</code> is returned.
- <code>sym</code>, <code>cls</code> and <code>hook</code> should specify a
- <code><a href="#tree">tree</a></code> for <code>cls</code> or one of
- its superclasses. See also <code><a href="#aux">aux</a></code>,
- <code><a href="#collect">collect</a></code>, <code><a
- href="#request">request</a></code>, <code><a
- href="#fetch">fetch</a></code>, <code><a
- href="#init">init</a></code> and <code><a
- href="#step">step</a></code>.
- <pre><code>
- : (db 'nr '+Item 1)
- -> {3-1}
- : (db 'nm '+Item "Main Part")
- -> {3-1}
- </code></pre>
- <dt><a name="db/3"><code>db/3</code></a>
- <dt><a name="db/4"><code>db/4</code></a>
- <dt><a name="db/5"><code>db/5</code></a>
- <dd><a href="#pilog">Pilog</a> database predicate that returns objects
- matching the given key/value (and optional hook) relation. The relation should
- be of type <code><a href="#+index">+index</a></code>. For the key
- pattern applies:
- <p><ul>
- <li>a symbol (string) returns all entries which start with that string
- <li>other atoms (numbers, external symbols) match as they are
- <li>cons pairs constitute a range, returning objects
- <ul>
- <li>in increasing order if the CDR is greater than the CAR
- <li>in decreasing order otherwise
- </ul>
- <li>other lists are matched for <code><a href="#+Aux">+Aux</a></code>
- key combinations
- </ul>
- <p>The optional hook can be supplied as the third argument. See also <code><a
- href="#select/3">select/3</a></code> and <code><a
- href="#remote/2">remote/2</a></code>.
- <pre><code>
- : (? (db nr +Item @Item)) # No value given
- @Item={3-1}
- @Item={3-2}
- @Item={3-3}
- @Item={3-4}
- @Item={3-5}
- @Item={3-6}
- -> NIL
- : (? (db nr +Item 2 @Item)) # Get item no. 2
- @Item={3-2}
- -> NIL
- : (? (db nm +Item Spare @Item) (show @Item)) # Search for "Spare.."
- {3-2} (+Item)
- pr 1250
- inv 100
- sup {2-2}
- nm "Spare Part"
- nr 2
- @Item={3-2}
- -> NIL
- </code></pre>
- <dt><a name="db:"><code>(db: cls ..) -> num</code></a>
- <dd>Returns the database file number for objects of the type given by the
- <code>cls</code> argument(s). Needed, for example, for the creation of <code><a
- href="#new">new</a></code> objects. See also <code><a
- href="#dbs">dbs</a></code>.
- <pre><code>
- : (db: +Item)
- -> 3
- </code></pre>
- <dt><a name="dbSync"><code>(dbSync) -> flg</code></a>
- <dd>Starts a database transaction, by trying to obtain a <code><a
- href="#lock">lock</a></code> on the database root object <code><a
- href="#*DB">*DB</a></code>, and then calling <code><a
- href="#sync">sync</a></code> to synchronize with possible changes from
- other processes. When all desired modifications to external symbols are done,
- <code>(<a href="#commit">commit</a> 'upd)</code> should be called. See
- also <a href="#dbase">Database</a>.
- <pre><code>
- (let? Obj (rd) # Get object?
- (dbSync) # Yes: Start transaction
- (put> Obj 'nm (rd)) # Update
- (put> Obj 'nr (rd))
- (put> Obj 'val (rd))
- (commit 'upd) ) # Close transaction
- </code></pre>
- <dt><a name="dbck"><code>(dbck ['cnt] 'flg) -> any</code></a>
- <dd>Performs a low-level integrity check of the current (or <code>cnt</code>'th)
- database file, and returns <code>NIL</code> (or the number of blocks and symbols
- if <code>flg</code> is non-<code>NIL</code>) if everything seems correct.
- Otherwise, a string indicating an error is returned. As a side effect, possibly
- unused blocks (as there might be when a <code><a
- href="#rollback">rollback</a></code> is done before <code><a
- href="#commit">commit</a></code>ting newly allocated (<code><a
- href="#new">new</a></code>) external symbols) are appended to the free
- list.
- <pre><code>
- : (pool "db")
- -> T
- : (dbck)
- -> NIL
- </code></pre>
- <dt><a name="dbs"><code>(dbs . lst)</code></a>
- <dd>Initializes the global variable <code><a
- href="#*Dbs">*Dbs</a></code>. Each element in <code>lst</code> has a
- number in its CAR (the block size scale factor of a database file, to be stored
- in <code>*Dbs</code>). The CDR elements are either classes (so that objects of
- that class are later stored in the corresponding file), or lists with a class in
- the CARs and a list of relations in the CDRs (so that index trees for these
- relations go into that file). See also <code><a
- href="#dbs+">dbs+</a></code> and <code><a
- href="#pool">pool</a></code>.
- <pre><code>
- (dbs
- (3 +Role +User +Sal) # 512 Prevalent objects
- (0 +Pos) # A:64 Tiny objects
- (1 +Item +Ord) # B:128 Small objects
- (2 +CuSu) # C:256 Normal objects
- (2 (+Role nm) (+User nm) (+Sal nm)) # D:256 Small indexes
- (4 (+CuSu nr plz tel mob)) # E:1024 Normal indexes
- (4 (+CuSu nm)) # F:1024
- (4 (+CuSu ort)) # G:1024
- (4 (+Item nr sup pr)) # H:1024
- (4 (+Item nm)) # I:1024
- (4 (+Ord nr dat cus)) # J:1024
- (4 (+Pos itm)) ) # K:1024
- : *Dbs
- -> (1 2 1 0 2 4 4 4 4 4 4 4)
- : (get '+Item 'Dbf)
- -> (3 . 128)
- : (get '+Item 'nr 'dbf)
- -> (9 . 1024)
- </code></pre>
- <dt><a name="dbs+"><code>(dbs+ 'num . lst)</code></a>
- <dd>Extends the list of database sizes stored in <code><a
- href="#*Dbs">*Dbs</a></code>. <code>num</code> is the initial offset
- into the list. See also <code><a href="#dbs">dbs</a></code>.
- <pre><code>
- (dbs+ 9
- (1 +NewCls) # (9 . 128)
- (3 (+NewCls nr nm)) ) # (10 . 512)
- </code></pre>
- <dt><a name="de"><code>(de sym . any) -> sym</code></a>
- <dd>Assigns a definition to the <code>sym</code> argument, by setting its
- <code>VAL</code> to the <code>any</code> argument. If the symbol has already
- another value, a "redefined" message is issued. When the value of the global
- variable <a href="#*Dbg">*Dbg</a> is non-<code>NIL</code>, the current
- line number and file name (if any) are stored in the <code>*Dbg</code> property
- of <code>sym</code>. <code>de</code> is the standard way to define a function.
- See also <code><a href="#def">def</a></code>, <code><a
- href="#dm">dm</a></code> and <code><a
- href="#undef">undef</a></code>.
- <pre><code>
- : (de foo (X Y) (* X (+ X Y))) # Define a function
- -> foo
- : (foo 3 4)
- -> 21
- : (de *Var . 123) # Define a variable value
- : *Var
- -> 123
- </code></pre>
- <dt><a name="debug"><code>(debug 'sym) -> T</code></a>
- <dt><code>(debug 'sym 'cls) -> T</code>
- <dt><code>(debug '(sym . cls)) -> T</code>
- <dd>(Debug mode only) Inserts a <code><a href="#!">!</a></code>
- breakpoint function call at the beginning and all top-level expressions of the
- function or method body of <code>sym</code>, to allow a stepwise execution.
- Typing <code>(<a href="#d">d</a>)</code> at a breakpoint will also
- debug the current subexpression, and <code>(<a href="#e">e</a>)</code>
- will evaluate the current subexpression. The current subexpression is stored in
- the global variable <code><a href="#^">^</a></code>. See also <code><a
- href="#unbug">unbug</a></code>, <code><a
- href="#*Dbg">*Dbg</a></code>, <code><a
- href="#trace">trace</a></code> and <code><a
- href="#lint">lint</a></code>.
- <pre><code>
- : (de tst (N) # Define tst
- (println (+ 3 N)) )
- -> tst
- : (debug 'tst) # Set breakpoints
- -> T
- : (pp 'tst)
- (de tst (N)
- (! println (+ 3 N)) ) # Breakpoint '!'
- -> tst
- : (tst 7) # Execute
- (println (+ 3 N)) # Stopped at beginning of 'tst'
- ! (d) # Debug subexpression
- -> T
- ! # Continue
- (+ 3 N) # Stopped in subexpression
- ! N # Inspect variable 'N'
- -> 7
- ! # Continue
- 10 # Output of print statement
- -> 10 # Done
- : (unbug 'tst)
- -> T
- : (pp 'tst) # Restore to original
- (de tst (N)
- (println (+ 3 N)) )
- -> tst
- </code></pre>
- <dt><a name="dec"><code>(dec 'num) -> num</code></a>
- <dt><code>(dec 'var ['num]) -> num</code>
- <dd>The first form returns the value of <code>num</code> decremented by 1. The
- second form decrements the <code>VAL</code> of <code>var</code> by 1, or by
- <code>num</code>. If the first argument is <code>NIL</code>, it is returned
- immediately. <code>(dec Num)</code> is equivalent to <code>(- Num 1)</code> and
- <code>(dec 'Var)</code> is equivalent to <code>(set 'Var (- Var 1))</code>. See
- also <code><a href="#inc">inc</a></code> and <code><a
- href="#-">-</a></code>.
- <pre><code>
- : (dec -1)
- -> -2
- : (dec 7)
- -> 6
- : (setq N 7)
- -> 7
- : (dec 'N)
- -> 6
- : (dec 'N 3)
- -> 3
- </code></pre>
- <dt><a name="def"><code>(def 'sym 'any) -> sym</code></a>
- <dt><code>(def 'sym1 'sym2 'any) -> sym1</code>
- <dd>The first form assigns a definition to the first <code>sym</code> argument,
- by setting its <code>VAL</code>'s to <code>any</code>. The second form defines a
- property value <code>any</code> for the first argument's <code>sym2</code> key.
- If any of these values existed and was changed in the process, a "redefined"
- message is issued. When the value of the global variable <a
- href="#*Dbg">*Dbg</a> is non-<code>NIL</code>, the current line number
- and file name (if any) are stored in the <code>*Dbg</code> property of
- <code>sym</code>. See also <code><a href="#de">de</a></code> and
- <code><a href="#dm">dm</a></code>.
- <pre><code>
- : (def 'b '((X Y) (* X (+ X Y))))
- -> b
- : (def 'b 999)
- # b redefined
- -> b
- </code></pre>
- <dt><a name="default"><code>(default var 'any ..) -> any</code></a>
- <dd>Stores new values <code>any</code> in the <code>var</code> arguments only if
- their current values are <code>NIL</code>. Otherwise, their values are left
- unchanged. In any case, the last <code>var</code>'s value is returned.
- <code>default</code> is used typically in functions to initialize optional
- arguments.
- <pre><code>
- : (de foo (A B) # Function with two optional arguments
- (default A 1 B 2) # The default values are 1 and 2
- (list A B) )
- -> foo
- : (foo 333 444) # Called with two arguments
- -> (333 444)
- : (foo 333) # Called with one arguments
- -> (333 2)
- : (foo) # Called without arguments
- -> (1 2)
- </code></pre>
- <dt><a name="del"><code>(del 'any 'var) -> lst</code></a>
- <dd>Deletes <code>any</code> from the list in the value of <code>var</code>, and
- returns the remaining list. <code>(del 'any 'var)</code> is equivalent to
- <code>(set 'var (delete 'any var))</code>. See also <code><a
- href="#delete">delete</a></code>, <code><a
- href="#cut">cut</a></code> and <code><a
- href="#pop">pop</a></code>.
- <pre><code>
- : (setq S '((a b c) (d e f)))
- -> ((a b c) (d e f))
- : (del '(d e f) 'S)
- -> ((a b c))
- : (del 'b S)
- -> (a c)
- </code></pre>
- <dt><a name="delete"><code>(delete 'any 'lst) -> lst</code></a>
- <dd>Deletes <code>any</code> from <code>lst</code>. If <code>any</code> is
- contained more than once in <code>lst</code>, only the first occurrence is
- deleted. See also <code><a href="#delq">delq</a></code>, <code><a
- href="#del">del</a></code>, <code><a
- href="#remove">remove</a></code> and <code><a
- href="#insert">insert</a></code>.
- <pre><code>
- : (delete 2 (1 2 3))
- -> (1 3)
- : (delete (3 4) '((1 2) (3 4) (5 6) (3 4)))
- -> ((1 2) (5 6) (3 4))
- </code></pre>
- <dt><a name="delete/3"><code>delete/3</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that succeeds if deleting the
- first argument from the list in the second argument is equal to the third
- argument. See also <code><a href="#delete">delete</a></code> and
- <code><a href="#member/2">member/2</a></code>.
- <pre><code>
- : (? (delete b (a b c) @X))
- @X=(a c)
- -> NIL
- </code></pre>
- <dt><a name="delq"><code>(delq 'any 'lst) -> lst</code></a>
- <dd>Deletes <code>any</code> from <code>lst</code>. If <code>any</code> is
- contained more than once in <code>lst</code>, only the first occurrence is
- deleted. <code><a href="#==">==</a></code> is used for comparison
- (pointer equality). See also <code><a href="#delete">delete</a></code>,
- <code><a href="#asoq">asoq</a></code>, <code><a
- href="#push1q">push1q</a></code>, <code><a
- href="#memq">memq</a></code>, <code><a
- href="#mmeq">mmeq</a></code> and <a href="ref.html#cmp">Comparing</a>.
- <pre><code>
- : (delq 'b '(a b c))
- -> (a c)
- : (delq (2) (1 (2) 3))
- -> (1 (2) 3)
- </code></pre>
- <dt><a name="dep"><code>(dep 'cls) -> cls</code></a>
- <dd>(Debug mode only) Displays the "dependencies" of <code>cls</code>, i.e. the
- tree of superclasses and the tree of subclasses. See also <a
- href="#oop">OO Concepts</a>, <code><a
- href="#methods">methods</a></code>, <code><a
- href="#class">class</a></code>, <code><a
- href="#what">what</a></code>, <code><a
- href="#who">who</a></code>, <code><a
- href="#has">has</a></code> and and <code><a
- href="#can">can</a></code>.
- <pre><code>
- : (dep '+Number) # Dependencies of '+Number'
- +relation # Single superclass is '+relation'
- +Number
- +Date # Subclasses are '+Date' and '+Time'
- +Time
- -> +Number
- </code></pre>
- <dt><a name="depth"><code>(depth 'lst) -> (cnt1 . cnt2)</code></a>
- <dd>Returns the maximal (<code>cnt1</code>) and the average (<code>cnt2</code>)
- "depth" of a tree structure as maintained by <code><a
- href="#idx">idx</a></code>. The total number of nodes is stored in the
- global variable <code><a href="#@@">@@</a></code>. See also <code><a
- href="#length">length</a></code> and <code><a
- href="#size">size</a></code>.
- <pre><code>
- : (off X) # Clear variable
- -> NIL
- : (for N (1 2 3 4 5 6 7) (idx 'X N T)) # Build a degenerated tree
- -> NIL
- : X
- -> (1 NIL 2 NIL 3 NIL 4 NIL 5 NIL 6 NIL 7) # Only right branches
- : (depth X)
- -> (7 . 4) # Depth is 7, average 4
- : (balance 'X (1 2 3 4 5 6 7)) # Build a balanced tree
- -> NIL
- : (depth X)
- -> (3 . 2) # Depth is 3, average 2
- </code></pre>
- <dt><a name="diff"><code>(diff 'lst 'lst) -> lst</code></a>
- <dd>Returns the difference of the <code>lst</code> arguments. See also <code><a
- href="#sect">sect</a></code>.
- <pre><code>
- : (diff (1 2 3 4 5) (2 4))
- -> (1 3 5)
- : (diff (1 2 3) (1 2 3))
- -> NIL
- </code></pre>
- <dt><a name="different/2"><code>different/2</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that succeeds if the two
- arguments are different. See also <code><a
- href="#equal/2">equal/2</a></code>.
- <pre><code>
- : (? (different 3 4))
- -> T
- </code></pre>
- <dt><a name="dir"><code>(dir ['any] ['flg]) -> lst</code></a>
- <dd>Returns a list of all filenames in the directory <code>any</code>. Names
- starting with a dot '<code>.</code>' are ignored, unless <code>flg</code> is
- non-<code>NIL</code>. See also <code><a href="#cd">cd</a></code> and
- <code><a href="#info">info</a></code>.
- <pre><code>
- : (filter '((F) (tail '(. c) (chop F))) (dir "src/"))
- -> ("main.c" "subr.c" "gc.c" "io.c" "big.c" "sym.c" "tab.c" "flow.c" ..
- </code></pre>
- <dt><a name="dirname"><code>(dirname 'any) -> sym</code></a>
- <dd>Returns the directory part of a path name <code>any</code>. See also
- <code><a href="#basename">basename</a></code> and <code><a
- href="#path">path</a></code>.
- <pre><code>
- : (dirname "a/b/c/d")
- -> "a/b/c/"
- </code></pre>
- <dt><a name="dm"><code>(dm sym . fun|cls2) -> sym</code></a>
- <dt><code>(dm (sym . cls) . fun|cls2) -> sym</code>
- <dt><code>(dm (sym sym2 [. cls]) . fun|cls2) -> sym</code>
- <dd>Defines a method for the message <code>sym</code> in the current class,
- implicitly given by the value of the global variable <code><a
- href="#*Class">*Class</a></code>, or - in the second form - for the
- explicitly given class <code>cls</code>. In the third form, the class object is
- obtained by <code><a href="#get">get</a></code>ting <code>sym2</code>
- from <code><a href="#*Class">*Class</a></code> (or <code>cls</code> if
- given). If the method for that class existed and was changed in the process, a
- "redefined" message is issued. If - instead of a method <code>fun</code> - a
- symbol specifying another class <code>cls2</code> is given, the method from that
- class is used (explicit inheritance). When the value of the global variable <a
- href="#*Dbg">*Dbg</a> is non-<code>NIL</code>, the current line number
- and file name (if any) are stored in the <code>*Dbg</code> property of
- <code>sym</code>. See also <a href="#oop">OO Concepts</a>, <code><a
- href="#de">de</a></code>, <code><a
- href="#undef">undef</a></code>, <a href="refC.html#class">class</a>, <a
- href="#rel">rel</a>, <a href="refV.html#var">var</a>, <a
- href="#method">method</a>, <a href="refS.html#send">send</a> and <a
- href="#try">try</a>.
- <pre><code>
- : (dm start> ()
- (super)
- (mapc 'start> (: fields))
- (mapc 'start> (: arrays)) )
- : (dm foo> . +OtherClass) # Explicitly inherit 'foo>' from '+OtherClass'
- </code></pre>
- <dt><a name="do"><code>(do 'flg|num ['any | (NIL 'any . prg) | (T 'any . prg) ..]) -> any</code></a>
- <dd>Counted loop with multiple conditional exits: The body is executed at most
- <code>num</code> times (or never (if the first argument is <code>NIL</code>), or
- an infinite number of times (if the first argument is <code>T</code>)). If a
- clause has <code>NIL</code> or <code>T</code> as its CAR, the clause's second
- element is evaluated as a condition and - if the result is <code>NIL</code> or
- non-<code>NIL</code>, respectively - the <code>prg</code> is executed and the
- result returned. Otherwise (if count drops to zero), the result of the last
- expression is returned. See also <code><a href="#loop">loop</a></code>
- and <code><a href="#for">for</a></code>.
- <pre><code>
- : (do 4 (printsp 'OK))
- OK OK OK OK -> OK
- : (do 4 (printsp 'OK) (T (= 3 3) (printsp 'done)))
- OK done -> done
- </code></pre>
- <dt><a name="doc"><code>(doc ['sym1] ['sym2])</code></a>
- <dd>(Debug mode only) Opens a browser, and tries to display the reference
- documentation for <code>sym1</code>. <code>sym2</code> may be the name of a
- browser. If not given, the value of the environment variable
- <code>BROWSER</code>, or the <code>w3m</code> browser is tried. If
- <code>sym1</code> is <code>NIL</code>, the <a href="">PicoLisp
- Reference</a> manual is opened. See also <a href="#fun">Function
- Reference</a> and <code><a href="#vi">vi</a></code>.
- <pre><code>
- : (doc '+) # Function reference
- -> T
- : (doc '+relation) # Class reference
- -> T
- : (doc) # Reference manual
- -> T
- : (doc 'vi "firefox") # Use alternative browser
- -> T
- </code></pre>
- </dl>
- <h1><a name="E">E</a></h1>
- <dl>
- <dt><a name="*Err"><code>*Err</code></a>
- <dd>A global variable holding a (possibly empty) <code>prg</code> body, which
- will be executed during error processing. See also <code><a
- href="#errors">Error Handling</a></code>, <code><a
- href="#*Msg">*Msg</a></code> and <code><a
- href="#^">^</a></code>.
- <pre><code>
- : (de *Err (prinl "Fatal error!"))
- -> *Err
- : (/ 3 0)
- !? (/ 3 0)
- Div/0
- Fatal error!
- ?
- </code></pre>
- <dt><a name="*Ext"><code>*Ext</code></a>
- <dd>A global variable holding a sorted list of cons pairs. The CAR of each pair
- specifies an external symbol offset (suitable for <code><a
- href="#ext">ext</a></code>), and the CDR should be a function taking a
- single external symbol as an argument. This function should return a list, with
- the value for that symbol in its CAR, and the property list (in the format used
- by <code><a href="#getl">getl</a></code> and <code><a
- href="#putl">putl</a></code>) in its CDR. The symbol will be set to
- this value and property list upon access. Typically this function will access
- the corresponding symbol in a remote database process. See also <code><a
- href="#qsym">qsym</a></code> and <code><a
- href="#external">external symbols</a></code>.
- <pre><code>
- ### On the local machine ###
- : (setq *Ext # Define extension functions
- (mapcar
- '((@Host @Ext)
- (cons @Ext
- (curry (@Host @Ext (Sock)) (Obj)
- (when (or Sock (setq Sock (connect @Host 4040)))
- (ext @Ext
- (out Sock (pr (cons 'qsym Obj)))
- (prog1
- (in Sock (rd))
- (unless @
- (close Sock)
- (off Sock) ) ) ) ) ) ) )
- '("10.10.12.1" "10.10.12.2" "10.10.12.3" "10.10.12.4")
- (20 40 60 80) ) )
- ### On the remote machines ###
- (de go ()
- ...
- (task (port 4040) # Set up background query server
- (let? Sock (accept @) # Accept a connection
- (unless (fork) # In child process
- (in Sock
- (while (rd) # Handle requests
- (sync)
- (out Sock
- (pr (eval @)) ) ) )
- (bye) ) # Exit child process
- (close Sock) ) )
- (forked) # Close task in children
- ...
- </code></pre>
- <dt><a name="+Entity"><code>+Entity</code></a>
- <dd>Base class of all database objects. See also <code><a
- href="#+relation">+relation</a></code> and <a
- href="#dbase">Database</a>.
- <p><a name="entityMesssages">Messages</a> to entity objects include
- <pre><code>
- zap> () # Clean up relational structures, for removal from the DB
- url> (Tab) # Call the GUI on that object (in optional Tab)
- upd> (X Old) # Callback method when object is created/modified/deleted
- has> (Var Val) # Check if value is present
- put> (Var Val) # Put a new value
- put!> (Var Val) # Put a new value, single transaction
- del> (Var Val) # Delete value (also partial)
- del!> (Var Val) # Delete value (also partial), single transaction
- inc> (Var Val) # Increment numeric value
- inc!> (Var Val) # Increment numeric value, single transaction
- dec> (Var Val) # Decrement numeric value
- dec!> (Var Val) # Decrement numeric value, single transaction
- mis> (Var Val) # Return error message if value or type mismatch
- lose1> (Var) # Delete relational structures for a single attribute
- lose> (Lst) # Delete relational structures (excluding 'Lst')
- lose!> () # Delete relational structures, single transaction
- keep1> (Var) # Restore relational structures for single attribute
- keep> (Lst) # Restore relational structures (excluding 'Lst')
- keep?> (Lst) # Test for restauration (excluding 'Lst')
- keep!> () # Restore relational structures, single transaction
- set> (Val) # Set the value (type, i.e. class list)
- set!> (Val) # Set the value, single transaction
- clone> () # Object copy
- clone!> () # Object copy, single transaction
- </code></pre>
- <dt><a name="e"><code>(e . prg) -> any</code></a>
- <dd>Used in a breakpoint. Evaluates <code>prg</code> in the execution
- environment, or the currently executed expression if <code>prg</code> is not
- given. See also <code><a href="#debug">debug</a></code>, <code><a
- href="#!">!</a></code>, <code><a href="ref_.html#^">^</a></code> and
- <code><a href="#*Dbg">*Dbg</a></code>.
- <pre><code>
- : (! + 3 4)
- (+ 3 4)
- ! (e)
- -> 7
- </code></pre>
- <dt><a name="echo"><code>(echo ['cnt ['cnt]] | ['sym ..]) -> sym</code></a>
- <dd>Reads the current input channel, and writes to the current output channel.
- If <code>cnt</code> is given, only that many bytes are actually echoed. In case
- of two <code>cnt</code> arguments, the first one specifies the number of bytes
- to skip in the input stream. Otherwise, if one or more <code>sym</code>
- arguments are given, the echo process stops as soon as one of the symbol's names
- is encountered in the input stream. In this case the name will be read and
- returned, but not written. Returns non-<code>NIL</code> if the operation was
- successfully completed. See also <code><a href="#from">from</a></code>.
- <pre><code>
- : (in "x.l" (echo)) # Display file on console
- ..
- : (out "x2.l" (in "x.l" (echo))) # Copy file "x.l" to "x2.l"
- </code></pre>
- <dt><a name="edit"><code>(edit 'sym ..) -> NIL</code></a>
- <dd>(Debug mode only) Edits the value and property list of the argument
- symbol(s) by calling the <code>vim</code> editor on a temporary file with these
- data. When closing the editor, the modified data are read and stored into the
- symbol(s). During the edit session, individual symbols are separated by the
- pattern <code>(=======)</code>. These separators should not be modified. When
- moving the cursor to the beginning of a symbol (no matter if internal, transient
- or external), and hitting '<code>K</code>', that symbol is added to the
- currently edited symbols. Hitting '<code>Q</code>' will go back one step and
- return to the previously edited list of symbols.
- <p><code>edit</code> is especially useful for browsing through the database
- (with '<code>K</code>' and '<code>Q</code>'), inspecting external symbols, but
- care must be taken when modifying any data as then the <a
- href="#er">entity/relation</a> mechanisms are circumvented, and
- <code><a href="#commit">commit</a></code> has to be called manually if
- the changes should be persistent.
- <p>Another typical use case is inserting or removing <code><a
- href="#!">!</a></code> breakpoints at arbitrary code locations, or
- doing other temporary changes to the code for debugging purposes.
- <p>See also <code><a href="#update">update</a></code>, <code><a
- href="#show">show</a></code>, <code><a
- href="#vi">vi</a></code> and <code><a
- href="#em">em</a></code>.
- <pre><code>
- : (edit (db 'nr '+Item 1)) # Edit a database symbol
- ### 'vim' shows this ###
- {3-1} (+Item)
- nr 1
- inv 100
- pr 29900
- sup {2-1} # (+CuSu)
- nm "Main Part"
- (=======)
- ### Hitting 'K' on the '{' of '{2-1} ###
- {2-1} (+CuSu)
- nr 1
- plz "3425"
- mob "37 176 86303"
- tel "37 4967 6846-0"
- fax "37 4967 68462"
- nm "Active Parts Inc."
- nm2 "East Division"
- ort "Freetown"
- str "Wildcat Lane"
- em "info@api.tld"
- (=======)
- {3-1} (+Item)
- nr 1
- inv 100
- pr 29900
- sup {2-1} # (+CuSu)
- nm "Main Part"
- (=======)
- ### Entering ':q' in vim ###
- -> NIL
- </code></pre>
- <dt><a name="em"><code>(em 'sym) -> sym</code></a>
- <dt><code>(em 'sym 'cls) -> sym</code>
- <dt><code>(em '(sym . cls)) -> sym</code>
- <dt><code>(em) -> NIL</code>
- <dd>(Debug mode only) Opens the "emacs" editor on the function or method
- definition of <code>sym</code>. A call to <code><a
- href="#ld">ld</a></code> thereafter will <code><a
- href="#load">load</a></code> the modified file. A call without
- arguments permanently switches the REPL line editor and the <code><a
- href="#edit">edit</a></code> function to "emacs" mode. See also
- <code><a href="#doc">doc</a></code>, <code><a
- href="#edit">edit</a></code>, <code><a
- href="#vi">vi</a></code>, <code><a
- href="#*Dbg">*Dbg</a></code>, <code><a
- href="#debug">debug</a></code> and <code><a
- href="#pp">pp</a></code>.
- <pre><code>
- : (em 'url> '+CuSu) # Edit the method's source code, then exit from 'emacs'
- -> T
- </code></pre>
- <dt><a name="env"><code>(env ['lst] | ['sym 'val] ..) -> lst</code></a>
- <dd>Return a list of symbol-value pairs of all dynamically bound symbols if
- called without arguments, or of the symbols or symbol-value pairs in
- <code>lst</code>, or the explicitly given <code>sym</code>-<code>val</code>
- arguments. See also <code><a href="#bind">bind</a></code>, <code><a
- href="#job">job</a></code>, <code><a
- href="#trail">trail</a></code> and <code><a
- href="#up">up</a></code>.
- <pre><code>
- : (env)
- -> NIL
- : (let (A 1 B 2) (env))
- -> ((A . 1) (B . 2))
- : (let (A 1 B 2) (env '(A B)))
- -> ((B . 2) (A . 1))
- : (let (A 1 B 2) (env 'X 7 '(A B (C . 3)) 'Y 8))
- -> ((Y . 8) (C . 3) (B . 2) (A . 1) (X . 7))
- </code></pre>
- <dt><a name="eof"><code>(eof ['flg]) -> flg</code></a>
- <dd>Returns the end-of-file status of the current input channel. If
- <code>flg</code> is non-<code>NIL</code>, the channel's status is forced to
- end-of-file, so that the next call to <code>eof</code> will return
- <code>T</code>, and calls to <code><a href="#char">char</a></code>,
- <code><a href="#peek">peek</a></code>, <code><a
- href="#line">line</a></code>, <code><a
- href="#from">from</a></code>, <code><a
- href="#till">till</a></code>, <code><a
- href="#read">read</a></code> or <code><a
- href="#skip">skip</a></code> will return <code>NIL</code>. Note that
- <code>eof</code> cannot be used with the binary <code><a
- href="#rd">rd</a></code> function. See also <code><a
- href="#eol">eol</a></code>.
- <pre><code>
- : (in "file" (until (eof) (println (line T))))
- ...
- </code></pre>
- <dt><a name="eol"><code>(eol) -> flg</code></a>
- <dd>Returns the end-of-line status of the current input channel.
- See also <code><a href="#eof">eof</a></code>.
- <pre><code>
- : (make (until (prog (link (read)) (eol)))) # Read line into a list
- a b c (d e f) 123
- -> (a b c (d e f) 123)
- </code></pre>
- <dt><a name="equal/2"><code>equal/2</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that succeeds if the two
- arguments are equal. See also <code><a href="#=">=</a></code>, <code><a
- href="#different/2">different/2</a></code> and <code><a
- href="#member/2">member/2</a></code>.
- <pre><code>
- : (? (equal 3 4))
- -> NIL
- : (? (equal @N 7))
- @N=7
- -> NIL
- </code></pre>
- <dt><a name="err"><code>(err 'sym . prg) -> any</code></a>
- <dd>Redirects the standard error stream to <code>sym</code> during the execution
- of <code>prg</code>. The current standard error stream will be saved and
- restored appropriately. If the argument is <code>NIL</code>, the current output
- stream will be used. Otherwise, <code>sym</code> is taken as a file name (opened
- in "append" mode if the first character is "+"), where standard error is to be
- written to. See also <code><a href="#in">in</a></code>, <code><a
- href="#out">out</a></code> and <code><a
- href="#ctl">ctl</a></code>.
- <pre><code>
- : (err "/dev/null" # Suppress error messages
- (call 'ls 'noSuchFile) )
- -> NIL
- </code></pre>
- <dt><a name="errno"><code>(errno) -> cnt</code></a>
- <dd>(64-bit version only) Returns the value of the standard I/O 'errno'
- variable. See also <code><a href="#native">native</a></code>.
- <pre><code>
- : (in "foo") # Produce an error
- !? (in "foo")
- "foo" -- Open error: No such file or directory
- ? (errno)
- -> 2 # Returned 'ENOENT'
- </code></pre>
- <dt><a name="eval"><code>(eval 'any ['cnt ['lst]]) -> any</code></a>
- <dd>Evaluates <code>any</code>. Note that because of the standard argument
- evaluation, <code>any</code> is actually evaluated twice. If a binding
- environment offset <code>cnt</code> is given, the second evaluation takes place
- in the corresponding environment, and an optional <code>lst</code> of excluded
- symbols can be supplied. See also <code><a href="#run">run</a></code>
- and <code><a href="#up">up</a></code>.
- <pre><code>
- : (eval (list '+ 1 2 3))
- -> 6
- : (setq X 'Y Y 7)
- -> 7
- : X
- -> Y
- : Y
- -> 7
- : (eval X)
- -> 7
- : (de f (A)
- (list
- (eval 'A)
- (eval 'A 1)
- (eval 'A 2) ) )
- -> f
- : (de g (A)
- (f (inc A)) )
- -> g
- : (one A)
- -> 1
- : (g (inc A))
- -> (3 2 1)
- </code></pre>
- <dt><a name="expDat"><code>(expDat 'sym) -> dat</code></a>
- <dd>Expands a <code><a href="#date">date</a></code> string according to
- the current <code><a href="#locale">locale</a></code> (delimiter, and
- order of year, month and day). Accepts abbreviated input, without delimiter and
- with only the day, or the day and month, or the day, month and year of current
- century. See also <code><a href="#datStr">datStr</a></code>, <code><a
- href="#day">day</a></code>, <code><a
- href="#expTel">expTel</a></code>.
- <pre><code>
- : (date)
- -> 733133
- : (date (date))
- -> (2007 5 31)
- : (expDat "31")
- -> 733133
- : (expDat "315")
- -> 733133
- : (expDat "3105")
- -> 733133
- : (expDat "31057")
- -> 733133
- : (expDat "310507")
- -> 733133
- : (expDat "2007-05-31")
- -> 733133
- : (expDat "7-5-31")
- -> 733133
- : (locale "DE" "de")
- -> NIL
- : (expDat "31.5")
- -> 733133
- : (expDat "31.5.7")
- -> 733133
- </code></pre>
- <dt><a name="exec"><code>(exec 'any ..)</code></a>
- <dd>Executes an external system command. The <code>any</code> arguments specify
- the command and its arguments. Does not return to the caller; the current
- process is replaced with a new process image. See also <code><a
- href="#fork">fork</a></code> and <code><a
- href="#call">call</a></code>.
- <pre><code>
- : (pipe (exec 'echo 123 "abc")
- (list (read) (read)) )
- -> (123 abc)
- (unless (fork)
- (exec "@bin/ssl" # Start replication process
- "10.11.12.13" 443
- "app/!replica" "key/app" "fifo/app" "db/app/blob/" 20 ) )
- </code></pre>
- <dt><a name="expTel"><code>(expTel 'sym) -> sym</code></a>
- <dd>Expands a telephone number string. Multiple spaces or hyphens are coalesced.
- A leading <code>+</code> or <code>00</code> is removed, a leading <code>0</code>
- is replaced with the current country code. Otherwise, <code>NIL</code> is
- returned. See also <code><a href="#telStr">telStr</a></code>, <code><a
- href="#expDat">expDat</a></code> and <code><a
- href="#locale">locale</a></code>.
- <pre><code>
- : (expTel "+49 1234 5678-0")
- -> "49 1234 5678-0"
- : (expTel "0049 1234 5678-0")
- -> "49 1234 5678-0"
- : (expTel "01234 5678-0")
- -> NIL
- : (locale "DE" "de")
- -> NIL
- : (expTel "01234 5678-0")
- -> "49 1234 5678-0"
- </code></pre>
- <dt><a name="expr"><code>(expr 'sym) -> fun</code></a>
- <dd>Converts a C-function ("subr") to a Lisp-function. Useful only for normal
- functions (i.e. functions that evaluate all arguments). See also <code><a
- href="#subr">subr</a></code>.
- <pre><code>
- : car
- -> 67313448
- : (expr 'car)
- -> (@ (pass $385260187))
- : (car (1 2 3))
- -> 1
- </code></pre>
- <dt><a name="ext"><code>(ext 'cnt . prg) -> any</code></a>
- <dd>During the execution of <code>prg</code>, all <code><a
- href="#external">external symbols</a></code> processed by <code><a
- href="#rd">rd</a></code>, <code><a href="refP.html#pr">pr</a></code> or
- <code><a href="#udp">udp</a></code> are modified by an offset
- <code>cnt</code> suitable for mapping via the <code><a
- href="#*Ext">*Ext</a></code> mechanism. All external symbol's file
- numbers are decremented by <code>cnt</code> during output, and incremented by
- <code>cnt</code> during input.
- <pre><code>
- : (out 'a (ext 5 (pr '({6-2} ({8-9} . a) ({7-7} . b)))))
- -> ({6-2} ({8-9} . a) ({7-7} . b))
- : (in 'a (rd))
- -> ({2} ({3-9} . a) ({2-7} . b))
- : (in 'a (ext 5 (rd)))
- -> ({6-2} ({8-9} . a) ({7-7} . b))
- </code></pre>
- <dt><a name="ext?"><code>(ext? 'any) -> sym | NIL</code></a>
- <dd>Returns the argument <code>any</code> when it is an existing external
- symbol, otherwise <code>NIL</code>. See also <code><a
- href="#sym?">sym?</a></code>, <code><a
- href="#box?">box?</a></code>, <code><a
- href="#str?">str?</a></code>, <code><a
- href="#extern">extern</a></code> and <code><a
- href="#lieu">lieu</a></code>.
- <pre><code>
- : (ext? *DB)
- -> {1}
- : (ext? 'abc)
- -> NIL
- : (ext? "abc")
- -> NIL
- : (ext? 123)
- -> NIL
- </code></pre>
- <dt><a name="extend"><code>(extend cls) -> cls</code></a>
- <dd>Extends the class <code>cls</code>, by storing it in the global variable
- <code><a href="#*Class">*Class</a></code>. As a consequence, all
- following method, relation and class variable definitions are applied to that
- class. See also <a href="#oop">OO Concepts</a>, <code><a
- href="#class">class</a></code>, <code><a
- href="#dm">dm</a></code>, <code><a href="refV.html#var">var</a></code>,
- <code><a href="#rel">rel</a></code>, <code><a
- href="#type">type</a></code> and <code><a
- href="#isa">isa</a></code>.
- <pre><code>
- </code></pre>
- <dt><a name="extern"><code>(extern 'sym) -> sym | NIL</code></a>
- <dd>Creates or finds an external symbol. If a symbol with the name
- <code>sym</code> is already extern, it is returned. Otherwise, a new external
- symbol is returned. <code>NIL</code> is returned if <code>sym</code> does not
- exist in the database. See also <code><a
- href="#intern">intern</a></code> and <code><a
- href="#ext?">ext?</a></code>.
- <pre><code>
- : (extern "A1b")
- -> {A1b}
- : (extern "{A1b}")
- -> {A1b}
- </code></pre>
- <dt><a name="extra"><code>(extra ['any ..]) -> any</code></a>
- <dd>Can only be used inside methods. Sends the current message to the current
- object <code>This</code>, this time starting the search for a method at the
- remaining branches of the inheritance tree of the class where the current method
- was found. See also <a href="#oop">OO Concepts</a>, <code><a
- href="#super">super</a></code>, <code><a
- href="#method">method</a></code>, <code><a
- href="#meth">meth</a></code>, <code><a
- href="#send">send</a></code> and <code><a
- href="#try">try</a></code>.
- <pre><code>
- (dm key> (C) # 'key>' method of the '+Uppc' class
- (uppc (extra C)) ) # Convert 'key>' of extra classes to upper case
- </code></pre>
- <dt><a name="extract"><code>(extract 'fun 'lst ..) -> lst</code></a>
- <dd>Applies <code>fun</code> to each element of <code>lst</code>. When
- additional <code>lst</code> arguments are given, their elements are also passed
- to <code>fun</code>. Returns a list of all non-<code>NIL</code> values returned
- by <code>fun</code>. <code>(extract 'fun 'lst)</code> is equivalent to
- <code>(mapcar 'fun (filter 'fun 'lst))</code> or, for non-NIL results, to
- <code>(mapcan '((X) (and (fun X) (cons @))) 'lst)</code>. See also <code><a
- href="#filter">filter</a></code>, <code><a
- href="#find">find</a></code>, <code><a
- href="#pick">pick</a></code> and <code><a
- href="#mapcan">mapcan</a></code>.
- <pre><code>
- : (setq A NIL B 1 C NIL D 2 E NIL F 3)
- -> 3
- : (filter val '(A B C D E F))
- -> (B D F)
- : (extract val '(A B C D E F))
- -> (1 2 3)
- </code></pre>
- </dl>
- <h1><a name="F">F</a></h1>
- <dl>
- <dt><a name="*Fork"><code>*Fork</code></a>
- <dd>A global variable holding a (possibly empty) <code>prg</code> body, to be
- executed after a call to <code><a href="#fork">fork</a></code> in the
- child process.
- <pre><code>
- : (push '*Fork '(off *Tmp)) # Clear '*Tmp' in child process
- -> (off *Tmp)
- </code></pre>
- <dt><a name="+Fold"><code>+Fold</code></a>
- <dd>Prefix class for maintaining <code><a
- href="#fold">fold</a></code>ed indexes to <code><a
- href="#+String">+String</a></code> relations. Typically used in
- combination with the <code><a href="#+Ref">+Ref</a></code> or <code><a
- href="#+Idx">+Idx</a></code> prefix classes. See also <code><a
- href="#+IdxFold">+IdxFold</a></code> and <a
- href="#dbase">Database</a>.
- <pre><code>
- (rel nm (+Fold +Idx +String)) # Item Description
- ...
- (rel tel (+Fold +Ref +String)) # Phone number
- </code></pre>
- <dt><a name="fail"><code>(fail) -> lst</code></a>
- <dd>Constructs an empty <a href="#pilog">Pilog</a> query, i.e. a query
- that will always fail. See also <code><a href="#goal">goal</a></code>.
- <pre><code>
- (dm clr> () # Clear query chart in search dialogs
- (query> This (fail)) )
- </code></pre>
- <dt><a name="fail/0"><code>fail/0</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that always fails. See also
- <code><a href="#true/0">true/0</a></code>.
- <pre><code>
- : (? (fail))
- -> NIL
- </code></pre>
- <dt><a name="fetch"><code>(fetch 'tree 'any) -> any</code></a>
- <dd>Fetches a value for the key <code>any</code> from a database tree. See also
- <code><a href="#tree">tree</a></code> and <code><a
- href="#store">store</a></code>.
- <pre><code>
- : (fetch (tree 'nr '+Item) 2)
- -> {3-2}
- </code></pre>
- <dt><a name="fifo"><code>(fifo 'var ['any ..]) -> any</code></a>
- <dd>Implements a first-in-first-out structure using a circular list. When called
- with <code>any</code> arguments, they will be concatenated to end of the
- structure. Otherwise, the first element is removed from the structure and
- returned. See also <code><a href="#queue">queue</a></code>, <code><a
- href="#push">push</a></code>, <code><a
- href="#pop">pop</a></code>, <code><a
- href="#rot">rot</a></code> and <code><a
- href="#circ">circ</a></code>.
- <pre><code>
- : (fifo 'X 1)
- -> 1
- : (fifo 'X 2 3)
- -> 3
- : X
- -> (3 1 2 .)
- : (fifo 'X)
- -> 1
- : (fifo 'X)
- -> 2
- : X
- -> (3 .)
- </code></pre>
- <dt><a name="file"><code>(file) -> (sym1 sym2 . num) | NIL</code></a>
- <dd>Returns for the current input channel the path name <code>sym1</code>, the
- file name <code>sym2</code>, and the current line number <code>num</code>. If
- the current input channel is not a file, <code>NIL</code> is returned. See also
- <code><a href="#info">info</a></code>, <code><a
- href="#in">in</a></code> and <code><a
- href="#load">load</a></code>.
- <pre><code>
- : (load (pack (car (file)) "localFile.l")) # Load a file in same directory
- </code></pre>
- <dt><a name="fill"><code>(fill 'any ['sym|lst]) -> any</code></a>
- <dd>Non-destructively fills a pattern <code>any</code>, by substituting
- <code>sym</code>, or all symbols in <code>lst</code>, or - if no second argument
- is given - each pattern symbol in <code>any</code> (see <code><a
- href="#pat?">pat?</a></code>), with its current value. <code>@</code>
- itself is not considered a pattern symbol here. Unmodified subexpressions are
- shared. In any case, expressions following the symbol <code>^</code> should
- evaluate to lists which are then (destructively) spliced into the result. See
- also <code><a href="#match">match</a></code>.
- <pre><code>
- : (setq @X 1234 @Y (1 2 3 4))
- -> (1 2 3 4)
- : (fill '@X)
- -> 1234
- : (fill '(a b (c @X) ((@Y . d) e)))
- -> (a b (c 1234) (((1 2 3 4) . d) e))
- : (let X 2 (fill (1 X 3) 'X))
- -> (1 2 3)
- : (fill (1 ^ (list 'a 'b 'c) 9))
- -> (1 a b c 9)
- : (match '(This is @X) '(This is a pen))
- -> T
- : (fill '(Got ^ @X))
- -> (Got a pen)
- </code></pre>
- <dt><a name="filter"><code>(filter 'fun 'lst ..) -> lst</code></a>
- <dd>Applies <code>fun</code> to each element of <code>lst</code>. When
- additional <code>lst</code> arguments are given, their elements are also passed
- to <code>fun</code>. Returns a list of all elements of <code>lst</code> where
- <code>fun</code> returned non-<code>NIL</code>. See also <code><a
- href="#fish">fish</a></code>, <code><a
- href="#find">find</a></code>, <code><a
- href="#pick">pick</a></code> and <code><a
- href="#extract">extract</a></code>.
- <pre><code>
- : (filter num? (1 A 2 (B) 3 CDE))
- -> (1 2 3)
- </code></pre>
- <dt><a name="fin"><code>(fin 'any) -> num|sym</code></a>
- <dd>Returns <code>any</code> if it is an atom, otherwise the CDR of its last
- cell. See also <code><a href="#last">last</a></code> and <code><a
- href="#tail">tail</a></code>.
- <pre><code>
- : (fin 'a)
- -> a
- : (fin '(a . b))
- -> b
- : (fin '(a b . c))
- -> c
- : (fin '(a b c))
- -> NIL
- </code></pre>
- <dt><a name="finally"><code>(finally exe . prg) -> any</code></a>
- <dd><code>prg</code> is executed, then <code>exe</code> is evaluated, and the
- result of <code>prg</code> is returned. <code>exe</code> will also be evaluated
- if <code>prg</code> does not terminate normally due to a runtime error or a call
- to <code><a href="#throw">throw</a></code>. See also <code><a
- href="#bye">bye</a></code>, <code><a
- href="#catch">catch</a></code>, <code><a
- href="#quit">quit</a></code> and <code><a href="ref.html#errors">Error
- Handling</a></code>.
- <pre><code>
- : (finally (prinl "Done!")
- (println 123)
- (quit)
- (println 456) )
- 123
- Done!
- : (catch 'A
- (finally (prinl "Done!")
- (println 1)
- (throw 'A 123)
- (println 2) ) )
- 1
- Done!
- -> 123
- </code></pre>
- <dt><a name="find"><code>(find 'fun 'lst ..) -> any</code></a>
- <dd>Applies <code>fun</code> to successive elements of <code>lst</code> until
- non-<code>NIL</code> is returned. Returns that element (and stores the
- non-<code>NIL</code> value in the global variable <code><a
- href="#@@">@@</a></code>), or <code>NIL</code> if <code>fun</code> did
- not return non-<code>NIL</code> for any element of <code>lst</code>. When
- additional <code>lst</code> arguments are given, their elements are also passed
- to <code>fun</code>. See also <code><a href="#seek">seek</a></code>,
- <code><a href="#pick">pick</a></code>, <code><a
- href="#fully">fully</a></code> and <code><a
- href="#filter">filter</a></code>.
- <pre><code>
- : (find pair (1 A 2 (B) 3 CDE))
- -> (B)
- : (find '((A B) (> A B)) (1 2 3 4 5 6) (6 5 4 3 2 1))
- -> 4
- : (find > (1 2 3 4 5 6) (6 5 4 3 2 1)) # shorter
- -> 4
- </code></pre>
- <dt><a name="fish"><code>(fish 'fun 'any) -> lst</code></a>
- <dd>Applies <code>fun</code> to each element - and recursively to all sublists -
- of <code>any</code>. Returns a list of all items where <code>fun</code> returned
- non-<code>NIL</code>. See also <code><a
- href="#filter">filter</a></code>.
- <pre><code>
- : (fish gt0 '(a -2 (1 b (-3 c 2)) 3 d -1))
- -> (1 2 3)
- : (fish sym? '(a -2 (1 b (-3 c 2)) 3 d -1))
- -> (a b c d)
- </code></pre>
- <dt><a name="flg?"><code>(flg? 'any) -> flg</code></a>
- <dd>Returns <code>T</code> when the argument <code>any</code> is either
- <code>NIL</code> or <code>T</code>. See also <code><a
- href="#bool">bool</a></code>. <code>(flg? X)</code> is equivalent to
- <code>(or (not X) (=T X))</code>.
- <pre><code>
- : (flg? (= 3 3))
- -> T
- : (flg? (= 3 4))
- -> T
- : (flg? (+ 3 4))
- -> NIL
- </code></pre>
- <dt><a name="flip"><code>(flip 'lst ['cnt]) -> lst</code></a>
- <dd>Returns <code>lst</code> (destructively) reversed. Without the optional
- <code>cnt</code> argument, the whole list is flipped, otherwise only the first
- <code>cnt</code> elements. See also <code><a
- href="#reverse">reverse</a></code> and <code><a
- href="#rot">rot</a></code>.
- <pre><code>
- : (flip (1 2 3 4)) # Flip all four elements
- -> (4 3 2 1)
- : (flip (1 2 3 4 5 6) 3) # Flip only the first three elements
- -> (3 2 1 4 5 6)
- </code></pre>
- <dt><a name="flush"><code>(flush) -> flg</code></a>
- <dd>Flushes the current output stream by writing all buffered data. A call to
- <code>flush</code> for standard output is done automatically before a call to
- <code><a href="#key">key</a></code>. Returns <code>T</code> when
- successful. See also <code><a href="#rewind">rewind</a></code>.
- <pre><code>
- : (flush)
- -> T
- </code></pre>
- <dt><a name="fmt64"><code>(fmt64 'num) -> sym</code></a>
- <dt><code>(fmt64 'sym) -> num</code>
- <dd>Converts a number <code>num</code> to a string in base-64 notation, or a
- base-64 formatted string to a number. The digits are represented with the
- characters <code>0</code> - <code>9</code>, <code>:</code>, <code>;</code>,
- <code>A</code> - <code>Z</code> and <code>a</code> - <code>z</code>. This format
- is used internally for the names of <code><a
- href="#external-io">external symbols</a></code> in the 32-bit version.
- See also <code><a href="#hax">hax</a></code>, <code><a
- href="#hex">hex</a></code>, <code><a
- href="#bin">bin</a></code> and <code><a
- href="#oct">oct</a></code>.
- <pre><code>
- : (fmt64 9)
- -> "9"
- : (fmt64 10)
- -> ":"
- : (fmt64 11)
- -> ";"
- : (fmt64 12)
- -> "A"
- : (fmt64 "100")
- -> 4096
- </code></pre>
- <dt><a name="fold"><code>(fold 'any ['cnt]) -> sym</code></a>
- <dd>Folding to a canonical form: If <code>any</code> is not a symbol, it is
- returned as it is. Otherwise, a new transient symbol with all digits and all
- letters of <code>any</code>, converted to lower case, is returned. If the
- <code>cnt</code> argument is given and non-zero, the result is truncated to that
- length. See also <code><a href="#lowc">lowc</a></code>.
- <pre><code>
- : (fold " 1A 2-b/3")
- -> "1a2b3"
- : (fold " 1A 2-B/3" 3)
- -> "1a2"
- </code></pre>
- <dt><a name="fold/3"><code>fold/3</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that succeeds if the first
- argument, after <code><a href="#fold">fold</a></code>ing it to a
- canonical form, is a <i>prefix</i> of the folded string representation of the
- result of applying the <code><a href="#get">get</a></code> algorithm to
- the following arguments. Typically used as filter predicate in <code><a
- href="#select/3">select/3</a></code> database queries. See also
- <code><a href="#pre?">pre?</a></code>, <code><a
- href="#isa/2">isa/2</a></code>, <code><a
- href="#same/3">same/3</a></code>, <code><a
- href="#bool/3">bool/3</a></code>, <code><a
- href="#range/3">range/3</a></code>, <code><a
- href="#head/3">head/3</a></code>, <code><a
- href="#part/3">part/3</a></code> and <code><a
- href="#tolr/3">tolr/3</a></code>.
- <pre><code>
- : (?
- @Nr (1 . 5)
- @Nm "main"
- (select (@Item)
- ((nr +Item @Nr) (nm +Item @Nm))
- (range @Nr @Item nr)
- (fold @Nm @Item nm) ) )
- @Nr=(1 . 5) @Nm="main" @Item={3-1}
- -> NIL
- </code></pre>
- <dt><a name="for"><code>(for sym 'num ['any | (NIL 'any . prg) | (T 'any . prg) ..]) -> any</code></a>
- <dt><code>(for sym|(sym2 . sym) 'lst ['any | (NIL 'any . prg) | (T 'any . prg) ..]) -> any</code>
- <dt><code>(for (sym|(sym2 . sym) 'any1 'any2 [. prg]) ['any | (NIL 'any . prg) | (T 'any . prg) ..]) -> any</code>
- <dd>Conditional loop with local variable(s) and multiple conditional exits:<br>
- In the first form, the value of <code>sym</code> is saved, <code>sym</code> is
- bound to <code>1</code>, and the body is executed with increasing values up to
- (and including) <code>num</code>.<br>
- In the second form, the value of <code>sym</code> is saved, <code>sym</code> is
- subsequently bound to the elements of <code>lst</code>, and the body is executed
- each time.<br>
- In the third form, the value of <code>sym</code> is saved, and <code>sym</code>
- is bound to <code>any1</code>. If <code>sym2</code> is given, it is treated as a
- counter variable, first bound to 1 and then incremented for each execution of
- the body. While the condition <code>any2</code> evaluates to
- non-<code>NIL</code>, the body is repeatedly executed and, if <code>prg</code>
- is given, <code>sym</code> is re-bound to the result of its evaluation.<br>
- If a clause has <code>NIL</code> or <code>T</code> as its CAR, the clause's
- second element is evaluated as a condition and - if the result is
- <code>NIL</code> or non-<code>NIL</code>, respectively - the <code>prg</code> is
- executed and the result returned. If the body is never executed,
- <code>NIL</code> is returned.<br>
- See also <code><a href="#do">do</a></code> and <code><a
- href="#loop">loop</a></code>.
- <pre><code>
- # First form:
- : (for N 5 (printsp N))
- 1 2 3 4 5 -> 5
- : (for N 5 (printsp N) (NIL (< N 3) (printsp 'enough)))
- 1 2 3 enough -> enough
- : (for N 5 (T (> N 3) (printsp 'enough)) (printsp N))
- 1 2 3 enough -> enough
- # Second form:
- : (for X (1 a 2 b) (printsp X))
- 1 a 2 b -> b
- : (for (I . X) '(a b c) (println I X))
- 1 a
- 2 b
- 3 c
- -> c
- # Third form:
- : (for (L (1 2 3 4 5) L) (printsp (pop 'L)))
- 1 2 3 4 5 -> 5
- : (for (N 1 (>= 5 N) (inc N)) (printsp N))
- 1 2 3 4 5 -> 5
- : (for ((I . L) '(a b c d e f) L (cddr L)) (println I L))
- 1 (a b c d e f)
- 2 (c d e f)
- 3 (e f)
- -> (e f)
- </code></pre>
- <dt><a name="for/2"><code>for/2</code></a>
- <dt><a name="for/3"><code>for/3</code></a>
- <dt><a name="for/4"><code>for/4</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that generates a sequence of
- numbers. See also <code><a href="#for">for</a></code> and <code><a
- href="#range">range</a></code>.
- <pre><code>
- : (? (for @I 3))
- @I=1
- @I=2
- @I=3
- -> NIL
- : (? (for @I 3 7))
- @I=3
- @I=4
- @I=5
- @I=6
- @I=7
- -> NIL
- : (? (for @I 7 3 2))
- @I=7
- @I=5
- @I=3
- -> NIL
- </code></pre>
- <dt><a name="fork"><code>(fork) -> pid | NIL</code></a>
- <dd>Forks a child process. Returns <code>NIL</code> in the child, and the
- child's process ID <code>pid</code> in the parent. In the child, the
- <code>VAL</code> of the global variable <code><a
- href="#*Fork">*Fork</a></code> (should be a <code>prg</code>) is
- executed. See also <code><a href="#exec">exec</a></code>, <code><a
- href="#kids">kids</a></code>, <code><a
- href="#pipe">pipe</a></code> and <code><a
- href="#tell">tell</a></code>.
- <pre><code>
- : (unless (fork) (do 5 (println 'OK) (wait 1000)) (bye))
- -> NIL
- OK # Child's output
- : OK
- OK
- OK
- OK
- </code></pre>
- <dt><a name="forked"><code>(forked)</code></a>
- <dd>Installs maintenance code in <code><a
- href="#*Fork">*Fork</a></code> to close server sockets and clean up
- <code><a href="#*Run">*Run</a></code> code in child processes. Should
- only be called immediately after <code><a href="#task">task</a></code>.
- <pre><code>
- : (task -60000 60000 (msg 'OK)) # Install timer task
- -> (-60000 60000 (msg 'OK))
- : (forked) # No timer in child processes
- -> (task -60000)
- : *Run
- -> ((-60000 56432 (msg 'OK)))
- : *Fork
- -> ((task -60000) (del '(saveHistory) '*Bye))
- </code></pre>
- <dt><a name="format"><code>(format 'num ['cnt ['sym1 ['sym2]]]) -> sym</code></a>
- <dt><code>(format 'sym|lst ['cnt ['sym1 ['sym2]]]) -> num</code>
- <dd>Converts a number <code>num</code> to a string, or a string
- <code>sym|lst</code> to a number. In both cases, optionally a precision
- <code>cnt</code>, a decimal-separator <code>sym1</code> and a
- thousands-separator <code>sym2</code> can be supplied. Returns
- <code>NIL</code> if the conversion is unsuccessful. See also <a
- href="#num-io">Numbers</a>, <code><a
- href="#pad">pad</a></code>, <code><a
- href="#hex">hex</a></code>, <code><a
- href="#oct">oct</a></code>, <code><a
- href="#bin">bin</a></code> and <code><a
- href="#round">round</a></code>.
- <pre><code>
- : (format 123456789) # Integer conversion
- -> "123456789"
- : (format 123456789 2) # Fixed point
- -> "1234567.89"
- : (format 123456789 2 ",") # Comma as decimal-separator
- -> "1234567,89"
- : (format 123456789 2 "," ".") # and period as thousands-separator
- -> "1.234.567,89"
- : (format "123456789") # String to number
- -> 123456789
- : (format (1 "23" (4 5 6)))
- -> 123456
- : (format "1234567.89" 4) # scaled to four digits
- -> 12345678900
- : (format "1.234.567,89") # separators not recognized
- -> NIL
- : (format "1234567,89" 4 ",")
- -> 12345678900
- : (format "1.234.567,89" 4 ",") # thousands-separator not recognized
- -> NIL
- : (format "1.234.567,89" 4 "," ".")
- -> 12345678900
- </code></pre>
- <dt><a name="free"><code>(free 'cnt) -> (sym . lst)</code></a>
- <dd>Returns, for the <code>cnt</code>'th database file, the next available
- symbol <code>sym</code> (i.e. the first symbol greater than any symbol in the
- database), and the list <code>lst</code> of free symbols. See also <code><a
- href="#seq">seq</a></code>, <code><a
- href="#zap">zap</a></code> and <code><a
- href="#dbck">dbck</a></code>.
- <pre><code>
- : (pool "x") # A new database
- -> T
- : (new T) # Create a new symbol
- -> {2}
- : (new T) # Create another symbol
- -> {3}
- : (commit) # Commit changes
- -> T
- : (zap '{2}) # Delete the first symbol
- -> {2}
- : (free 1) # Show free list
- -> ({4}) # {3} was the last symbol allocated
- : (commit) # Commit the deletion of {2}
- -> T
- : (free 1) # Now {2} is in the free list
- -> ({4} {2})
- </code></pre>
- <dt><a name="from"><code>(from 'any ..) -> sym</code></a>
- <dd>Skips the current input channel until one of the strings <code>any</code> is
- found, and starts subsequent reading from that point. The found <code>any</code>
- argument, or <code>NIL</code> (if none is found) is returned. See also <code><a
- href="#till">till</a></code> and <code><a
- href="#echo">echo</a></code>.
- <pre><code>
- : (and (from "val='") (till "'" T))
- test val='abc'
- -> "abc"
- </code></pre>
- <dt><a name="full"><code>(full 'any) -> bool</code></a>
- <dd>Returns <code>NIL</code> if <code>any</code> is a non-empty list with at
- least one <code>NIL</code> element, otherwise <code>T</code>. <code>(full
- X)</code> is equivalent to <code>(not (memq NIL X))</code>. See also <code><a
- href="#fully">fully</a></code>.
- <pre><code>
- : (full (1 2 3))
- -> T
- : (full (1 NIL 3))
- -> NIL
- : (full 123)
- -> T
- </code></pre>
- <dt><a name="fully"><code>(fully 'fun 'lst ..) -> flg</code></a>
- <dd>Applies <code>fun</code> to successive elements of <code>lst</code>, and
- returns <code>NIL</code> immediately if one of the results is <code>NIL</code>.
- Otherwise, <code>T</code> is returned. When additional <code>lst</code>
- arguments are given, their elements are also passed to <code>fun</code>.
- <code>(fully foo Lst)</code> is equivalent to <code>(not (find '((X) (not (foo
- X))) Lst))</code>. See also <code><a href="#find">find</a></code> and
- <code><a href="#full">full</a></code>.
- <pre><code>
- : (fully gt0 (1 2 3))
- -> T
- : (fully gt0 (1 -2 3))
- -> NIL
- </code></pre>
- <dt><a name="fun?"><code>(fun? 'any) -> any</code></a>
- <dd>Returns <code>NIL</code> when the argument <code>any</code> is neither a
- number suitable for a code-pointer, nor a list suitable for a lambda expression
- (function). Otherwise a number is returned for a code-pointer, <code>T</code>
- for a function without arguments, and a single formal parameter or a list of
- formal parameters for a function. See also <code><a
- href="#getd">getd</a></code>.
- <pre><code>
- : (fun? 1000000000) # Might be a code pointer
- -> 1000000000
- : (fun? 10000000000000000000) # Too big for a code pointer
- -> NIL
- : (fun? '((A B) (* A B))) # Lambda expression
- -> (A B)
- : (fun? '((A B) (* A B) . C)) # Not a lambda expression
- -> NIL
- : (fun? '(1 2 3 4)) # Not a lambda expression
- -> NIL
- : (fun? '((A 2 B) (* A B))) # Not a lambda expression
- -> NIL
- </code></pre>
- </dl>
- <h1><a name="G">G</a></h1>
- <dl>
- <dt><a name="gc"><code>(gc ['cnt [cnt2]]) -> cnt | NIL</code></a>
- <dd>Forces a garbage collection. When <code>cnt</code> is given, so many
- megabytes of free cells are reserved, increasing the heap size if necessary. If
- <code>cnt</code> is zero, all currently unused heap blocks are purged,
- decreasing the heap size if possible. If <code>cnt2</code> (64-bit version only)
- is given, the reserve size (defaults to 1 megabyte) is set to that value. Before
- collection (but after argument evaluation) the global variables <code><a
- href="#@">@</a></code> and <code><a href="ref_.html#@@">@@</a></code>
- are set to <code>NIL</code>. See also <code><a
- href="#heap">heap</a></code>.
- <pre><code>
- : (gc)
- -> NIL
- : (heap)
- -> 2
- : (gc 4)
- -> 4
- : (heap)
- -> 5
- </code></pre>
- <dt><a name="ge0"><code>(ge0 'any) -> num | NIL</code></a>
- <dd>Returns <code>num</code> when the argument is a number and greater or equal
- zero, otherwise <code>NIL</code>. See also <code><a
- href="#lt0">lt0</a></code>, <code><a
- href="#le0">le0</a></code>, <code><a
- href="#gt0">gt0</a></code>, <code><a href="ref_.html#=0">=0</a></code>
- and <code><a href="#n0">n0</a></code>.
- <pre><code>
- : (ge0 -2)
- -> NIL
- : (ge0 3)
- -> 3
- : (ge0 0)
- -> 0
- </code></pre>
- <dt><a name="genKey"><code>(genKey 'sym 'cls ['hook ['num1 ['num2]]]) -> num</code></a>
- <dd>Generates a key for a database tree. If a minimal key <code>num1</code>
- and/or a maximal key <code>num2</code> is given, the next free number in that
- range is returned. Otherwise, the current maximal key plus one is returned. See
- also <code><a href="#useKey">useKey</a></code>, <code><a
- href="#genStrKey">genStrKey</a></code> and <code><a
- href="#maxKey">maxKey</a></code>.
- <pre><code>
- : (maxKey (tree 'nr '+Item))
- -> 8
- : (genKey 'nr '+Item)
- -> 9
- </code></pre>
- <dt><a name="genStrKey"><code>(genStrKey 'sym 'sym 'cls ['hook]) -> sym</code></a>
- <dd>Generates a unique string for a database tree, by prepending as many "# "
- sequences as necessary. See also <code><a
- href="#genKey">genKey</a></code>.
- <pre><code>
- : (genStrKey "ben" 'nm '+User)
- -> "# ben"
- </code></pre>
- <dt><a name="get"><code>(get 'sym1|lst ['sym2|cnt ..]) -> any</code></a>
- <dd>Fetches a value <code>any</code> from the properties of a symbol, or from a
- list. From the first argument <code>sym1|lst</code>, values are retrieved in
- successive steps by either extracting the value (if the next argument is zero)
- or a property from a symbol, the <code><a
- href="#asoq">asoq</a></code>ed element (if the next argument is a
- symbol), the n'th element (if the next argument is a positive number) or the
- n'th CDR (if the next argument is a negative number) from a list. See also
- <code><a href="#put">put</a></code>, <code><a
- href="#;">;</a></code> and <code><a href="ref_.html#:">:</a></code>.
- <pre><code>
- : (put 'X 'a 1)
- -> 1
- : (get 'X 'a)
- -> 1
- : (put 'Y 'link 'X)
- -> X
- : (get 'Y 'link)
- -> X
- : (get 'Y 'link 'a)
- -> 1
- : (get '((a (b . 1) (c . 2)) (d (e . 3) (f . 4))) 'a 'b)
- -> 1
- : (get '((a (b . 1) (c . 2)) (d (e . 3) (f . 4))) 'd 'f)
- -> 4
- : (get '(X Y Z) 2)
- -> Y
- : (get '(X Y Z) 2 'link 'a)
- -> 1
- </code></pre>
- <dt><a name="getd"><code>(getd 'any) -> fun | NIL</code></a>
- <dd>Returns <code>fun</code> if <code>any</code> is a symbol that has a function
- definition, otherwise <code>NIL</code>. See also <code><a
- href="#fun?">fun?</a></code>.
- <pre><code>
- : (getd '+)
- -> 67327232
- : (getd 'script)
- -> ((File . @) (load File))
- : (getd 1)
- -> NIL
- : ht:Fmt # Initially undefined
- -> NIL
- : (getd 'ht:Fmt) # Check shared library
- -> 8790207171188
- : ht:Fmt # Now defined
- -> 8790207171188
- </code></pre>
- <dt><a name="getl"><code>(getl 'sym1|lst1 ['sym2|cnt ..]) -> lst</code></a>
- <dd>Fetches the complete property list <code>lst</code> from a symbol. That
- symbol is <code>sym1</code> (if no other arguments are given), or a symbol found
- by applying the <code><a href="#get">get</a></code> algorithm to
- <code>sym1|lst1</code> and the following arguments. See also <code><a
- href="#putl">putl</a></code> and <code><a
- href="#maps">maps</a></code>.
- <pre><code>
- : (put 'X 'a 1)
- -> 1
- : (put 'X 'b 2)
- -> 2
- : (put 'X 'flg T)
- -> T
- : (getl 'X)
- -> (flg (2 . b) (1 . a))
- </code></pre>
- <dt><a name="glue"><code>(glue 'any 'lst) -> sym</code></a>
- <dd>Builds a new transient symbol (string) by <code><a
- href="#pack">pack</a></code>ing the <code>any</code> argument between
- the individual elements of <code>lst</code>. See also <code><a
- href="#text">text</a></code>.
- <pre><code>
- : (glue "," '(a b c d))
- -> "a,b,c,d"
- </code></pre>
- <dt><a name="goal"><code>(goal '([pat 'any ..] . lst) ['sym 'any ..]) -> lst</code></a>
- <dd>Constructs a <a href="#pilog">Pilog</a> query list from the list of
- clauses <code>lst</code>. The head of the argument list may consist of a
- sequence of pattern symbols (Pilog variables) and expressions, which are used
- together with the optional <code>sym</code> and <code>any</code> arguments to
- form an initial environment. See also <code><a
- href="#prove">prove</a></code> and <code><a
- href="#fail">fail</a></code>.
- <pre><code>
- : (goal '((likes John @X)))
- -> (((1 (0) NIL ((likes John @X)) NIL T)))
- : (goal '(@X 'John (likes @X @Y)))
- -> (((1 (0) NIL ((likes @X @Y)) NIL ((0 . @X) 1 . John) T)))
- </code></pre>
- <dt><a name="group"><code>(group 'lst) -> lst</code></a>
- <dd>Builds a list of lists, by grouping all elements of <code>lst</code> with
- the same CAR into a common sublist. See also <a
- href="#cmp">Comparing</a>, <code><a
- href="#by">by</a></code>, <code><a
- href="#sort">sort</a></code> and <code><a
- href="#uniq">uniq</a></code>.
- <pre><code>
- : (group '((1 . a) (1 . b) (1 . c) (2 . d) (2 . e) (2 . f)))
- -> ((1 a b c) (2 d e f))
- : (by name group '("x" "x" "y" "z" "x" "z")))
- -> (("x" "x" "x") ("y") ("z" "z"))
- : (by length group '(123 (1 2) "abcd" "xyz" (1 2 3 4) "XY"))
- -> ((123 "xyz") ((1 2) "XY") ("abcd" (1 2 3 4))
- </code></pre>
- <dt><a name="gt0"><code>(gt0 'any) -> num | NIL</code></a>
- <dd>Returns <code>num</code> when the argument is a number and greater than
- zero, otherwise <code>NIL</code>. See also <code><a
- href="#lt0">lt0</a></code>, <code><a
- href="#le0">le0</a></code>, <code><a
- href="#ge0">ge0</a></code>, <code><a href="ref_.html#=0">=0</a></code>
- and <code><a href="#n0">n0</a></code>.
- <pre><code>
- : (gt0 -2)
- -> NIL
- : (gt0 3)
- -> 3
- </code></pre>
- </dl>
- <h1><a name="H">H</a></h1>
- <dl>
- <dt><a name="*Hup"><code>*Hup</code></a>
- <dd>Global variable holding a (possibly empty) <code>prg</code> body, which will
- be executed when a SIGHUP signal is sent to the current process. See also
- <code><a href="#alarm">alarm</a></code>, <code><a
- href="#sigio">sigio</a></code> and <code><a
- href="#*Sig1">*Sig[12]</a></code>.
- <pre><code>
- : (de *Hup (msg 'SIGHUP))
- -> *Hup
- </code></pre>
- <dt><a name="+Hook"><code>+Hook</code></a>
- <dd>Prefix class for <code><a href="#+relation">+relation</a></code>s,
- typically <code><a href="#+Link">+Link</a></code> or <code><a
- href="#+Joint">+Joint</a></code>. In essence, this maintains an local
- database in the referred object. See also <a href="#dbase">Database</a>.
- <pre><code>
- (rel sup (+Hook +Link) (+Sup)) # Supplier
- (rel nr (+Key +Number) sup) # Item number, unique per supplier
- (rel dsc (+Ref +String) sup) # Item description, indexed per supplier
- </code></pre>
- <dt><a name="+Hook2"><code>+Hook2</code></a>
- <dd>Prefix class for <code><a href="#+index">+index</a></code>
- relations. It maintains both a normal (global) index, and an object-local index
- in the corresponding <code><a href="#+Hook">+Hook</a></code> object.
- See also <a href="#dbase">Database</a>.
- <pre><code>
- (rel nm (+Hook2 +IdxFold +String) 3 shop) # Global and shop-local index
- </code></pre>
- <dt><a name="has"><code>(has 'any) -> lst</code></a>
- <dd>(Debug mode only) Returns a list of all internal symbols which have the
- value <code>any</code>. See also <code><a href="#who">who</a></code>,
- <code><a href="#can">can</a></code>, <code><a
- href="#what">what</a></code> and <code><a
- href="#dep">dep</a></code>.
- <pre><code>
- : +
- -> 270310
- : (has 270310)
- -> (+ @)
- : meth
- -> 267259
- : (has 267259)
- -> (@ js> dec> inc> upd> ele> log> chk> val> del> rel> all> url> zap> clr> str> has>
- </code></pre>
- <dt><a name="hash"><code>(hash 'any) -> cnt</code></a>
- <dd>Generates a 16-bit number (1-65536) from <code>any</code>, suitable as a
- hash value for various purposes, like randomly balanced <code><a
- href="#idx">idx</a></code> structures. See also <code><a
- href="#cache">cache</a></code> and <code><a
- href="#seed">seed</a></code>.
- <pre><code>
- : (hash 0)
- -> 1
- : (hash 1)
- -> 55682
- : (hash "abc")
- -> 45454
- </code></pre>
- <dt><a name="hax"><code>(hax 'num) -> sym</code></a>
- <dt><code>(hax 'sym) -> num</code>
- <dd>Converts a number <code>num</code> to a string in hexadecimal/alpha
- notation, or a hexadecimal/alpha formatted string to a number. The digits are
- represented with '<code>@</code>' (zero) and the letters '<code>A</code>' -
- '<code>O</code>' (from "alpha" to "omega"). This format is used internally for
- the names of <code><a href="#external-io">external symbols</a></code> in
- the 64-bit version. See also <code><a href="#fmt64">fmt64</a></code>,
- <code><a href="#hex">hex</a></code>, <code><a
- href="#bin">bin</a></code> and <code><a
- href="#oct">oct</a></code>.
- <pre><code>
- : (hax 7)
- -> "G"
- : (hax 16)
- -> "A@"
- : (hax 255)
- -> "OO"
- : (hax "A")
- -> 1
- </code></pre>
- <dt><a name="hd"><code>(hd 'sym ['cnt]) -> NIL</code></a>
- <dd>(Debug mode only) Displays a hexadecimal dump of the file given by
- <code>sym</code>, limited to <code>cnt</code> lines. See also <code><a
- href="#proc">proc</a></code>.
- <pre><code>
- : (hd "lib.l" 4)
- 00000000 23 20 32 33 64 65 63 30 39 61 62 75 0A 23 20 28 # 23dec09abu.# (
- 00000010 63 29 20 53 6F 66 74 77 61 72 65 20 4C 61 62 2E c) Software Lab.
- 00000020 20 41 6C 65 78 61 6E 64 65 72 20 42 75 72 67 65 Alexander Burge
- 00000030 72 0A 0A 28 64 65 20 74 61 73 6B 20 28 4B 65 79 r..(de task (Key
- -> NIL
- </code></pre>
- <dt><a name="head"><code>(head 'cnt|lst 'lst) -> lst</code></a>
- <dd>Returns a new list made of the first <code>cnt</code> elements of
- <code>lst</code>. If <code>cnt</code> is negative, it is added to the length of
- <code>lst</code>. If the first argument is a <code>lst</code>, <code>head</code>
- is a predicate function returning that argument list if it is <code>equal</code>
- to the head of the second argument, and <code>NIL</code> otherwise. See also
- <code><a href="#tail">tail</a></code> and <code><a
- href="#pre?">pre?</a></code>.
- <pre><code>
- : (head 3 '(a b c d e f))
- -> (a b c)
- : (head 0 '(a b c d e f))
- -> NIL
- : (head 10 '(a b c d e f))
- -> (a b c d e f)
- : (head -2 '(a b c d e f))
- -> (a b c d)
- : (head '(a b c) '(a b c d e f))
- -> (a b c)
- </code></pre>
- <dt><a name="head/3"><code>head/3</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that succeeds if the first
- (string) argument is a prefix of the string representation of the result of
- applying the <code><a href="#get">get</a></code> algorithm to the
- following arguments. Typically used as filter predicate in <code><a
- href="#select/3">select/3</a></code> database queries. See also
- <code><a href="#pre?">pre?</a></code>, <code><a
- href="#isa/2">isa/2</a></code>, <code><a
- href="#same/3">same/3</a></code>, <code><a
- href="#bool/3">bool/3</a></code>, <code><a
- href="#range/3">range/3</a></code>, <code><a
- href="#fold/3">fold/3</a></code>, <code><a
- href="#part/3">part/3</a></code> and <code><a
- href="#tolr/3">tolr/3</a></code>.
- <pre><code>
- : (?
- @Nm "Muller"
- @Tel "37"
- (select (@CuSu)
- ((nm +CuSu @Nm) (tel +CuSu @Tel))
- (tolr @Nm @CuSu nm)
- (head @Tel @CuSu tel) )
- (val @Name @CuSu nm)
- (val @Phone @CuSu tel) )
- @Nm="Muller" @Tel="37" @CuSu={2-3} @Name="Miller" @Phone="37 4773 82534"
- -> NIL
- </code></pre>
- <dt><a name="heap"><code>(heap 'flg) -> cnt</code></a>
- <dd>Returns the total size of the cell heap space in megabytes. If
- <code>flg</code> is non-<code>NIL</code>, the size of the currently free space
- is returned. See also <code><a href="#stack">stack</a></code> and
- <code><a href="#gc">gc</a></code>.
- <pre><code>
- : (gc 4)
- -> 4
- : (heap)
- -> 5
- : (heap T)
- -> 4
- </code></pre>
- <dt><a name="hear"><code>(hear 'cnt) -> cnt</code></a>
- <dd>Uses the file descriptor <code>cnt</code> as an asynchronous command input
- channel. Any executable list received via this channel will be executed in the
- background. As this mechanism is also used for inter-family communication (see
- <code><a href="#tell">tell</a></code>), <code>hear</code> is usually
- only called explicitly by a top level parent process.
- <pre><code>
- : (call 'mkfifo "fifo/cmd")
- -> T
- : (hear (open "fifo/cmd"))
- -> 3
- </code></pre>
- <dt><a name="here"><code>(here ['sym]) -> sym</code></a>
- <dd>Echoes the current input stream until <code>sym</code> is encountered, or
- until end of file. See also <code><a href="#echo">echo</a></code>.
- <pre><code>
- $ cat hello.l
- (html 0 "Hello" "lib.css" NIL
- (<h2> NIL "Hello")
- (here) )
- <p>Hello!</p>
- <p>This is a test.</p>
- $ pil @lib/http.l @lib/xhtml.l hello.l
- HTTP/1.0 200 OK
- Server: PicoLisp
- Date: Sun, 03 Jun 2007 11:41:27 GMT
- Cache-Control: max-age=0
- Cache-Control: no-cache
- Content-Type: text/html; charset=utf-8
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta name="viewport" content="width=device-width"/>
- <title>Hello</title>
- <link rel="stylesheet" href="http://:/lib.css" type="text/css"/>
- </head>
- <body><h2>Hello</h2>
- <p>Hello!</p>
- <p>This is a test.</p>
- </body></html>
- </code></pre>
- <dt><a name="hex"><code>(hex 'num ['num]) -> sym</code></a>
- <dt><code>(hex 'sym) -> num</code>
- <dd>Converts a number <code>num</code> to a hexadecimal string, or a hexadecimal
- string <code>sym</code> to a number. In the first case, if the second argument
- is given, the result is separated by spaces into groups of such many digits. See
- also <code><a href="#bin">bin</a></code>, <code><a
- href="#oct">oct</a></code>, <code><a
- href="#fmt64">fmt64</a></code>, <code><a
- href="#hax">hax</a></code> and <code><a
- href="#format">format</a></code>.
- <pre><code>
- : (hex 273)
- -> "111"
- : (hex "111")
- -> 273
- : (hex 1234567 4)
- -> "12 D687"
- </code></pre>
- <dt><a name="host"><code>(host 'any) -> sym</code></a>
- <dd>Returns the hostname corresponding to the given IP address. See also
- <code><a href="#*Adr">*Adr</a></code>.
- <pre><code>
- : (host "80.190.158.9")
- -> "www.leo.org"
- </code></pre>
- </dl>
- <h1><a name="_">Other</a></h1>
- <dl>
- <dt><a name="!"><code>(! . exe) -> any</code></a>
- <dd>Low level breakpoint function: The current execution environment is saved
- and the I/O channels are redirected to the console. Then <code>exe</code> is
- displayed, and a read-eval-print-loop is entered (with <code>!</code> as its
- prompt character), to evaluate expressions and examine the current program
- environment. An empty input line terminates the read-eval-print-loop, the
- environment and I/O channels are restored, and the result of <code>exe</code> is
- returned. <code>!</code> is normally inserted into existing programs with the
- <code><a href="#debug">debug</a></code> function. See also <code><a
- href="#e">e</a></code>, <code><a href="ref_.html#^">^</a></code> and
- <code><a href="#*Dbg">*Dbg</a></code>.
- <pre><code>
- : (de foo (N) (and (println 1) (! println N) (println 2)))
- -> foo
- : (foo 7)
- 1 # Executed '(println 1)'
- (println N) # Entered breakpoint
- ! N # Examine the value of 'N'
- -> 7
- ! (e) # Evaluate '^', i.e. (println N)
- 7
- -> 7
- ! (e @) # Evaluate '@' -> the result of '(println 1)'
- -> 1
- ! # Empty line: continue
- 7 # Executed '(println N)'
- 2 # Executed '(println 2)'
- -> 2
- </code></pre>
- <dt><a name="$"><code>($ sym|lst lst . prg) -> any</code></a>
- <dd>Low level trace function: The first argument <code>sym|lst</code> is printed
- to the console with a proper indentation, followed by a colon <code>:</code>. If
- a function is traced, the first argument is the function symbol, else if a
- method is traced, it is a cons pair of message and class. The second argument
- <code>lst</code> should be a list of symbols, identical to the function's
- argument list. The current values of these symbols are printed, followed by a
- newline. Then <code>prg</code> is executed, and its return value printed in a
- similar way (this time with an equals sign <code>=</code> instead of a colon)
- and returned. <code>$</code> is normally inserted into existing programs with
- the <code><a href="#trace">trace</a></code> function.
- <pre><code>
- : (de foo (A B) ($ foo (A B) (* A B)))
- -> foo
- : (foo 3 4)
- foo : 3 4 # Function entry, arguments 3 and 4
- foo = 12 # Function exit, return value 12
- -> 12
- </code></pre>
- <dt><a name="$dat"><code>($dat 'sym1 ['sym2]) -> dat</code></a>
- <dd>Converts a string <code>sym1</code> in ISO format to a <code><a
- href="#date">date</a></code>, optionally using a delimiter character
- <code>sym2</code>. See also <code><a href="#dat$">dat$</a></code>,
- <code><a href="#$tim">$tim</a></code>, <code><a
- href="#strDat">strDat</a></code> and <code><a
- href="#expDat">expDat</a></code>.
- <pre><code>
- : ($dat "20070601")
- -> 733134
- : ($dat "2007-06-01" "-")
- -> 733134
- </code></pre>
- <dt><a name="$tim"><code>($tim 'sym) -> tim</code></a>
- <dd>Converts a string to a <code><a href="#time">time</a></code>. The
- minutes and seconds are optional and default to zero. See also <code><a
- href="#tim$">tim$</a></code> and <code><a
- href="#$dat">$dat</a></code>.
- <pre><code>
- : (time ($tim "10:57:56"))
- -> (10 57 56)
- : (time ($tim "10:57"))
- -> (10 57 0)
- : (time ($tim "10"))
- -> (10 0 0)
- </code></pre>
- <dt><a name="%"><code>(% 'num ..) -> num</code></a>
- <dd>Returns the remainder from the divisions of successive <code>num</code>
- arguments. The sign of the result is that of the first argument. When one of the
- arguments evaluates to <code>NIL</code>, it is returned immediately. See also
- <code><a href="#/">/</a></code> and <code><a
- href="#*/">*/</a></code> .
- <pre><code>
- : (% 17 5)
- -> 2
- : (% -17 5) # Sign is that of the first argument
- -> -2
- : (% 5 2)
- -> 1
- : (% 15 10)
- -> 5
- : (% 15 10 2) # (% 15 10) -> 5, then (% 5 2) -> 1
- -> 1
- </code></pre>
- <dt><a name="&"><code>(& 'num ..) -> num</code></a>
- <dd>Returns the bitwise <code>AND</code> of all <code>num</code> arguments. When
- one of the arguments evaluates to <code>NIL</code>, it is returned immediately.
- See also <code><a href="#|">|</a></code>, <code><a
- href="#x|">x|</a></code> and <code><a
- href="#bit?">bit?</a></code>.
- <pre><code>
- : (& 6 3)
- -> 2
- : (& 7 3 1)
- -> 1
- </code></pre>
- <dt><a name="*"><code>(* 'num ..) -> num</code></a>
- <dd>Returns the product of all <code>num</code> arguments. When one of the
- arguments evaluates to <code>NIL</code>, it is returned immediately. See also
- <code><a href="#/">/</a></code>, <code><a
- href="#*/">*/</a></code>, <code><a href="ref_.html#+">+</a></code> and
- <code><a href="#-">-</a></code>.
- <pre><code>
- : (* 1 2 3)
- -> 6
- : (* 5 3 2 2)
- -> 60
- </code></pre>
- <dt><a name="**"><code>(** 'num1 'num2) -> num</code></a>
- <dd>Integer exponentiation: Returns <code>num1</code> to the power of
- <code>num2</code>.
- <pre><code>
- : (** 2 3)
- -> 8
- : (** 100 100)
- -> 10000000000000000000000000000000000000000000000000000000000000000000000000000
- 00000000000000000000000000000000000000000000000000000000000000000000000000000000
- 00000000000000000000000000000000000000000000
- </code></pre>
- <dt><a name="*/"><code>(*/ 'num1 ['num2 ..] 'num3) -> num</code></a>
- <dd>Returns the product of <code>num1</code> and all following <code>num2</code>
- arguments, divided by the <code>num3</code> argument. The result is rounded to
- the nearest integer value. When one of the arguments evaluates to
- <code>NIL</code>, it is returned immediately. Note that <code>*/</code> is
- especially useful for fixed point arithmetic, by multiplying with (or dividing
- by) the scale factor. See also <code><a href="#*">*</a></code>,
- <code><a href="#/">/</a></code>, <code><a
- href="#+">+</a></code>, <code><a href="ref_.html#-">-</a></code> and
- <code><a href="#sqrt">sqrt</a></code>.
- <pre><code>
- : (*/ 3 4 2)
- -> 6
- : (*/ 1234 2 10)
- -> 247
- : (*/ 100 6)
- -> 17
- : (scl 2)
- -> 2
- : (format (*/ 3.0 1.5 1.0) *Scl)
- -> "4.50"
- </code></pre>
- <dt><a name="+"><code>(+ 'num ..) -> num</code></a>
- <dd>Returns the sum of all <code>num</code> arguments. When one of the arguments
- evaluates to <code>NIL</code>, it is returned immediately. See also <code><a
- href="#inc">inc</a></code>, <code><a href="ref_.html#-">-</a></code>,
- <code><a href="#*">*</a></code>, <code><a
- href="#/">/</a></code> and <code><a href="ref_.html#*/">*/</a></code>.
- <pre><code>
- : (+ 1 2 3)
- -> 6
- </code></pre>
- <dt><a name="-"><code>(- 'num ..) -> num</code></a>
- <dd>Returns the difference of the first <code>num</code> argument and all
- following arguments. If only a single argument is given, it is negated. When one
- of the arguments evaluates to <code>NIL</code>, it is returned immediately. See
- also <code><a href="#dec">dec</a></code>, <code><a
- href="#+">+</a></code>, <code><a href="ref_.html#*">*</a></code>,
- <code><a href="#/">/</a></code> and <code><a
- href="#*/">*/</a></code>.
- <pre><code>
- : (- 7)
- -> -7
- : (- 7 2 1)
- -> 4
- </code></pre>
- <dt><a name="->"><code>(-> any [num]) -> any</code></a>
- <dd>Searches for the value of <code>any</code> (typically a <a
- href="#pilog">Pilog</a> variable, or an expression of variables) at top
- level (or level <code>num</code>) in the current environment. See also <code><a
- href="#prove">prove</a></code> and <code><a
- href="#unify">unify</a></code>.
- <pre><code>
- : (? (append (1 2 3) (4 5 6) @X) (^ @ (println 'X '= (-> @X))))
- X = (1 2 3 4 5 6)
- @X=(1 2 3 4 5 6)
- -> NIL
- </code></pre>
- <dt><a name="/"><code>(/ 'num ..) -> num</code></a>
- <dd>Returns the first <code>num</code> argument successively divided by all
- following arguments. When one of the arguments evaluates to <code>NIL</code>, it
- is returned immediately. See also <code><a href="#*">*</a></code>,
- <code><a href="#*/">*/</a></code>, <code><a
- href="#%">%</a></code>, <code><a href="ref_.html#+">+</a></code> and
- <code><a href="#-">-</a></code>.
- <pre><code>
- : (/ 12 3)
- -> 4
- : (/ 60 -3 2 2)
- -> -5
- </code></pre>
- <dt><a name=":"><code>(: sym|0 [sym1|cnt ..]) -> any</code></a>
- <dd>Fetches a value <code>any</code> from the properties of a symbol, or from a
- list, by applying the <code><a href="#get">get</a></code> algorithm to
- <code>This</code> and the following arguments. Used typically in methods or
- <code><a href="#with">with</a></code> bodies. <code>(: ..)</code> is
- equivalent to <code>(; This ..)</code>. See also <code><a
- href="#;">;</a></code>, <code><a href="ref_.html#=:">=:</a></code> and
- <code><a href="#::">::</a></code>.
- <pre><code>
- : (put 'X 'a 1)
- -> 1
- : (with 'X (: a))
- -> 1
- </code></pre>
- <dt><a name="::"><code>(:: sym [sym1|cnt .. sym2]) -> var</code></a>
- <dd>Fetches a property for a property key <code>sym</code> or <code>sym2</code>
- from a symbol. That symbol is <code>This</code> (if no other arguments are
- given), or a symbol found by applying the <code><a
- href="#get">get</a></code> algorithm to <code>This</code> and the
- following arguments. The property (the cons pair, not just its value) is
- returned, suitable for direct (destructive) manipulations with functions
- expecting a <code>var</code> argument. Used typically in methods or <code><a
- href="#with">with</a></code> bodies. See also <code><a
- href="#=:">=:</a></code>, <code><a
- href="#prop">prop</a></code> and <code><a
- href="#:">:</a></code>.
- <pre><code>
- : (with 'X (=: cnt 0) (inc (:: cnt)) (: cnt))
- -> 1
- </code></pre>
- <dt><a name=";"><code>(; 'sym1|lst [sym2|cnt ..]) -> any</code></a>
- <dd>Fetches a value <code>any</code> from the properties of a symbol, or from a
- list, by applying the <code><a href="#get">get</a></code> algorithm to
- <code>sym1|lst</code> and the following arguments. See also <code><a
- href="#:">:</a></code>, <code><a href="ref_.html#=:">=:</a></code> and
- <code><a href="#::">::</a></code>.
- <pre><code>
- : (put 'A 'a 1)
- -> 1
- : (put 'A 'b 'B)
- -> B
- : (put 'B 'c 7)
- -> 7
- : (; 'A a)
- -> 1
- : (; 'A b c)
- -> 7
- </code></pre>
- <dt><a name="<"><code>(< 'any ..) -> flg</code></a>
- <dd>Returns <code>T</code> when all arguments <code>any</code> are in strictly
- increasing order. See also <a href="#cmp">Comparing</a>.
- <pre><code>
- : (< 3 4)
- -> T
- : (< 'a 'b 'c)
- -> T
- : (< 999 'a)
- -> T
- </code></pre>
- <dt><a name="<="><code>(<= 'any ..) -> flg</code></a>
- <dd>Returns <code>T</code> when all arguments <code>any</code> are in strictly
- non-decreasing order. See also <a href="#cmp">Comparing</a>.
- <pre><code>
- : (<= 3 3)
- -> T
- : (<= 1 2 3)
- -> T
- : (<= "abc" "abc" "def")
- -> T
- </code></pre>
- <dt><a name="<>"><code>(<> 'any ..) -> flg</code></a>
- <dd>Returns <code>T</code> when not all <code>any</code> arguments are equal
- (structure equality). <code>(<> 'any ..)</code> is equivalent to <code>(not (=
- 'any ..))</code>. See also <a href="#cmp">Comparing</a>.
- <pre><code>
- : (<> 'a 'b)
- -> T
- : (<> 'a 'b 'b)
- -> T
- : (<> 'a 'a 'a)
- -> NIL
- </code></pre>
- <dt><a name="="><code>(= 'any ..) -> flg</code></a>
- <dd>Returns <code>T</code> when all <code>any</code> arguments are equal
- (structure equality). See also <a href="#cmp">Comparing</a>.
- <pre><code>
- : (= 6 (* 1 2 3))
- -> T
- : (= "a" "a")
- -> T
- : (== "a" "a")
- -> T
- : (= (1 (2) 3) (1 (2) 3))
- -> T
- </code></pre>
- <dt><a name="=0"><code>(=0 'any) -> 0 | NIL</code></a>
- <dd>Returns <code>0</code> when <code>any</code> is a number with value zero.
- See also <code><a href="#n0">n0</a></code>, <code><a
- href="#lt0">lt0</a></code>, <code><a
- href="#le0">le0</a></code>, <code><a
- href="#ge0">ge0</a></code> and <code><a
- href="#gt0">gt0</a></code>.
- <pre><code>
- : (=0 (- 6 3 2 1))
- -> 0
- : (=0 'a)
- -> NIL
- </code></pre>
- <dt><a name="=:"><code>(=: sym|0 [sym1|cnt .. sym2|0] 'any)</code></a>
- <dd>Stores a new value <code>any</code> for a property key <code>sym</code> or
- <code>sym2</code> (or in the symbol value for zero) in a symbol. That symbol is
- <code>This</code> (if no other arguments are given), or a symbol found by
- applying the <code><a href="#get">get</a></code> algorithm to
- <code>This</code> and the following arguments. Used typically in methods or
- <code><a href="#with">with</a></code> bodies. See also <code><a
- href="#put">put</a></code>, <code><a href="ref_.html#:">:</a></code>
- and <code><a href="#::">::</a></code>.
- <pre><code>
- : (with 'X (=: a 1) (=: b 2))
- -> 2
- : (get 'X 'a)
- -> 1
- : (get 'X 'b)
- -> 2
- </code></pre>
- <dt><a name="=="><code>(== 'any ..) -> flg</code></a>
- <dd>Returns <code>T</code> when all <code>any</code> arguments are the same
- (pointer equality). See also <code><a href="#n==">n==</a></code> and <a
- href="#cmp">Comparing</a>.
- <pre><code>
- : (== 'a 'a)
- -> T
- : (== 'NIL NIL (val NIL) (car NIL) (cdr NIL))
- -> T
- : (== (1 2 3) (1 2 3))
- -> NIL
- </code></pre>
- <dt><a name="===="><code>(==== ['sym ..]) -> NIL</code></a>
- <dd>Close the current transient scope by clearing the transient index. All
- transient symbols become hidden and inaccessible by the reader. Then any
- optional <code>sym</code> arguments are (re-)inserted into the transient index.
- See also <code><a href="#extern">extern</a></code> and <code><a
- href="#intern">intern</a></code>.
- <pre><code>
- : (setq S "abc") # Read "abc"
- -> "abc"
- : (== S "abc") # Read again, get the same symbol
- -> T
- : (====) # Close scope
- -> NIL
- : (== S "abc") # Read again, get another symbol
- -> NIL
- </code></pre>
- <dt><a name="=T"><code>(=T 'any) -> flg</code></a>
- <dd>Returns <code>T</code> when <code>any</code> is the symbol <code>T</code>.
- <code>(=T X)</code> is equivalent to <code>(== T X)</code>. See also <a
- href="#nT">nT</a>.
- <pre><code>
- : (=T 0)
- -> NIL
- : (=T "T")
- -> NIL
- : (=T T)
- -> T
- </code></pre>
- <dt><a name=">"><code>(> 'any ..) -> flg</code></a>
- <dd>Returns <code>T</code> when all arguments <code>any</code> are in strictly
- decreasing order. See also <a href="#cmp">Comparing</a>.
- <pre><code>
- : (> 4 3)
- -> T
- : (> 'A 999)
- -> T
- </code></pre>
- <dt><a name=">="><code>(>= 'any ..) -> flg</code></a>
- <dd>Returns <code>T</code> when all arguments <code>any</code> are in strictly
- non-increasing order. See also <a href="#cmp">Comparing</a>.
- <pre><code>
- : (>= 'A 999)
- -> T
- : (>= 3 2 2 1)
- -> T
- </code></pre>
- <dt><a name=">>"><code>(>> 'cnt 'num) -> num</code></a>
- <dd>Shifts right the <code>num</code> argument by <code>cnt</code>
- bit-positions. If <code>cnt</code> is negative, a corresponding left shift is
- performed.
- <pre><code>
- : (>> 1 8)
- -> 4
- : (>> 3 16)
- -> 2
- : (>> -3 16)
- -> 128
- : (>> -1 -16)
- -> -32
- </code></pre>
- <dt><a name="?"><code>(? [sym ..] [pat 'any ..] . lst) -> flg</code></a>
- <dd>Top-level function for interactive <a href="#pilog">Pilog</a>
- queries. <code>?</code> is a non-evaluating front-end to the <code><a
- href="#query">query</a></code> function. It displays each result, waits
- for console input, and terminates when a non-empty line is entered. If a
- preceding list of (non-pattern-) symbols is given, they will be taken as rules
- to be traced by <code><a href="#prove">prove</a></code>. The list of
- variable/value pairs is passed to <code><a href="#goal">goal</a></code>
- for an initial Pilog environment. See also <code><a
- href="#pilog">pilog</a></code> and <code><a
- href="#solve">solve</a></code>.
- <pre><code>
- : (? (append (a b c) (d e f) @X))
- @X=(a b c d e f)
- -> NIL
- : (? (append @X @Y (a b c)))
- @X=NIL @Y=(a b c)
- @X=(a) @Y=(b c)
- @X=(a b) @Y=(c)
- @X=(a b c) @Y=NIL
- -> NIL
- : (? (append @X @Y (a b c)))
- @X=NIL @Y=(a b c). # Stopped
- -> NIL
- : (? append (append @X @Y (a b c))) # Trace 'append'
- 1 (append NIL (a b c) (a b c))
- @X=NIL @Y=(a b c)
- 2 (append (a . @X) @Y (a b c))
- 1 (append NIL (b c) (b c))
- @X=(a) @Y=(b c). # Stopped
- -> NIL
- </code></pre>
- <dt><a name="@"><code>@</code></a>
- <dd>Holds the result of the last top level expression in the current
- read-eval-print loop, or the result of the conditional expression during the
- evaluation of flow functions (see <code><a href="#atres">@
- Result</a></code>). When <code>@</code> is used as a formal parameter in <a
- href="#lambda">lambda expressions</a>, it denotes a variable number of
- evaluated arguments.
- <dt><a name="@@"><code>@@</code></a>
- <dd>Holds the result of the second last top level expression in the current
- read-eval-print loop (see <code><a href="#atres">@ Result</a></code>).
- Some functions store a secondary return value in <code>@@</code>.
- <dt><a name="@@@"><code>@@@</code></a>
- <dd>Holds the result of the third last top level expression in the current
- read-eval-print loop (see <code><a href="#atres">@ Result</a></code>).
- <dt><a name="^"><code>^</code></a>
- <dd>Holds the currently executed expression during a breakpoint or an error. See
- also <code><a href="#debug">debug</a></code>, <code><a
- href="#!">!</a></code>, <code><a href="refE.html#e">e</a></code> and
- <code><a href="#*Dbg">*Dbg</a></code>.
- <pre><code>
- : (* (+ 3 4) (/ 7 0))
- !? (/ 7 0)
- Div/0
- ? ^
- -> (/ 7 0)
- </code></pre>
- <dt><a name="|"><code>(| 'num ..) -> num</code></a>
- <dd>Returns the bitwise <code>OR</code> of all <code>num</code> arguments. When
- one of the arguments evaluates to <code>NIL</code>, it is returned immediately.
- See also <code><a href="#x|">x|</a></code>, <code><a
- href="#&">&</a></code> and <code><a
- href="#bit?">bit?</a></code>.
- <pre><code>
- : (| 1 2)
- -> 3
- : (| 1 2 4 8)
- -> 15
- </code></pre>
- </dl>
- <h1><a name="I">I</a></h1>
- <dl>
- <dt><a name="+Idx"><code>+Idx</code></a>
- <dd>Prefix class for maintaining non-unique full-text indexes to <code><a
- href="#+String">+String</a></code> relations, a subclass of <code><a
- href="#+Ref">+Ref</a></code>. Accepts optional arguments for the
- minimally indexed substring length (defaults to 3), and a <code><a
- href="#+Hook">+Hook</a></code> attribute. Often used in combination
- with the <code><a href="#+Sn">+Sn</a></code> soundex index, or the
- <code><a href="#+Fold">+Fold</a></code> index prefix classes. See also
- <a href="#dbase">Database</a>.
- <pre><code>
- (rel nm (+Sn +Idx +String)) # Name
- </code></pre>
- <dt><a name="+IdxFold"><code>+IdxFold</code></a>
- <dd>Prefix class for maintaining non-unique indexes to subsequent substrings of
- the <code><a href="#fold">fold</a></code>ed individual words of
- <code><a href="#+String">+String</a></code> relations. Accepts optional
- arguments for the minimally indexed substring length (defaults to 3), and a
- <code><a href="#+Hook">+Hook</a></code> attribute. See also <code><a
- href="#+Idx">+Idx</a></code> and <a href="ref.html#dbase">Database</a>.
- <pre><code>
- (rel nm (+IdxFold +String)) # Item Description
- </code></pre>
- <dt><a name="+index"><code>+index</code></a>
- <dd>Abstract base class of all database B-Tree index relations (prefix classes
- for <code><a href="#+relation">+relation</a></code>s). The class
- hierarchy includes <code><a href="#+Key">+Key</a></code>, <code><a
- href="#+Ref">+Ref</a></code>, <code><a
- href="#+Idx">+Idx</a></code> and <code><a
- href="#+IdxFold">+IdxFold</a></code>. See also <a
- href="#dbase">Database</a>.
- <pre><code>
- (isa '+index Rel) # Check for an index relation
- </code></pre>
- <dt><a name="id"><code>(id 'num ['num]) -> sym</code></a>
- <dt><code>(id 'sym [NIL]) -> num</code>
- <dt><code>(id 'sym T) -> (num . num)</code>
- <dd>Converts one or two numbers to an external symbol, or an external symbol to
- a number or a pair of numbers.
- <pre><code>
- : (id 7)
- -> {7}
- : (id 1 2)
- -> {2}
- : (id '{1-2})
- -> 2
- : (id '{1-2} T)
- -> (1 . 2)
- </code></pre>
- <dt><a name="idx"><code>(idx 'var 'any 'flg) -> lst<br>
- (idx 'var 'any) -> lst<br>
- (idx 'var) -> lst</code></a>
- <dd>Maintains an index tree in <code>var</code>, and checks for the existence of
- <code>any</code>. If <code>any</code> is contained in <code>var</code>, the
- corresponding subtree is returned, otherwise <code>NIL</code>. In the first
- form, <code>any</code> is destructively inserted into the tree if
- <code>flg</code> is non-<code>NIL</code> (and <code>any</code> was not already
- there), or deleted from the tree if <code>flg</code> is <code>NIL</code>. The
- second form only checks for existence, but does not change the index tree. In
- the third form (when called with a single <code>var</code> argument) the
- contents of the tree are returned as a sorted list. If all elements are inserted
- in sorted order, the tree degenerates into a linear list. See also <code><a
- href="#lup">lup</a></code>, <code><a
- href="#hash">hash</a></code>, <code><a
- href="#depth">depth</a></code>, <code><a
- href="#sort">sort</a></code>, <code><a
- href="#balance">balance</a></code> and <code><a
- href="#member">member</a></code>.
- <pre><code>
- : (idx 'X 'd T) # Insert data
- -> NIL
- : (idx 'X 2 T)
- -> NIL
- : (idx 'X '(a b c) T)
- -> NIL
- : (idx 'X 17 T)
- -> NIL
- : (idx 'X 'A T)
- -> NIL
- : (idx 'X 'd T)
- -> (d (2 NIL 17 NIL A) (a b c)) # 'd' already existed
- : (idx 'X T T)
- -> NIL
- : X # View the index tree
- -> (d (2 NIL 17 NIL A) (a b c) NIL T)
- : (idx 'X 'A) # Check for 'A'
- -> (A)
- : (idx 'X 'B) # Check for 'B'
- -> NIL
- : (idx 'X)
- -> (2 17 A d (a b c) T) # Get list
- : (idx 'X 17 NIL) # Delete '17'
- -> (17 NIL A)
- : X
- -> (d (2 NIL A) (a b c) NIL T) # View it again
- : (idx 'X)
- -> (2 A d (a b c) T) # '17' is deleted
- </code></pre>
- <dt><a name="if"><code>(if 'any1 'any2 . prg) -> any</code></a>
- <dd>Conditional execution: If the condition <code>any1</code> evaluates to
- non-<code>NIL</code>, <code>any2</code> is evaluated and returned. Otherwise,
- <code>prg</code> is executed and the result returned. See also <code><a
- href="#cond">cond</a></code>, <code><a
- href="#when">when</a></code> and <code><a
- href="#if2">if2</a></code>.
- <pre><code>
- : (if (> 4 3) (println 'OK) (println 'Bad))
- OK
- -> OK
- : (if (> 3 4) (println 'OK) (println 'Bad))
- Bad
- -> Bad
- </code></pre>
- <dt><a name="if2"><code>(if2 'any1 'any2 'any3 'any4 'any5 . prg) -> any</code></a>
- <dd>Four-way conditional execution for two conditions: If both conditions
- <code>any1</code> and <code>any2</code> evaluate to non-<code>NIL</code>,
- <code>any3</code> is evaluated and returned. Otherwise, <code>any4</code> or
- <code>any5</code> is evaluated and returned if <code>any1</code> or
- <code>any2</code> evaluate to non-<code>NIL</code>, respectively. If none of the
- conditions evaluate to non-<code>NIL</code>, <code>prg</code> is executed and
- the result returned. See also <code><a href="#if">if</a></code> and
- <code><a href="#cond">cond</a></code>.
- <pre><code>
- : (if2 T T 'both 'first 'second 'none)
- -> both
- : (if2 T NIL 'both 'first 'second 'none)
- -> first
- : (if2 NIL T 'both 'first 'second 'none)
- -> second
- : (if2 NIL NIL 'both 'first 'second 'none)
- -> none
- </code></pre>
- <dt><a name="ifn"><code>(ifn 'any1 'any2 . prg) -> any</code></a>
- <dd>Conditional execution ("If not"): If the condition <code>any1</code>
- evaluates to <code>NIL</code>, <code>any2</code> is evaluated and returned.
- Otherwise, <code>prg</code> is executed and the result returned.
- <pre><code>
- : (ifn (= 3 4) (println 'OK) (println 'Bad))
- OK
- -> OK
- </code></pre>
- <dt><a name="import"><code>(import . lst) -> NIL</code></a>
- <dd>Wrapper function for <code><a href="#intern">intern</a></code>.
- Typically used to import symbols from other namespaces, as created by <code><a
- href="#symbols">symbols</a></code>. <code>lst</code> should be a list
- of symbols. An import conflict error is issued when a symbol with the same name
- already exists in the current namespace. See also <code><a
- href="#pico">pico</a></code> and <code><a
- href="#local">local</a></code>.
- <pre><code>
- : (import libA~foo libB~bar)
- -> NIL
- </code></pre>
- <dt><a name="in"><code>(in 'any . prg) -> any</code></a>
- <dd>Opens <code>any</code> as input channel during the execution of
- <code>prg</code>. The current input channel will be saved and restored
- appropriately. If the argument is <code>NIL</code>, standard input is used. If
- the argument is a symbol, it is used as a file name (opened for reading
- <i>and</i> writing if the first character is "<code>+</code>"). If it is a
- positive number, it is used as the descriptor of an open file. If it is a
- negative number, the saved input channel such many levels above the current one
- is used. Otherwise (if it is a list), it is taken as a command with arguments,
- and a pipe is opened for input. See also <code><a
- href="#ipid">ipid</a></code>, <code><a
- href="#call">call</a></code>, <code><a
- href="#load">load</a></code>, <code><a
- href="#file">file</a></code>, <code><a
- href="#out">out</a></code>, <code><a
- href="#err">err</a></code>, <code><a
- href="#poll">poll</a></code>, <code><a
- href="#pipe">pipe</a></code> and <code><a
- href="#ctl">ctl</a></code>.
- <pre><code>
- : (in "a" (list (read) (read) (read))) # Read three items from file "a"
- -> (123 (a b c) def)
- </code></pre>
- <dt><a name="inc"><code>(inc 'num) -> num<br>
- (inc 'var ['num]) -> num</code></a>
- <dd>The first form returns the value of <code>num</code> incremented by 1. The
- second form increments the <code>VAL</code> of <code>var</code> by 1, or by
- <code>num</code>. If the first argument is <code>NIL</code>, it is returned
- immediately. <code>(inc Num)</code> is equivalent to <code>(+ Num 1)</code> and
- <code>(inc 'Var)</code> is equivalent to <code>(set 'Var (+ Var 1))</code>. See
- also <code><a href="#dec">dec</a></code> and <code><a
- href="#+">+</a></code>.
- <pre><code>
- : (inc 7)
- -> 8
- : (inc -1)
- -> 0
- : (zero N)
- -> 0
- : (inc 'N)
- -> 1
- : (inc 'N 7)
- -> 8
- : N
- -> 8
- : (setq L (1 2 3 4))
- -> (1 2 3 4)
- : (inc (cdr L))
- -> 3
- : L
- -> (1 3 3 4)
- </code></pre>
- <dt><a name="inc!"><code>(inc! 'obj 'sym ['num]) -> num</code></a>
- <dd><a href="#trans">Transaction</a> wrapper function for <code><a
- href="#inc">inc</a></code>. <code>num</code> defaults to 1. Note that
- for incrementing a property value of an entity typically the <code><a
- href="#entityMesssages">inc!></a></code> message is used. See also
- <code><a href="#new!">new!</a></code>, <code><a
- href="#set!">set!</a></code> and <code><a
- href="#put!">put!</a></code>.
- <pre><code>
- (inc! Obj 'cnt 0) # Incrementing a property of a non-entity object
- </code></pre>
- <dt><a name="index"><code>(index 'any 'lst) -> cnt | NIL</code></a>
- <dd>Returns the <code>cnt</code> position of <code>any</code> in
- <code>lst</code>, or <code>NIL</code> if it is not found. See also <code><a
- href="#offset">offset</a></code> and <code><a
- href="#sub?">sub?</a></code>.
- <pre><code>
- : (index 'c '(a b c d e f))
- -> 3
- : (index '(5 6) '((1 2) (3 4) (5 6) (7 8)))
- -> 3
- </code></pre>
- <dt><a name="info"><code>(info 'any ['flg]) -> (cnt|T dat . tim)</code></a>
- <dd>Returns information about a file with the name <code>any</code>: The current
- size <code>cnt</code> in bytes, and the modification date and time (UTC). For
- directories, <code>T</code> is returned instead of the size. If <code>flg</code>
- is non-<code>NIL</code> and <code>any</code> is the name of a symbolic link,
- then the link itself is used, not the file that it refers to. See also <code><a
- href="#dir">dir</a></code>, <code><a
- href="#date">date</a></code>, <code><a
- href="#time">time</a></code> and <code><a
- href="#lines">lines</a></code>.
- <pre><code>
- $ ls -l x.l
- -rw-r--r-- 1 abu users 208 Jun 17 08:58 x.l
- $ pil +
- : (info "x.l")
- -> (208 730594 . 32315)
- : (stamp 730594 32315)
- -> "2000-06-17 08:58:35"
- </code></pre>
- <dt><a name="init"><code>(init 'tree ['any1] ['any2]) -> lst</code></a>
- <dd>Initializes a structure for stepping iteratively through a database tree.
- <code>any1</code> and <code>any2</code> may specify a range of keys. If
- <code>any2</code> is greater than <code>any1</code>, the traversal will be in
- opposite direction. See also <code><a href="#tree">tree</a></code>,
- <code><a href="#step">step</a></code>, <code><a
- href="#iter">iter</a></code> and <code><a
- href="#scan">scan</a></code>.
- <pre><code>
- : (init (tree 'nr '+Item) 3 5)
- -> (((3 . 5) ((3 NIL . {3-3}) (4 NIL . {3-4}) (5 NIL . {3-5}) (6 NIL . {3-6}) (7 NIL . {3-8}))))
- </code></pre>
- <dt><a name="insert"><code>(insert 'cnt 'lst 'any) -> lst</code></a>
- <dd>Inserts <code>any</code> into <code>lst</code> at position <code>cnt</code>.
- This is a non-destructive operation. See also <code><a
- href="#remove">remove</a></code>, <code><a
- href="#place">place</a></code>, <code><a
- href="#append">append</a></code>, <code><a
- href="#delete">delete</a></code> and <code><a
- href="#replace">replace</a></code>.
- <pre><code>
- : (insert 3 '(a b c d e) 777)
- -> (a b 777 c d e)
- : (insert 1 '(a b c d e) 777)
- -> (777 a b c d e)
- : (insert 9 '(a b c d e) 777)
- -> (a b c d e 777)
- </code></pre>
- <dt><a name="intern"><code>(intern 'sym) -> sym</code></a>
- <dd>Creates or finds an internal symbol. If a symbol with the name
- <code>sym</code> is already intern, it is returned. Otherwise, <code>sym</code>
- is interned and returned. See also <code><a
- href="#symbols">symbols</a></code>, <code><a
- href="#zap">zap</a></code>, <code><a
- href="#extern">extern</a></code> and <code><a
- href="#====">====</a></code>.
- <pre><code>
- : (intern "abc")
- -> abc
- : (intern 'car)
- -> car
- : ((intern (pack "c" "a" "r")) (1 2 3))
- -> 1
- </code></pre>
- <dt><a name="ipid"><code>(ipid) -> pid | NIL</code></a>
- <dd>Returns the corresponding process ID when the current input channel is
- reading from a pipe, otherwise <code>NIL</code>. See also <code><a
- href="#opid">opid</a></code>, <code><a
- href="#in">in</a></code>, <code><a
- href="#pipe">pipe</a></code> and <code><a
- href="#load">load</a></code>.
- <pre><code>
- : (in '(ls "-l") (println (line T)) (kill (ipid)))
- "total 7364"
- -> T
- </code></pre>
- <dt><a name="isa"><code>(isa 'cls|typ 'obj) -> obj | NIL</code></a>
- <dd>Returns <code>obj</code> when it is an object that inherits from
- <code>cls</code> or <code>type</code>. See also <a href="#oop">OO
- Concepts</a>, <code><a href="#class">class</a></code>, <code><a
- href="#type">type</a></code>, <code><a
- href="#new">new</a></code> and <code><a
- href="#object">object</a></code>.
- <pre><code>
- : (isa '+Address Obj)
- -> {1-17}
- : (isa '(+Male +Person) Obj)
- -> NIL
- </code></pre>
- <dt><a name="isa/2"><code>isa/2</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that succeeds if the second
- argument is of the type or class given by the first argument, according to the
- <code><a href="#isa">isa</a></code> function. Typically used in
- <code><a href="#db/3">db/3</a></code> or <code><a
- href="#select/3">select/3</a></code> database queries. See also
- <code><a href="#same/3">same/3</a></code>, <code><a
- href="#bool/3">bool/3</a></code>, <code><a
- href="#range/3">range/3</a></code>, <code><a
- href="#head/3">head/3</a></code>, <code><a
- href="#fold/3">fold/3</a></code>, <code><a
- href="#part/3">part/3</a></code> and <code><a
- href="#tolr/3">tolr/3</a></code>.
- <pre><code>
- : (? (db nm +Person @Prs) (isa +Woman @Prs) (val @Nm @Prs nm))
- @Prs={2-Y} @Nm="Alexandra of Denmark"
- @Prs={2-1I} @Nm="Alice Maud Mary"
- @Prs={2-F} @Nm="Anne"
- @Prs={2-j} @Nm="Augusta Victoria". # Stop
- </code></pre>
- <dt><a name="iter"><code>(iter 'tree ['fun] ['any1] ['any2] ['flg])</code></a>
- <dd>Iterates through a database tree by applying <code>fun</code> to all values.
- <code>fun</code> defaults to <code><a
- href="#println">println</a></code>. <code>any1</code> and
- <code>any2</code> may specify a range of keys. If <code>any2</code> is greater
- than <code>any1</code>, the traversal will be in opposite direction. Note that
- the keys need not to be atomic, depending on the application's index structure.
- If <code>flg</code> is non-<code>NIL</code>, partial keys are skipped. See also
- <code><a href="#tree">tree</a></code>, <code><a
- href="#ubIter">ubIter</a></code>, <code><a
- href="#scan">scan</a></code>, <code><a
- href="#init">init</a></code> and <code><a
- href="#step">step</a></code>.
- <pre><code>
- : (iter (tree 'nr '+Item))
- {3-1}
- {3-2}
- {3-3}
- {3-4}
- {3-5}
- {3-6}
- {3-8}
- -> {7-1}
- : (iter (tree 'nr '+Item) '((This) (println (: nm))))
- "Main Part"
- "Spare Part"
- "Auxiliary Construction"
- "Enhancement Additive"
- "Metal Fittings"
- "Gadget Appliance"
- "Testartikel"
- -> {7-1}
- </code></pre>
- </dl>
- <h1><a name="J">J</a></h1>
- <dl>
- <dt><a name="+Joint"><code>+Joint</code></a>
- <dd>Class for bidirectional object relations, a subclass of <code><a
- href="#+Link">+Link</a></code>. Expects a (symbolic) attribute, and
- list of classes as <code><a href="#type">type</a></code> of the
- referred database object (of class <code><a
- href="#+Entity">+Entity</a></code>). A <code>+Joint</code> corresponds
- to two <code>+Link</code>s, where the attribute argument is the relation of the
- back-link in the referred object. See also <a
- href="#dbase">Database</a>.
- <pre><code>
- (class +Ord +Entity) # Order class
- (rel pos (+List +Joint) ord (+Pos)) # List of positions in that order
- ...
- (class +Pos +Entity) # Position class
- (rel ord (+Joint) # Back-link to the parent order
- </code></pre>
- <dt><a name="job"><code>(job 'lst . prg) -> any</code></a>
- <dd>Executes a job within its own environment (as specified by symbol-value
- pairs in <code>lst</code>). The current values of all symbols are saved, the
- symbols are bound to the values in <code>lst</code>, <code>prg</code> is
- executed, then the (possibly modified) symbol values are (destructively) stored
- in the environment list, and the symbols are restored to their original values.
- The return value is the result of <code>prg</code>. Typically used in <code><a
- href="#curry">curried</a></code> functions and <code><a
- href="#*Run">*Run</a></code> tasks. See also <code><a
- href="#env">env</a></code>, <code><a
- href="#bind">bind</a></code>, <code><a
- href="#let">let</a></code>, <code><a
- href="#use">use</a></code> and <code><a
- href="#state">state</a></code>.
- <pre><code>
- : (de tst ()
- (job '((A . 0) (B . 0))
- (println (inc 'A) (inc 'B 2)) ) )
- -> tst
- : (tst)
- 1 2
- -> 2
- : (tst)
- 2 4
- -> 4
- : (tst)
- 3 6
- -> 6
- : (pp 'tst)
- (de tst NIL
- (job '((A . 3) (B . 6))
- (println (inc 'A) (inc 'B 2)) ) )
- -> tst
- </code></pre>
- <dt><a name="journal"><code>(journal 'any ..) -> T</code></a>
- <dd>Reads journal data from the files with the names <code>any</code>, and
- writes all changes to the database. See also <code><a
- href="#pool">pool</a></code>.
- <pre><code>
- : (journal "db.log")
- -> T
- </code></pre>
- </dl>
- <h1><a name="K">K</a></h1>
- <dl>
- <dt><a name="+Key"><code>+Key</code></a>
- <dd>Prefix class for maintaining unique indexes to <code><a
- href="#+relation">+relation</a></code>s, a subclass of <code><a
- href="#+index">+index</a></code>. Accepts an optional argument for a
- <code><a href="#+Hook">+Hook</a></code> attribute. See also <a
- href="#dbase">Database</a>.
- <pre><code>
- (rel nr (+Need +Key +Number)) # Mandatory, unique Customer/Supplier number
- </code></pre>
- <dt><a name="key"><code>(key ['cnt]) -> sym</code></a>
- <dd>Returns the next character from standard input as a single-character
- transient symbol. The console is set to raw mode. While waiting for a key press,
- a <code>select</code> system call is executed for all file descriptors and
- timers in the <code>VAL</code> of the global variable <code><a
- href="#*Run">*Run</a></code>. If <code>cnt</code> is
- non-<code>NIL</code>, that amount of milliseconds is waited maximally, and
- <code>NIL</code> is returned upon timeout. See also <code><a
- href="#raw">raw</a></code> and <code><a
- href="#wait">wait</a></code>.
- <pre><code>
- : (key) # Wait for a key
- -> "a" # 'a' pressed
- </code></pre>
- <dt><a name="kids"><code>(kids) -> lst</code></a>
- <dd>Returns a list of process IDs of all running child processes. See also
- <code><a href="#fork">fork</a></code>, <code><a
- href="#pipe">pipe</a></code>, <code><a
- href="#tell">tell</a></code>, <code><a
- href="#proc">proc</a></code> and <code><a
- href="#kill">kill</a></code>.
- <pre><code>
- : (unless (fork) (wait 60000) (bye))
- -> NIL
- : (unless (fork) (wait 60000) (bye))
- -> NIL
- : (proc 'pil)
- PID PPID STARTED SIZE %CPU WCHAN CMD
- 2205 22853 19:45:24 1336 0.1 - /usr/bin/picolisp /usr/lib/picolisp/lib.l /usr/bin/pil +
- 2266 2205 19:45:30 1336 0.0 - /usr/bin/picolisp /usr/lib/picolisp/lib.l /usr/bin/pil +
- 2300 2205 19:45:33 1336 0.0 - /usr/bin/picolisp /usr/lib/picolisp/lib.l /usr/bin/pil +
- -> T
- : (kids)
- -> (2300 2266)
- </code></pre>
- <dt><a name="kill"><code>(kill 'pid ['cnt]) -> flg</code></a>
- <dd>Sends a signal with the signal number <code>cnt</code> (or SIGTERM if
- <code>cnt</code> is not given) to the process with the ID <code>pid</code>.
- Returns <code>T</code> if successful.
- <pre><code>
- : (kill *Pid 20) # Stop current process
- [2]+ Stopped pil + # Unix shell
- $ fg # Job control: Foreground
- pil +
- -> T # 'kill' was successful
- </code></pre>
- </dl>
- <h1><a name="L">L</a></h1>
- <dl>
- <dt><a name="*Led"><code>*Led</code></a>
- <dd>(Debug mode only) A global variable holding a (possibly empty)
- <code>prg</code> body that implements a "Line editor". When
- non-<code>NIL</code>, it should return a single symbol (string) upon execution.
- <pre><code>
- : (de *Led "(bye)")
- # *Led redefined
- -> *Led
- : $ # Exit
- </code></pre>
- <dt><a name="+Link"><code>+Link</code></a>
- <dd>Class for object relations, a subclass of <code><a
- href="#+relation">+relation</a></code>. Expects a list of classes as
- <code><a href="#type">type</a></code> of the referred database object
- (of class <code><a href="#+Entity">+Entity</a></code>). See also <a
- href="#dbase">Database</a>.
- <pre><code>
- (rel sup (+Ref +Link) NIL (+CuSu)) # Supplier (class Customer/Supplier)
- </code></pre>
- <dt><a name="+List"><code>+List</code></a>
- <dd>Prefix class for a list of identical relations. Objects of that class
- maintain a list of Lisp data of uniform type. See also <a
- href="#dbase">Database</a>.
- <pre><code>
- (rel pos (+List +Joint) ord (+Pos)) # Positions
- (rel nm (+List +Ref +String)) # List of indexed strings
- (rel val (+Ref +List +Number)) # Indexed list of numeric values
- </code></pre>
- <dt><a name="last"><code>(last 'lst) -> any</code></a>
- <dd>Returns the last element of <code>lst</code>. See also <code><a
- href="#fin">fin</a></code> and <code><a
- href="#tail">tail</a></code>.
- <pre><code>
- : (last (1 2 3 4))
- -> 4
- : (last '((a b) c (d e f)))
- -> (d e f)
- </code></pre>
- <dt><a name="later"><code>(later 'var . prg) -> var</code></a>
- <dd>Executes <code>prg</code> in a <code><a
- href="#pipe">pipe</a></code>'ed child process. The return value of
- <code>prg</code> will later be available in <code>var</code>.
- <pre><code>
- : (prog1 # Parallel background calculation of square numbers
- (mapcan '((N) (later (cons) (* N N))) (1 2 3 4))
- (wait NIL (full @)) )
- -> (1 4 9 16)
- </code></pre>
- <dt><a name="ld"><code>(ld) -> any</code></a>
- <dd>(Debug mode only) <code><a href="#load">load</a></code>s the last
- file edited with <code><a href="#vi">vi</a></code> or <code><a
- href="#em">em</a></code>.
- <pre><code>
- : (vi 'main)
- -> T
- : (ld)
- # main redefined
- -> go
- </code></pre>
- <dt><a name="le0"><code>(le0 'any) -> num | NIL</code></a>
- <dd>Returns <code>num</code> when the argument is a number less or equal zero,
- otherwise <code>NIL</code>. See also <code><a
- href="#lt0">lt0</a></code>, <code><a
- href="#ge0">ge0</a></code>, <code><a
- href="#gt0">gt0</a></code>, <code><a href="ref_.html#=0">=0</a></code>
- and <code><a href="#n0">n0</a></code>.
- <pre><code>
- : (le0 -2)
- -> -2
- : (le0 0)
- -> 0
- : (le0 3)
- -> NIL
- </code></pre>
- <dt><a name="leaf"><code>(leaf 'tree) -> any</code></a>
- <dd>Returns the first leaf (i.e. the value of the smallest key) in a database
- tree. See also <code><a href="#tree">tree</a></code>, <code><a
- href="#minKey">minKey</a></code>, <code><a
- href="#maxKey">maxKey</a></code> and <code><a
- href="#step">step</a></code>.
- <pre><code>
- : (leaf (tree 'nr '+Item))
- -> {3-1}
- : (db 'nr '+Item (minKey (tree 'nr '+Item)))
- -> {3-1}
- </code></pre>
- <dt><a name="length"><code>(length 'any) -> cnt | T</code></a>
- <dd>Returns the "length" of <code>any</code>. For numbers this is the number of
- decimal digits in the value (plus 1 for negative values), for symbols it is the
- number of characters in the name, and for lists it is the number of cells (or
- <code>T</code> for circular lists). See also <code><a
- href="#size">size</a></code> and <code><a
- href="#bytes">bytes</a></code>.
- <pre><code>
- : (length "abc")
- -> 3
- : (length "äbc")
- -> 3
- : (length 123)
- -> 3
- : (length (1 (2) 3))
- -> 3
- : (length (1 2 3 .))
- -> T
- </code></pre>
- <dt><a name="less"><code>(less 'any) -> any</code></a>
- <dd>(Debug mode only) Returns a reduced form of <code>any</code>, where for each
- list and its sublists only the first two elements, possibly followed by
- <code>..</code>, are retained.
- <pre><code>
- : (less '(a b c d))
- -> (a b ..)
- : (less '((a b c) ((d e f) g h) i j))
- -> ((a b ..) ((d e ..) g ..) ..)
- </code></pre>
- <dt><a name="let"><code>(let sym 'any . prg) -> any</code></a>
- <dt><code>(let (sym|lst 'any ..) . prg) -> any</code>
- <dd>Defines local variables. The value of the symbol <code>sym</code> - or the
- values of the symbols <code>sym</code> in the list of the second form - are
- saved and the symbols are bound to the evaluated <code>any</code> arguments. The
- 64-bit version also accepts <code>lst</code> arguments in the second form; they
- may consist only of symbols and sublists, and match the <code>any</code>
- argument (destructuring bind). <code>prg</code> is executed, then the symbols
- are restored to their original values. The result of <code>prg</code> is
- returned. It is an error condition to pass <code>NIL</code> as a
- <code>sym</code> argument. In destructuring patterns, <code>NIL</code> denotes a
- "don't care" position. See also <code><a href="#let?">let?</a></code>,
- <code><a href="#bind">bind</a></code>, <code><a
- href="#recur">recur</a></code>, <code><a
- href="#with">with</a></code>, <code><a
- href="#for">for</a></code>, <code><a
- href="#job">job</a></code> and <code><a
- href="#use">use</a></code>.
- <pre><code>
- : (setq X 123 Y 456)
- -> 456
- : (let X "Hello" (println X))
- "Hello"
- -> "Hello"
- : (let (X "Hello" Y "world") (prinl X " " Y))
- Hello world
- -> "world"
- : X
- -> 123
- : Y
- -> 456
- # 64-bit version
- : (let (A 1 (B . C) (2 3) D 4)
- (list A B C D) )
- -> (1 2 (3) 4)
- : (let (((A . B) (C) . D) '((1 2 3) (4 5 6) 7 8 9))
- (list A B C D) )
- -> (1 (2 3) 4 (7 8 9))
- : (let (((A . NIL) NIL NIL D) '((1 2 3) (4 5 6) 7 8 9))
- (trail T) )
- -> (A 1 D 8)
- </code></pre>
- <dt><a name="let?"><code>(let? sym 'any . prg) -> any</code></a>
- <dd>Conditional local variable binding and execution: If <code>any</code>
- evaluates to <code>NIL</code>, <code>NIL</code> is returned. Otherwise, the
- value of the symbol <code>sym</code> is saved and <code>sym</code> is bound to
- the evaluated <code>any</code> argument. <code>prg</code> is executed, then
- <code>sym</code> is restored to its original value. The result of
- <code>prg</code> is returned. It is an error condition to pass <code>NIL</code>
- as the <code>sym</code> argument. <code>(let? sym 'any ..)</code> is equivalent
- to <code>(when 'any (let sym @ ..))</code>. See also <code><a
- href="#let">let</a></code>, <code><a
- href="#bind">bind</a></code>, <code><a
- href="#job">job</a></code> and <code><a
- href="#use">use</a></code>.
- <pre><code>
- : (setq Lst (1 NIL 2 NIL 3))
- -> (1 NIL 2 NIL 3)
- : (let? A (pop 'Lst) (println 'A A))
- A 1
- -> 1
- : (let? A (pop 'Lst) (println 'A A))
- -> NIL
- </code></pre>
- <dt><a name="lieu"><code>(lieu 'any) -> sym | NIL</code></a>
- <dd>Returns the argument <code>any</code> when it is an external symbol and
- currently manifest in heap space, otherwise <code>NIL</code>. See also <code><a
- href="#ext?">ext?</a></code>.
- <pre><code>
- : (lieu *DB)
- -> {1}
- </code></pre>
- <dt><a name="line"><code>(line 'flg ['cnt ..]) -> lst|sym</code></a>
- <dd>Reads a line of characters from the current input channel. End of line is
- recognized as linefeed (hex "0A"), carriage return (hex "0D"), or the
- combination of both. (Note that a single carriage return may not work on network
- connections, because the character look-ahead to distinguish from
- return+linefeed can block the connection.) If <code>flg</code> is
- <code>NIL</code>, a list of single-character transient symbols is returned. When
- <code>cnt</code> arguments are given, subsequent characters of the input line
- are grouped into sublists, to allow parsing of fixed field length records. If
- <code>flg</code> is non-<code>NIL</code>, strings are returned instead of
- single-character lists. <code>NIL</code> is returned upon end of file. See also
- <code><a href="#char">char</a></code>, <code><a
- href="#read">read</a></code>, <code><a
- href="#till">till</a></code> and <code><a
- href="#eof">eof</a></code>.
- <pre><code>
- : (line)
- abcdefghijkl
- -> ("a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l")
- : (line T)
- abcdefghijkl
- -> "abcdefghijkl"
- : (line NIL 1 2 3)
- abcdefghijkl
- -> (("a") ("b" "c") ("d" "e" "f") "g" "h" "i" "j" "k" "l")
- : (line T 1 2 3)
- abcdefghijkl
- -> ("a" "bc" "def" "g" "h" "i" "j" "k" "l")
- </code></pre>
- <dt><a name="lines"><code>(lines 'any ..) -> cnt</code></a>
- <dd>Returns the sum of the number of lines in the files with the names
- <code>any</code>, or <code>NIL</code> if none was found. See also <code><a
- href="#info">info</a></code>.
- <pre><code>
- : (lines "x.l")
- -> 11
- </code></pre>
- <dt><a name="link"><code>(link 'any ..) -> any</code></a>
- <dd>Links one or several new elements <code>any</code> to the end of the list in
- the current <code><a href="#make">make</a></code> environment. This
- operation is efficient also for long lists, because a pointer to the last
- element of the list is maintained. <code>link</code> returns the last linked
- argument. See also <code><a href="#yoke">yoke</a></code>, <code><a
- href="#chain">chain</a></code> and <code><a
- href="#made">made</a></code>.
- <pre><code>
- : (make
- (println (link 1))
- (println (link 2 3)) )
- 1
- 3
- -> (1 2 3)
- </code></pre>
- <dt><a name="lint"><code>(lint 'sym) -> lst</code></a>
- <dt><code>(lint 'sym 'cls) -> lst</code>
- <dt><code>(lint '(sym . cls)) -> lst</code>
- <dd>(Debug mode only) Checks the function definition or file contents (in the
- first form), or the method body of sym (second and third form), for possible
- pitfalls. Returns an association list of diagnoses, where <code>var</code>
- indicates improper variables, <code>dup</code> duplicate parameters,
- <code>def</code> an undefined function, <code>bnd</code> an unbound variable,
- and <code>use</code> unused variables. See also <code><a
- href="#noLint">noLint</a></code>, <code><a
- href="#lintAll">lintAll</a></code>, <code><a
- href="#debug">debug</a></code>, <code><a
- href="#trace">trace</a></code> and <code><a
- href="#*Dbg">*Dbg</a></code>.
- <pre><code>
- : (de foo (R S T R) # 'T' is a improper parameter, 'R' is duplicated
- (let N 7 # 'N' is unused
- (bar X Y) ) ) # 'bar' is undefined, 'X' and 'Y' are not bound
- -> foo
- : (lint 'foo)
- -> ((var T) (dup R) (def bar) (bnd Y X) (use N))
- </code></pre>
- <dt><a name="lintAll"><code>(lintAll ['sym ..]) -> lst</code></a>
- <dd>(Debug mode only) Applies <code><a href="#lint">lint</a></code> to
- <code><a href="#all">all</a></code> internal symbols - and optionally
- to all files <code>sym</code> - and returns a list of diagnoses. See also
- <code><a href="#noLint">noLint</a></code>.
- <pre><code>
- : (more (lintAll "file1.l" "file2.l"))
- ...
- </code></pre>
- <dt><a name="lisp"><code>(lisp 'sym ['fun]) -> num</code></a>
- <dd>(64-bit version only) Installs under the tag <code>sym</code> a callback
- function <code>fun</code>, and returns a pointer <code>num</code> suitable to be
- passed to a C function via 'native'. If <code>fun</code> is <code>NIL</code>,
- the corresponding entry is freed. Maximally 24 callback functions can be
- installed that way. 'fun' should be a function of maximally five numbers, and
- should return a number. "Numbers" in this context are 64-bit scalars, and may
- not only represent integers, but also pointers or other encoded data. See also
- <code><a href="#native">native</a></code> and <code><a
- href="#struct">struct</a></code>.
- <pre><code>
- (load "lib/native.l")
- (gcc "ltest" NIL
- (cbTest (Fun) cbTest 'N Fun) )
- long cbTest(int(*fun)(int,int,int,int,int)) {
- return fun(1,2,3,4,5);
- }
- /**/
- : (cbTest
- (lisp 'cbTest
- '((A B C D E)
- (msg (list A B C D E))
- (* A B C D E) ) ) )
- (1 2 3 4 5)
- -> 120
- </code></pre>
- <dt><a name="list"><code>(list 'any ['any ..]) -> lst</code></a>
- <dd>Returns a list of all <code>any</code> arguments. See also <code><a
- href="#cons">cons</a></code>.
- <pre><code>
- : (list 1 2 3 4)
- -> (1 2 3 4)
- : (list 'a (2 3) "OK")
- -> (a (2 3) "OK")
- </code></pre>
- <dt><a name="lst/3"><code>lst/3</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that returns subsequent list
- elements, after applying the <code><a href="#get">get</a></code>
- algorithm to that object and the following arguments. Often used in database
- queries. See also <code><a href="#map/3">map/3</a></code>.
- <pre><code>
- : (? (db nr +Ord 1 @Ord) (lst @Pos @Ord pos))
- @Ord={3-7} @Pos={4-1}
- @Ord={3-7} @Pos={4-2}
- @Ord={3-7} @Pos={4-3}
- -> NIL
- </code></pre>
- <dt><a name="lst?"><code>(lst? 'any) -> flg</code></a>
- <dd>Returns <code>T</code> when the argument <code>any</code> is a (possibly
- empty) list (<code>NIL</code> or a cons pair). See also <code><a
- href="#pair">pair</a></code>.
- <pre><code>
- : (lst? NIL)
- -> T
- : (lst? (1 . 2))
- -> T
- : (lst? (1 2 3))
- -> T
- </code></pre>
- <dt><a name="listen"><code>(listen 'cnt1 ['cnt2]) -> cnt | NIL</code></a>
- <dd>Listens at a socket descriptor <code>cnt1</code> (as received by <code><a
- href="#port">port</a></code>) for an incoming connection, and returns
- the new socket descriptor <code>cnt</code>. While waiting for a connection, a
- <code>select</code> system call is executed for all file descriptors and timers
- in the <code>VAL</code> of the global variable <code><a
- href="#*Run">*Run</a></code>. If <code>cnt2</code> is
- non-<code>NIL</code>, that amount of milliseconds is waited maximally, and
- <code>NIL</code> is returned upon timeout. The global variable <code>*Adr</code>
- is set to the IP address of the client. See also <code><a
- href="#accept">accept</a></code>, <code><a
- href="#connect">connect</a></code>, <code><a
- href="#*Adr">*Adr</a></code>.
- <pre><code>
- : (setq *Socket
- (listen (port 6789) 60000) ) # Listen at port 6789 for max 60 seconds
- -> 4
- : *Adr
- -> "127.0.0.1"
- </code></pre>
- <dt><a name="lit"><code>(lit 'any) -> any</code></a>
- <dd>Returns the literal (i.e. quoted) value of <code>any</code>, by
- <code>cons</code>ing it with the <code><a
- href="#quote">quote</a></code> function if necessary.
- <pre><code>
- : (lit T)
- -> T
- : (lit 1)
- -> 1
- : (lit '(1))
- -> (1)
- : (lit '(a))
- -> '(a)
- </code></pre>
- <dt><a name="load"><code>(load 'any ..) -> any</code></a>
- <dd>Loads all <code>any</code> arguments. Normally, the name of each argument is
- taken as a file to be executed in a read-eval loop. The argument semantics are
- identical to that of <code><a href="#in">in</a></code>, with the
- exception that if an argument is a symbol and its first character is a hyphen
- '-', then that argument is parsed as an executable list (without the surrounding
- parentheses). When <code>any</code> is <code>T</code>, all remaining command
- line arguments are <code>load</code>ed recursively. When <code>any</code> is
- <code>NIL</code>, standard input is read, a prompt is issued before each read
- operation, the results are printed to standard output (read-eval-print loop),
- and <code>load</code> terminates when an empty line is entered. In any case,
- <code>load</code> terminates upon end of file, or when <code>NIL</code> is read.
- The index for transient symbols is cleared before and after the load, so that
- all transient symbols in a file have a local scope. If the namespace was
- switched (with <code><a href="#symbols">symbols</a></code>) while
- executing a file, it is restored to the previous one. Returns the value of the
- last evaluated expression. See also <code><a
- href="#script">script</a></code>, <code><a
- href="#ipid">ipid</a></code>, <code><a
- href="#call">call</a></code>, <code><a
- href="#file">file</a></code>, <code><a
- href="#in">in</a></code>, <code><a href="refO.html#out">out</a></code>
- and <code><a href="#str">str</a></code>.
- <pre><code>
- : (load "lib.l" "-* 1 2 3")
- -> 6
- </code></pre>
- <dt><a name="loc"><code>(loc 'sym 'lst) -> sym</code></a>
- <dd>Locates in <code>lst</code> a <code><a
- href="#transient">transient</a></code> symbol with the same name as
- <code>sym</code>. Allows to get hold of otherwise inaccessible symbols. See also
- <code><a href="#====">====</a></code>.
- <pre><code>
- : (loc "X" curry)
- -> "X"
- : (== @ "X")
- -> NIL
- </code></pre>
- <dt><a name="local"><code>(local . lst) -> sym</code></a>
- <dd>Wrapper function for <code><a href="#zap">zap</a></code>. Typically
- used to create namespace-local symbols. <code>lst</code> should be a list of
- symbols. See also <code><a href="#pico">pico</a></code>, <code><a
- href="#symbols">symbols</a></code>, <code><a
- href="#import">import</a></code> and <code><a
- href="#intern">intern</a></code>.
- <pre><code>
- : (symbols 'myLib 'pico)
- -> pico
- myLib: (local bar foo)
- -> "foo"
- myLib: (de foo (A) # 'foo' is local to 'myLib'
- ...
- myLib: (de bar (B) # 'bar' is local to 'myLib'
- ...
- </code></pre>
- <dt><a name="locale"><code>(locale 'sym1 'sym2 ['sym ..])</code></a>
- <dd>Sets the current locale to that given by the country file <code>sym1</code>
- and the language file <code>sym2</code> (both located in the "loc/" directory),
- and optional application-specific directories <code>sym</code>. The locale
- influences the language, and numerical, date and other formats. See also
- <code><a href="#*Uni">*Uni</a></code>, <code><a
- href="#datStr">datStr</a></code>, <code><a
- href="#strDat">strDat</a></code>, <code><a
- href="#expDat">expDat</a></code>, <code><a
- href="#day">day</a></code>, <code><a
- href="#telStr">telStr</a></code>, <code><a
- href="#expTel">expTel</a></code> and and <code><a
- href="#money">money</a></code>.
- <pre><code>
- : (locale "DE" "de" "app/loc/")
- -> "Zip"
- : ,"Yes"
- -> "Ja"
- </code></pre>
- <dt><a name="lock"><code>(lock ['sym]) -> cnt | NIL</code></a>
- <dd>Write-locks an external symbol <code>sym</code> (file record locking), or
- the whole database root file if <code>sym</code> is <code>NIL</code>. Returns
- <code>NIL</code> if successful, or the ID of the process currently holding the
- lock. When <code>sym</code> is non-<code>NIL</code>, the lock is released at the
- next top level call to <code><a href="#commit">commit</a></code> or
- <code><a href="#rollback">rollback</a></code>, otherwise only when
- another database is opened with <code><a href="#pool">pool</a></code>,
- or when the process terminates. See also <code><a
- href="#*Solo">*Solo</a></code>.
- <pre><code>
- : (lock '{1}) # Lock single object
- -> NIL
- : (lock) # Lock whole database
- -> NIL
- </code></pre>
- <dt><a name="loop"><code>(loop ['any | (NIL 'any . prg) | (T 'any . prg) ..]) -> any</code></a>
- <dd>Endless loop with multiple conditional exits: The body is executed an
- unlimited number of times. If a clause has <code>NIL</code> or <code>T</code> as
- its CAR, the clause's second element is evaluated as a condition and - if the
- result is <code>NIL</code> or non-<code>NIL</code>, respectively - the
- <code>prg</code> is executed and the result returned. See also <code><a
- href="#do">do</a></code> and <code><a
- href="#for">for</a></code>.
- <pre><code>
- : (let N 3
- (loop
- (prinl N)
- (T (=0 (dec 'N)) 'done) ) )
- 3
- 2
- 1
- -> done
- </code></pre>
- <dt><a name="low?"><code>(low? 'any) -> sym | NIL</code></a> <dd>Returns
- <code>any</code> when the argument is a string (symbol) that starts with a
- lowercase character. See also <code><a href="#lowc">lowc</a></code> and
- <code><a href="#upp?">upp?</a></code>
- <pre><code>
- : (low? "a")
- -> "a"
- : (low? "A")
- -> NIL
- : (low? 123)
- -> NIL
- : (low? ".")
- -> NIL
- </code></pre>
- <dt><a name="lowc"><code>(lowc 'any) -> any</code></a>
- <dd>Lower case conversion: If <code>any</code> is not a symbol, it is returned
- as it is. Otherwise, a new transient symbol with all characters of
- <code>any</code>, converted to lower case, is returned. See also <code><a
- href="#uppc">uppc</a></code>, <code><a
- href="#fold">fold</a></code> and <code><a
- href="#low?">low?</a></code>.
- <pre><code>
- : (lowc 123)
- -> 123
- : (lowc "ABC")
- -> "abc"
- </code></pre>
- <dt><a name="lt0"><code>(lt0 'any) -> num | NIL</code></a>
- <dd>Returns <code>num</code> when the argument is a number and less than zero,
- otherwise <code>NIL</code>. See also <code><a
- href="#le0">le0</a></code>, <code><a
- href="#ge0">ge0</a></code>, <code><a
- href="#gt0">gt0</a></code>, <code><a href="ref_.html#=0">=0</a></code>
- and <code><a href="#n0">n0</a></code>.
- <pre><code>
- : (lt0 -2)
- -> -2
- : (lt0 3)
- -> NIL
- </code></pre>
- <dt><a name="lup"><code>(lup 'lst 'any) -> lst</code></a>
- <dt><code>(lup 'lst 'any 'any2) -> lst</code>
- <dd>Looks up <code>any</code> in the CAR-elements of cons pairs stored in the
- index tree <code>lst</code>, as built-up by <code><a
- href="#idx">idx</a></code>. In the first form, the first found cons
- pair is returned, in the second form a list of all pairs whose CAR is in the
- range <code>any</code> .. <code>any2</code>. See also <code><a
- href="#assoc">assoc</a></code>.
- <pre><code>
- : (idx 'A 'a T)
- -> NIL
- : (idx 'A (1 . b) T)
- -> NIL
- : (idx 'A 123 T)
- -> NIL
- : (idx 'A (1 . a) T)
- -> NIL
- : (idx 'A (1 . c) T)
- -> NIL
- : (idx 'A (2 . d) T)
- -> NIL
- : (idx 'A)
- -> (123 a (1 . a) (1 . b) (1 . c) (2 . d))
- : (lup A 1)
- -> (1 . b)
- : (lup A 2)
- -> (2 . d)
- : (lup A 1 1)
- -> ((1 . a) (1 . b) (1 . c))
- : (lup A 1 2)
- -> ((1 . a) (1 . b) (1 . c) (2 . d))
- </code></pre>
- </dl>
- <h1><a name="M">M</a></h1>
- <dl>
- <dt><a name="*Msg"><code>*Msg</code></a>
- <dd>A global variable holding the last recently issued error message. See also
- <code><a href="#errors">Error Handling</a></code>, <code><a
- href="#*Err">*Err</a></code> and <code><a
- href="#^">^</a></code>.
- <pre><code>
- : (+ 'A 2)
- !? (+ 'A 2)
- A -- Number expected
- ?
- :
- : *Msg
- -> "Number expected"
- </code></pre>
- <dt><a name="+Mis"><code>+Mis</code></a>
- <dd>Prefix class to explicitly specify validation functions for <code><a
- href="#+relation">+relation</a></code>s. Expects a function that takes
- a value and an entity object, and returns <code>NIL</code> if everything is
- correct, or an error string. See also <a href="#dbase">Database</a>.
- <pre><code>
- (class +Ord +Entity) # Order class
- (rel pos (+Mis +List +Joint) # List of positions in that order
- ((Val Obj)
- (when (memq NIL Val)
- "There are empty positions" ) )
- ord (+Pos) )
- </code></pre>
- <dt><a name="macro"><code>(macro prg) -> any</code></a>
- <dd>Substitues all <code><a href="#pat?">pat?</a></code> symbols in
- <code>prg</code> (using <code><a href="#fill">fill</a></code>), and
- executes the result with <code><a href="#run">run</a></code>. Used
- occasionally to call functions which otherwise do not evaluate their arguments.
- <pre><code>
- : (de timerMessage (@N . @Prg)
- (setq @N (- @N))
- (macro
- (task @N 0 . @Prg) ) )
- -> timerMessage
- : (timerMessage 6000 (println 'Timer 6000))
- -> (-6000 0 (println 'Timer 6000))
- : (timerMessage 12000 (println 'Timer 12000))
- -> (-12000 0 (println 'Timer 12000))
- : (more *Run)
- (-12000 2616 (println 'Timer 12000))
- (-6000 2100 (println 'Timer 6000))
- -> NIL
- : Timer 6000
- Timer 12000
- ...
- </code></pre>
- <dt><a name="made"><code>(made ['lst1 ['lst2]]) -> lst</code></a>
- <dd>Initializes a new list value for the current <code><a
- href="#make">make</a></code> environment. All list elements already
- produced with <code><a href="#chain">chain</a></code> and <code><a
- href="#link">link</a></code> are discarded, and <code>lst1</code> is
- used instead. Optionally, <code>lst2</code> can be specified as the new linkage
- cell, otherwise the last cell of <code>lst1</code> is used. When called without
- arguments, <code>made</code> does not modify the environment. In any case, the
- current list is returned.
- <pre><code>
- : (make
- (link 'a 'b 'c) # Link three items
- (println (made)) # Print current list (a b c)
- (made (1 2 3)) # Discard it, start new with (1 2 3)
- (link 4) ) # Link 4
- (a b c)
- -> (1 2 3 4)
- </code></pre>
- <dt><a name="mail"><code>(mail 'any 'cnt 'sym1 'sym2|lst1 'sym3 'lst2 . prg)'</code></a>
- <dd>Sends an eMail via SMTP to a mail server at host <code>any</code>, port
- <code>cnt</code>. <code>sym1</code> should be the "from" address,
- <code>sym2|lst1</code> the "to" address(es), and <code>sym3</code> the subject.
- <code>lst2</code> is a list of attachments, each one specified by three elements
- for path, name and mime type. <code>prg</code> generates the mail body with
- <code><a href="#prEval">prEval</a></code>. See also <code><a
- href="#connect">connect</a></code>.
- <pre><code>
- (mail "localhost" 25 # Local mail server
- "a@bc.de" # "From" address
- "abu@software-lab.de" # "To" address
- "Testmail" # Subject
- (quote
- "img/go.png" "go.png" "image/png" # First attachment
- "img/7fach.gif" "7fach.gif" "image/gif" ) # Second attachment
- "Hello," # First line
- NIL # (empty line)
- (prinl (pack "This is mail #" (+ 3 4))) ) # Third line
- </code></pre>
- <dt><a name="make"><code>(make .. [(made 'lst ..)] .. [(link 'any ..)] ..) -> any</code></a>
- <dd>Initializes and executes a list-building process with the <code><a
- href="#made">made</a></code>, <code><a
- href="#chain">chain</a></code>, <code><a
- href="#link">link</a></code> and <code><a
- href="#yoke">yoke</a></code> functions, and returns the result list.
- For efficiency, pointers to the head and the tail of the list are maintained
- internally.
- <pre><code>
- : (make (link 1) (link 2 3) (link 4))
- -> (1 2 3 4)
- : (make (made (1 2 3)) (link 4))
- -> (1 2 3 4)
- </code></pre>
- <dt><a name="map"><code>(map 'fun 'lst ..) -> lst</code></a>
- <dd>Applies <code>fun</code> to <code>lst</code> and all successive CDRs. When
- additional <code>lst</code> arguments are given, they are passed to
- <code>fun</code> in the same way. Returns the result of the last application.
- See also <code><a href="#mapc">mapc</a></code>, <code><a
- href="#maplist">maplist</a></code>, <code><a
- href="#mapcar">mapcar</a></code>, <code><a
- href="#mapcon">mapcon</a></code>, <code><a
- href="#mapcan">mapcan</a></code> and <code><a
- href="#filter">filter</a></code>.
- <pre><code>
- : (map println (1 2 3 4) '(A B C))
- (1 2 3 4) (A B C)
- (2 3 4) (B C)
- (3 4) (C)
- (4) NIL
- -> NIL
- </code></pre>
- <dt><a name="map/3"><code>map/3</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that returns a list and
- subsequent CDRs of that list, after applying the <code><a
- href="#get">get</a></code> algorithm to that object and the following
- arguments. Often used in database queries. See also <code><a
- href="#lst/3">lst/3</a></code>.
- <pre><code>
- : (? (db nr +Ord 1 @Ord) (map @L @Ord pos))
- @Ord={3-7} @L=({4-1} {4-2} {4-3})
- @Ord={3-7} @L=({4-2} {4-3})
- @Ord={3-7} @L=({4-3})
- -> NIL
- </code></pre>
- <dt><a name="mapc"><code>(mapc 'fun 'lst ..) -> any</code></a>
- <dd>Applies <code>fun</code> to each element of <code>lst</code>. When
- additional <code>lst</code> arguments are given, their elements are also passed
- to <code>fun</code>. Returns the result of the last application. See also
- <code><a href="#map">map</a></code>, <code><a
- href="#maplist">maplist</a></code>, <code><a
- href="#mapcar">mapcar</a></code>, <code><a
- href="#mapcon">mapcon</a></code>, <code><a
- href="#mapcan">mapcan</a></code> and <code><a
- href="#filter">filter</a></code>.
- <pre><code>
- : (mapc println (1 2 3 4) '(A B C))
- 1 A
- 2 B
- 3 C
- 4 NIL
- -> NIL
- </code></pre>
- <dt><a name="mapcan"><code>(mapcan 'fun 'lst ..) -> lst</code></a>
- <dd>Applies <code>fun</code> to each element of <code>lst</code>. When
- additional <code>lst</code> arguments are given, their elements are also passed
- to <code>fun</code>. Returns a (destructively) concatenated list of all results.
- See also <code><a href="#map">map</a></code>, <code><a
- href="#mapc">mapc</a></code>, <code><a
- href="#maplist">maplist</a></code>, <code><a
- href="#mapcar">mapcar</a></code>, <code><a
- href="#mapcon">mapcon</a></code>, <code><a
- href="#filter">filter</a></code>.
- <pre><code>
- : (mapcan reverse '((a b c) (d e f) (g h i)))
- -> (c b a f e d i h g)
- </code></pre>
- <dt><a name="mapcar"><code>(mapcar 'fun 'lst ..) -> lst</code></a>
- <dd>Applies <code>fun</code> to each element of <code>lst</code>. When
- additional <code>lst</code> arguments are given, their elements are also passed
- to <code>fun</code>. Returns a list of all results. See also <code><a
- href="#map">map</a></code>, <code><a
- href="#mapc">mapc</a></code>, <code><a
- href="#maplist">maplist</a></code>, <code><a
- href="#mapcon">mapcon</a></code>, <code><a
- href="#mapcan">mapcan</a></code> and <code><a
- href="#filter">filter</a></code>.
- <pre><code>
- : (mapcar + (1 2 3) (4 5 6))
- -> (5 7 9)
- : (mapcar '((X Y) (+ X (* Y Y))) (1 2 3 4) (5 6 7 8))
- -> (26 38 52 68)
- </code></pre>
- <dt><a name="mapcon"><code>(mapcon 'fun 'lst ..) -> lst</code></a>
- <dd>Applies <code>fun</code> to <code>lst</code> and all successive CDRs. When
- additional <code>lst</code> arguments are given, they are passed to
- <code>fun</code> in the same way. Returns a (destructively) concatenated list of
- all results. See also <code><a href="#map">map</a></code>, <code><a
- href="#mapc">mapc</a></code>, <code><a
- href="#maplist">maplist</a></code>, <code><a
- href="#mapcar">mapcar</a></code>, <code><a
- href="#mapcan">mapcan</a></code> and <code><a
- href="#filter">filter</a></code>.
- <pre><code>
- : (mapcon copy '(1 2 3 4 5))
- -> (1 2 3 4 5 2 3 4 5 3 4 5 4 5 5)
- </code></pre>
- <dt><a name="maplist"><code>(maplist 'fun 'lst ..) -> lst</code></a>
- <dd>Applies <code>fun</code> to <code>lst</code> and all successive CDRs. When
- additional <code>lst</code> arguments are given, they are passed to
- <code>fun</code> in the same way. Returns a list of all results. See also
- <code><a href="#map">map</a></code>, <code><a
- href="#mapc">mapc</a></code>, <code><a
- href="#mapcar">mapcar</a></code>, <code><a
- href="#mapcon">mapcon</a></code>, <code><a
- href="#mapcan">mapcan</a></code> and <code><a
- href="#filter">filter</a></code>.
- <pre><code>
- : (maplist cons (1 2 3) '(A B C))
- -> (((1 2 3) A B C) ((2 3) B C) ((3) C))
- </code></pre>
- <dt><a name="maps"><code>(maps 'fun 'sym ['lst ..]) -> any</code></a>
- <dd>Applies <code>fun</code> to all properties of <code>sym</code>. When
- additional <code>lst</code> arguments are given, their elements are also passed
- to <code>fun</code>. Returns the result of the last application. Note that
- 'maps' should only be used when the property list is not modified by
- <code>fun</code>. Otherwise it is better to use a loop over the result of
- <code><a href="#getl">getl</a></code>. See also <code><a
- href="#putl">putl</a></code>.
- <pre><code>
- : (put 'X 'a 1)
- -> 1
- : (put 'X 'b 2)
- -> 2
- : (put 'X 'flg T)
- -> T
- : (getl 'X)
- -> (flg (2 . b) (1 . a))
- : (maps println 'X '(A B))
- flg A
- (2 . b) B
- (1 . a) NIL
- -> NIL
- </code></pre>
- <dt><a name="mark"><code>(mark 'sym|0 ['NIL | 'T | '0]) -> flg</code></a>
- <dd>Tests, sets or resets a mark for <code>sym</code> in the database (for a
- second argument of <code>NIL</code>, <code>T</code> or <code>0</code>,
- respectively), and returns the old value. The marks are local to the current
- process (not stored in the database), and vanish when the process terminates. If
- the first argument is zero, all marks are cleared.
- <pre><code>
- : (pool "db")
- -> T
- : (mark '{1} T) # Mark
- -> NIL
- : (mark '{1}) # Test
- -> T # -> marked
- : (mark '{1} 0) # Unmark
- -> T
- : (mark '{1}) # Test
- -> NIL # -> unmarked
- </code></pre>
- <dt><a name="match"><code>(match 'lst1 'lst2) -> flg</code></a>
- <dd>Takes <code>lst1</code> as a pattern to be matched against
- <code>lst2</code>, and returns <code>T</code> when successful. Atoms must be
- equal, and sublists must match recursively. Symbols in the pattern list with
- names starting with an at-mark "<code>@</code>" (see <code><a
- href="#pat?">pat?</a></code>) are taken as wildcards. They can match
- zero, one or more elements, and are bound to the corresponding data. See also
- <code><a href="#chop">chop</a></code>, <code><a
- href="#split">split</a></code> and <code><a
- href="#fill">fill</a></code>.
- <pre><code>
- : (match '(@A is @B) '(This is a test))
- -> T
- : @A
- -> (This)
- : @B
- -> (a test)
- : (match '(@X (d @Y) @Z) '((a b c) (d (e f) g) h i))
- -> T
- : @X
- -> ((a b c))
- : @Y
- -> ((e f) g)
- : @Z
- -> (h i)
- </code></pre>
- <dt><a name="max"><code>(max 'any ..) -> any</code></a>
- <dd>Returns the largest of all <code>any</code> arguments. See also <a
- href="#min">min</a> and <a href="ref.html#cmp">Comparing</a>.
- <pre><code>
- : (max 2 'a 'z 9)
- -> z
- : (max (5) (2 3) 'X)
- -> (5)
- </code></pre>
- <dt><a name="maxKey"><code>(maxKey 'tree ['any1 ['any2]]) -> any</code></a>
- <dd>Returns the largest key in a database tree. If a minimal key
- <code>any1</code> and/or a maximal key <code>any2</code> is given, the largest
- key from that range is returned. See also <code><a
- href="#tree">tree</a></code>, <code><a
- href="#leaf">leaf</a></code>, <code><a
- href="#minKey">minKey</a></code> and <code><a
- href="#genKey">genKey</a></code>.
- <pre><code>
- : (maxKey (tree 'nr '+Item))
- -> 7
- : (maxKey (tree 'nr '+Item) 3 5)
- -> 5
- </code></pre>
- <dt><a name="maxi"><code>(maxi 'fun 'lst ..) -> any</code></a>
- <dd>Applies <code>fun</code> to each element of <code>lst</code>. When
- additional <code>lst</code> arguments are given, their elements are also passed
- to <code>fun</code>. Returns that element from <code>lst</code> for which
- <code>fun</code> returned a maximal value (and stores the maximal value in the
- global variable <code><a href="#@@">@@</a></code>). See also <code><a
- href="#mini">mini</a></code> and <code><a
- href="#sort">sort</a></code>.
- <pre><code>
- : (setq A 1 B 2 C 3)
- -> 3
- : (maxi val '(A B C))
- -> C
- : (maxi # Symbol with largest list value
- '((X)
- (and (pair (val X)) (size @)) )
- (all) )
- -> pico
- </code></pre>
- <dt><a name="member"><code>(member 'any 'lst) -> any</code></a>
- <dd>Returns the tail of <code>lst</code> that starts with <code>any</code> when
- <code>any</code> is a member of <code>lst</code>, otherwise <code>NIL</code>.
- See also <code><a href="#memq">memq</a></code>, <code><a
- href="#assoc">assoc</a></code> and <code><a
- href="#idx">idx</a></code>.
- <pre><code>
- : (member 3 (1 2 3 4 5 6))
- -> (3 4 5 6)
- : (member 9 (1 2 3 4 5 6))
- -> NIL
- : (member '(d e f) '((a b c) (d e f) (g h i)))
- -> ((d e f) (g h i))
- </code></pre>
- <dt><a name="member/2"><code>member/2</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that succeeds if the the first
- argument is a member of the list in the second argument. See also <code><a
- href="#equal/2">equal/2</a></code> and <code><a
- href="#member">member</a></code>.
- <pre><code>
- : (? (member @X (a b c)))
- @X=a
- @X=b
- @X=c
- -> NIL
- </code></pre>
- <dt><a name="memq"><code>(memq 'any 'lst) -> any</code></a>
- <dd>Returns the tail of <code>lst</code> that starts with <code>any</code> when
- <code>any</code> is a member of <code>lst</code>, otherwise <code>NIL</code>.
- <code><a href="#==">==</a></code> is used for comparison (pointer
- equality). See also <code><a href="#member">member</a></code>, <code><a
- href="#mmeq">mmeq</a></code>, <code><a
- href="#asoq">asoq</a></code>, <code><a
- href="#push1q">push1q</a></code>, <code><a
- href="#delq">delq</a></code> and <a href="ref.html#cmp">Comparing</a>.
- <pre><code>
- : (memq 'c '(a b c d e f))
- -> (c d e f)
- : (memq (2) '((1) (2) (3)))
- -> NIL
- </code></pre>
- <dt><a name="meta"><code>(meta 'obj|typ 'sym ['sym2|cnt ..]) -> any</code></a>
- <dd>Fetches a property value <code>any</code>, by searching the property lists
- of the classes and superclasses of <code>obj</code>, or the classes in
- <code>typ</code>, for the property key <code>sym</code>, and by applying the
- <code><a href="#get">get</a></code> algorithm to the following optional
- arguments. See also <code><a href="#var:">var:</a></code>.
- <pre><code>
- : (setq A '(B)) # Be 'A' an object of class 'B'
- -> (B)
- : (put 'B 'a 123)
- -> 123
- : (meta 'A 'a) # Fetch 'a' from 'B'
- -> 123
- </code></pre>
- <dt><a name="meth"><code>(meth 'obj ['any ..]) -> any</code></a>
- <dd>This function is usually not called directly, but is used by <code> <a
- href="#dm">dm</a></code> as a template to initialize the
- <code>VAL</code> of message symbols. It searches for itself in the methods of
- <code>obj</code> and its classes and superclasses, and executes that method. An
- error <code>"Bad message"</code> is issued if the search is unsuccessful. See
- also <a href="#oop">OO Concepts</a>, <code><a
- href="#method">method</a></code>, <code><a
- href="#send">send</a></code> and <code><a
- href="#try">try</a></code>.
- <pre><code>
- : meth
- -> 67283504 # Value of 'meth'
- : rel>
- -> 67283504 # Value of any message
- </code></pre>
- <dt><a name="method"><code>(method 'msg 'obj) -> fun</code></a>
- <dd>Returns the function body of the method that would be executed upon sending
- the message <code>msg</code> to the object <code>obj</code>. If the message
- cannot be located in <code>obj</code>, its classes and superclasses,
- <code>NIL</code> is returned. See also <a href="#oop">OO Concepts</a>,
- <code><a href="#send">send</a></code>, <code><a
- href="#try">try</a></code>, <code><a
- href="#meth">meth</a></code>, <code><a
- href="#super">super</a></code>, <code><a
- href="#extra">extra</a></code>, <code><a
- href="#class">class</a></code>.
- <pre><code>
- : (method 'mis> '+Number)
- -> ((Val Obj) (and Val (not (num? Val)) "Numeric input expected"))
- </code></pre>
- <dt><a name="methods"><code>(methods 'sym) -> lst</code></a>
- <dd>(Debug mode only) Returns a list of method specifications for the object or
- class <code>sym</code>, as they are inherited from <code>sym</code>'s classes
- and superclasses. See also <a href="#oop">OO Concepts</a>, <code><a
- href="#dep">dep</a></code>, <code><a
- href="#class">class</a></code> and <code><a
- href="#can">can</a></code>.
- <pre><code>
- : (more (methods '+Joint))
- (keep> . +Joint)
- (lose> . +Joint)
- (rel> . +Joint)
- (mis> . +Joint)
- (T . +Joint)
- (revise> . +relation)
- (print> . +relation)
- (zap> . +relation)
- (del> . +relation)
- (put> . +relation)
- (has> . +relation)
- (ele> . +relation)
- </code></pre>
- <dt><a name="min"><code>(min 'any ..) -> any</code></a>
- <dd>Returns the smallest of all <code>any</code> arguments. See also <a
- href="#max">max</a> and <a href="ref.html#cmp">Comparing</a>.
- <pre><code>
- : (min 2 'a 'z 9)
- -> 2
- : (min (5) (2 3) 'X)
- -> X
- </code></pre>
- <dt><a name="minKey"><code>(minKey 'tree ['any1 ['any2]]) -> any</code></a>
- <dd>Returns the smallest key in a database tree. If a minimal key
- <code>any1</code> and/or a maximal key <code>any2</code> is given, the smallest
- key from that range is returned. See also <code><a
- href="#tree">tree</a></code>, <code><a
- href="#leaf">leaf</a></code>, <code><a
- href="#maxKey">maxKey</a></code> and <code><a
- href="#genKey">genKey</a></code>.
- <pre><code>
- : (minKey (tree 'nr '+Item))
- -> 1
- : (minKey (tree 'nr '+Item) 3 5)
- -> 3
- </code></pre>
- <dt><a name="mini"><code>(mini 'fun 'lst ..) -> any</code></a>
- <dd>Applies <code>fun</code> to each element of <code>lst</code>. When
- additional <code>lst</code> arguments are given, their elements are also passed
- to <code>fun</code>. Returns that element from <code>lst</code> for which
- <code>fun</code> returned a minimal value (and stores the minimal value in the
- global variable <code><a href="#@@">@@</a></code>). See also <code><a
- href="#maxi">maxi</a></code> and <code><a
- href="#sort">sort</a></code>.
- <pre><code>
- : (setq A 1 B 2 C 3)
- -> 3
- : (mini val '(A B C))
- -> A
- </code></pre>
- <dt><a name="mix"><code>(mix 'lst cnt|'any ..) -> lst</code></a>
- <dd>Builds a list from the elements of the argument <code>lst</code>, as
- specified by the following <code>cnt|'any</code> arguments. If such an argument
- is a number, the <code>cnt</code>'th element from <code>lst</code> is taken,
- otherwise that argument is evaluated and the result is used.
- <pre><code>
- : (mix '(a b c d) 3 4 1 2)
- -> (c d a b)
- : (mix '(a b c d) 1 'A 4 'D)
- -> (a A d D)
- </code></pre>
- <dt><a name="mmeq"><code>(mmeq 'lst 'lst) -> any</code></a>
- <dd>Returns the tail of the second argument <code>lst</code> that starts with a
- member of the first argument <code>lst</code>, otherwise <code>NIL</code>.
- <code><a href="#==">==</a></code> is used for comparison (pointer
- equality). See also <code><a href="#member">member</a></code>, <code><a
- href="#memq">memq</a></code>, <code><a
- href="#asoq">asoq</a></code> and <code><a
- href="#delq">delq</a></code>.
- <pre><code>
- : (mmeq '(a b c) '(d e f))
- -> NIL
- : (mmeq '(a b c) '(d b x))
- -> (b x)
- </code></pre>
- <dt><a name="money"><code>(money 'num ['sym]) -> sym</code></a>
- <dd>Formats a number <code>num</code> into a digit string with two decimal
- places, according to the current <code><a
- href="#locale">locale</a></code>. If an additional currency name is
- given, it is appended (separated by a space). See also <code><a
- href="#telStr">telStr</a></code>, <code><a
- href="#datStr">datStr</a></code> and <code><a
- href="#format">format</a></code>.
- <pre><code>
- : (money 123456789)
- -> "1,234,567.89"
- : (money 12345 "EUR")
- -> "123.45 EUR"
- : (locale "DE" "de")
- -> NIL
- : (money 123456789 "EUR")
- -> "1.234.567,89 EUR"
- </code></pre>
- <dt><a name="more"><code>(more 'lst ['fun]) -> flg</code></a>
- <dt><code>(more 'cls) -> any</code>
- <dd>(Debug mode only) Displays the elements of <code>lst</code> (first form), or
- the type and methods of <code>cls</code> (second form). <code>fun</code>
- defaults to <code><a href="#print">print</a></code>. In the second
- form, the method definitions of <code>cls</code> are pretty-printed with
- <code><a href="#pp">pp</a></code>. After each step, <code>more</code>
- waits for console input, and terminates when a non-empty line is entered. In
- that case, <code>T</code> is returned, otherwise (when end of data is reached)
- <code>NIL</code>. See also <code><a href="#query">query</a></code> and
- <code><a href="#show">show</a></code>.
- <pre><code>
- : (more (all)) # Display all internal symbols
- inc>
- leaf
- nil
- inc!
- accept. # Stop
- -> T
- : (more (all) show) # 'show' all internal symbols
- inc> 67292896
- *Dbg ((859 . "lib/db.l"))
- leaf ((Tree) (let (Node (cdr (root Tree)) X) (while (val Node) (setq X (cadr @) Node (car @))) (cddr X)))
- *Dbg ((173 . "lib/btree.l"))
- nil 67284680
- T (((@X) (^ @ (not (-> @X)))))
- . # Stop
- -> T
- : (more '+Link) # Display a class
- (+relation)
- (dm mis> (Val Obj)
- (and
- Val
- (nor (isa (: type) Val) (canQuery Val))
- "Type error" ) )
- (dm T (Var Lst)
- (unless (=: type (car Lst)) (quit "No Link" Var))
- (super Var (cdr Lst)) )
- -> NIL
- </code></pre>
- <dt><a name="msg"><code>(msg 'any ['any ..]) -> any</code></a>
- <dd>Prints <code>any</code> with <code><a
- href="#print">print</a></code>, followed by all <code>any</code>
- arguments (printed with <code><a href="#prin">prin</a></code>) and a
- newline, to standard error. The first <code>any</code> argument is returned.
- <pre><code>
- : (msg (1 a 2 b 3 c) " is a mixed " "list")
- (1 a 2 b 3 c) is a mixed list
- -> (1 a 2 b 3 c)
- </code></pre>
- </dl>
- <h1><a name="N">N</a></h1>
- <dl>
- <dt><a name="+Need"><code>+Need</code></a>
- <dd>Prefix class for mandatory <code><a
- href="#+relation">+relation</a></code>s. Note that this does not
- enforce any requirements by itself, it only returns an error message if the
- <code>mis></code> message is explicitly called, e.g. by GUI functions. See
- also <a href="#dbase">Database</a>.
- <pre><code>
- (rel nr (+Need +Key +Number)) # Item number is mandatory
- </code></pre>
- <dt><a name="+Number"><code>+Number</code></a>
- <dd>Class for numeric relations, a subclass of <code><a
- href="#+relation">+relation</a></code>. Accepts an optional argument
- for the fixpoint scale (currently not used). See also <a
- href="#dbase">Database</a>.
- <pre><code>
- (rel pr (+Number) 2) # Price, with two decimal places
- </code></pre>
- <dt><a name="n=="><code>(n== 'any ..) -> flg</code></a>
- <dd>Returns <code>T</code> when not all <code>any</code> arguments are the same
- (pointer equality). <code>(n== 'any ..)</code> is equivalent to <code>(not (==
- 'any ..))</code>. See also <code><a href="#==">==</a></code> and <a
- href="#cmp">Comparing</a>.
- <pre><code>
- : (n== 'a 'a)
- -> NIL
- : (n== (1) (1))
- -> T
- </code></pre>
- <dt><a name="n0"><code>(n0 'any) -> flg</code></a>
- <dd>Returns <code>T</code> when <code>any</code> is not a number with value
- zero. See also <code><a href="#=0">=0</a></code>, <code><a
- href="#lt0">lt0</a></code>, <code><a
- href="#le0">le0</a></code>, <code><a
- href="#ge0">ge0</a></code> and <code><a
- href="#gt0">gt0</a></code>.
- <pre><code>
- : (n0 (- 6 3 2 1))
- -> NIL
- : (n0 'a)
- -> T
- </code></pre>
- <dt><a name="nT"><code>(nT 'any) -> flg</code></a>
- <dd>Returns <code>T</code> when <code>any</code> is not the symbol
- <code>T</code>. See also <a href="#=T">=T</a>.
- <pre><code>
- : (nT 0)
- -> T
- : (nT "T")
- -> T
- : (nT T)
- -> NIL
- </code></pre>
- <dt><a name="name"><code>(name 'sym ['sym2]) -> sym</code></a>
- <dd>Returns, if <code>sym2</code> is not given, a new transient symbol with the
- name of <code>sym</code>. Otherwise <code>sym</code> must be a transient symbol,
- and its name is changed to that of <code>sym2</code> (note that this may give
- inconsistencies if the symbol is still referred to from other namespaces). See
- also <code><a href="#str">str</a></code>, <code><a
- href="#sym">sym</a></code>, <code><a
- href="#symbols">symbols</a></code>, <code><a
- href="#zap">zap</a></code> and <code><a
- href="#intern">intern</a></code>.
- <pre><code>
- : (name 'abc)
- -> "abc"
- : (name "abc")
- -> "abc"
- : (name '{A17})
- -> "A17"
- : (name (new))
- -> NIL
- : (de foo (Lst) (car Lst)) # 'foo' calls 'car'
- -> foo
- : (intern (name (zap 'car) "xxx")) # Globally change the name of 'car'
- -> xxx
- : (xxx (1 2 3))
- -> 1
- : (pp 'foo)
- (de foo (Lst)
- (xxx Lst) ) # Name changed
- -> foo
- : (foo (1 2 3)) # 'foo' still works
- -> 1
- : (car (1 2 3)) # Reader returns a new 'car' symbol
- !? (car (1 2 3))
- car -- Undefined
- ?
- </code></pre>
- <dt><a name="nand"><code>(nand 'any ..) -> flg</code></a>
- <dd>Logical NAND. The expressions <code>any</code> are evaluated from left to
- right. If <code>NIL</code> is encountered, <code>T</code> is returned
- immediately. Else <code>NIL</code> is returned. <code>(nand ..)</code> is
- equivalent to <code>(not (and ..))</code>.
- <pre><code>
- : (nand (lt0 7) (read))
- -> T
- : (nand (lt0 -7) (read))
- abc
- -> NIL
- : (nand (lt0 -7) (read))
- NIL
- -> T
- </code></pre>
- <dt><a name="native"><code>(native 'cnt1|sym1 'cnt2|sym2 'any 'any ..) -> any</code></a>
- <dd>(64-bit version only) Calls a native C function. The first argument should
- specify a shared object library, either <code>"@"</code> (the current main
- program), <code>sym1</code> (a library path name), or <code>cnt1</code> (a
- library handle obtained by a previous call). The second argument should be a
- symbol name <code>sym2</code>, or a function pointer <code>cnt2</code> obtained
- by a previous call). Practically, the first two arguments will be always passed
- as transient symbols, which will get the library handle and function pointer
- assigned as values to be cached and used in subsequent calls. The third argument
- <code>any</code> is a result specification, while all following arguments are
- the arguments to the native function. The functionality is described in detail
- in <a href="native.html">Native C Calls</a>.
- <p><a name="natResult">The result specification</a> may either be one of the
- atoms
- <pre><code>
- NIL void
- B byte # Byte (unsigned 8 bit)
- C char # Character (UTF-8, 1-3 bytes)
- I int # Integer (signed 32 bit)
- N long # Long or pointer (signed 64 bit)
- S string # String (UTF-8)
- -1.0 float # Scaled fixpoint number
- +1.0 double # Scaled fixpoint number
- </code></pre>
- <p>or nested lists of these atoms with size specifications to denote arrays and
- structures, e.g.
- <pre><code>
- (N . 4) # long[4]; -> (1 2 3 4)
- (N (C . 4)) # {long; char[4];} -> (1234 ("a" "b" "c" NIL))
- (N (B . 7)) # {long; byte[7];} -> (1234 (1 2 3 4 5 6 7))
- </code></pre>
- <p>Arguments can be
- <ul>
- <li>integers (up to 64-bit) or pointers, passed as numbers
- <li>strings, passed as symbols
- <li>fixpoint numbers, passed as cons pairs consisting of a the value and the
- scale (if the scale is positive, the number is passed as a
- <code>double</code>, otherwise as a <code>float</code>)
- <li>structures, passed as lists with
- <ul>
- <li>a variable in the CAR (to receive the returned structure data, ignored
- when the CAR is <code>NIL</code>)
- <li>a cons pair for the size and result specification in the CADR (see
- above), and
- <li>an optional sequence of <a name="natItem">initialization items</a> in the
- CDDR, where each may be
- <ul>
- <li>a positive number, stored as an unsigned byte value
- <li>a negative number, whose absolute value is stored as an unsigned
- integer
- <li>a pair <code>(num . cnt)</code> where '<code>num</code>' is stored in
- a field of '<code>cnt</code>' bytes
- <li>a pair <code>(sym . cnt)</code> where '<code>sym</code>' is stored as
- a null-terminated string in a field of '<code>cnt</code>' bytes
- <li>a list <code>(1.0 num ...)</code> where the '<code>num</code>'
- elements (scaled fixpoint numbers) are stored as a sequence of double
- precision floating point numbers
- <li>a list <code>(-1.0 num ...)</code> where the '<code>num</code>'
- elements (scaled fixpoint numbers) are stored as a sequence of single
- precision floating point numbers
- </ul>
- If the last CDR of the initialization sequence is a number, it is used
- as a fill-byte value for the remaining space in the structure.
- </ul>
- </ul>
- <p><code>native</code> takes care of allocating memory for strings, arrays or
- structures, and frees that memory when done.
- <p>The number of fixpoint arguments is limited to six. For NaN or negative
- infinity <code>NIL</code>, and for positive infinity <code>T</code> is returned.
- <p>The C function may in turn call a function
- <pre><code>
- long lisp(char*, long, long, long, long, long);
- </code></pre>
- <p>which accepts a symbol name as the first argument, and up to 5 numbers.
- <code>lisp()</code> calls that symbol with the five numbers, and expects a
- numeric return value. "Numbers" in this context are 64-bit scalars, and may not
- only represent integers, but also pointers or other encoded data. See also
- <code><a href="#struct">struct</a></code>, <code><a
- href="#lisp">lisp</a></code> and <code><a
- href="#errno">errno</a></code>.
- <pre><code>
- : (native "@" "getenv" 'S "TERM") # Same as (sys "TERM")
- -> "xterm"
- : (native "@" "printf" 'I "abc%d%s^J" (+ 3 4) (pack "X" "Y" "Z"))
- abc7XYZ
- -> 8
- : (native "@" "printf" 'I "This is %.3f^J" (123456 . 1000))
- This is 123.456
- -> 16
- : (use Tim
- (native "@" "time" NIL '(Tim (8 B . 8))) # time_t 8 # Get time_t structure
- (native "@" "localtime" '(I . 9) (cons NIL (8) Tim)) ) # Read local time
- -> (32 18 13 31 11 109 4 364 0) # 13:18:32, Dec. 31st, 2009
- : (native "libcrypto.so" "SHA1" '(B . 20) "abcd" 4 0)
- -> (129 254 139 254 135 87 108 62 203 34 66 111 142 87 132 115 130 145 122 207)
- </code></pre>
- <dt><a name="need"><code>(need 'cnt ['lst ['any]]) -> lst</code></a>
- <dt><code>(need 'cnt ['num|sym]) -> lst</code>
- <dd>Produces a list of at least <code>cnt</code> elements. When called without
- optional arguments, a list of <code>cnt</code> <code>NIL</code>'s is returned.
- When <code>lst</code> is given, it is extended to the left (if <code>cnt</code>
- is positive) or (destructively) to the right (if <code>cnt</code> is negative)
- with <code>any</code> elements. In the second form, a list of <code>cnt</code>
- atomic values is returned. See also <code><a
- href="#range">range</a></code>.
- <pre><code>
- : (need 5)
- -> (NIL NIL NIL NIL NIL) # Allocate 5 cells
- : (need 5 '(a b c))
- -> (NIL NIL a b c)
- : (need -5 '(a b c))
- -> (a b c NIL NIL)
- : (need 5 '(a b c) " ") # String alignment
- -> (" " " " a b c)
- : (need 7 0)
- -> (0 0 0 0 0 0 0)
- </code></pre>
- <dt><a name="new"><code>(new ['flg|num] ['typ ['any ..]]) -> obj</code></a>
- <dd>Creates and returns a new object. If <code>flg</code> is given and
- non-<code>NIL</code>, the new object will be an external symbol (created in
- database file 1 if <code>T</code>, or in the corresponding database file if
- <code>num</code> is given). <code>typ</code> (typically a list of classes) is
- assigned to the <code>VAL</code>, and the initial <code>T</code> message is sent
- with the arguments <code>any</code> to the new object. If no <code>T</code>
- message is defined for the classes in <code>typ</code> or their superclasses,
- the <code>any</code> arguments should evaluate to alternating keys and values
- for the initialization of the new object. See also <code><a
- href="#box">box</a></code>, <code><a
- href="#object">object</a></code>, <code><a
- href="#class">class</a></code>, <code><a
- href="#type">type</a></code>, <code><a
- href="#isa">isa</a></code>, <code><a
- href="#send">send</a></code> and <a href="ref.html#dbase">Database</a>.
- <pre><code>
- : (new)
- -> $134426427
- : (new T '(+Address))
- -> {1A;3}
- </code></pre>
- <dt><a name="new!"><code>(new! 'typ ['any ..]) -> obj</code></a>
- <dd><a href="#trans">Transaction</a> wrapper function for <code><a
- href="#new">new</a></code>. <code>(new! '(+Cls) 'key 'val ...)</code>
- is equivalent to <code>(dbSync) (new (db: +Cls) '(+Cls) 'key 'val ...) (commit
- 'upd)</code>. See also <code><a href="#set!">set!</a></code>, <code><a
- href="#put!">put!</a></code> and <code><a
- href="#inc!">inc!</a></code>.
- <pre><code>
- : (new! '(+Item) # Create a new item
- 'nr 2 # Item number
- 'nm "Spare Part" # Description
- 'sup (db 'nr '+CuSu 2) # Supplier
- 'inv 100 # Inventory
- pr 12.50 ) # Price
- </code></pre>
- <dt><a name="next"><code>(next) -> any</code></a>
- <dd>Can only be used inside functions with a variable number of arguments (with
- <code>@</code>). Returns the next argument from the internal list. See also
- <code><a href="#args">args</a></code>, <code><a
- href="#arg">arg</a></code>, <code><a
- href="#rest">rest</a></code>, and <code><a
- href="#pass">pass</a></code>.
- <pre><code>
- : (de foo @ (println (next))) # Print next argument
- -> foo
- : (foo)
- NIL
- -> NIL
- : (foo 123)
- 123
- -> 123
- </code></pre>
- <dt><a name="nil"><code>(nil . prg) -> NIL</code></a>
- <dd>Executes <code>prg</code>, and returns <code>NIL</code>. See also <code><a
- href="#t">t</a></code>, <code><a href="refP.html#prog">prog</a></code>,
- <code><a href="#prog1">prog1</a></code> and <code><a
- href="#prog2">prog2</a></code>.
- <pre><code>
- : (nil (println 'OK))
- OK
- -> NIL
- </code></pre>
- <dt><a name="nil/1"><code>nil/1</code></a>
- <dd><a href="#pilog">Pilog</a> predicate expects an argument variable,
- and succeeds if that variable is bound to <code>NIL</code>. See also <code><a
- href="#not/1">not/1</a></code>.
- <pre><code>
- : (? @X NIL (nil @X))
- @X=NIL
- -> NIL
- </code></pre>
- <dt><a name="noLint"><code>(noLint 'sym)</code></a>
- <dt><code>(noLint 'sym|(sym . cls) 'sym2)</code>
- <dd>(Debug mode only) Excludes the check for a function definition of
- <code>sym</code> (in the first form), or for variable binding and usage of
- <code>sym2</code> in the function definition, file contents or method body of
- <code>sym</code> (second form), during calls to <code><a
- href="#lint">lint</a></code>. See also <code><a
- href="#lintAll">lintAll</a></code>.
- <pre><code>
- : (de foo ()
- (bar FreeVariable) )
- -> foo
- : (lint 'foo)
- -> ((def bar) (bnd FreeVariable))
- : (noLint 'bar)
- -> bar
- : (noLint 'foo 'FreeVariable)
- -> (foo . FreeVariable)
- : (lint 'foo)
- -> NIL
- </code></pre>
- <dt><a name="nond"><code>(nond ('any1 . prg1) ('any2 . prg2) ..) -> any</code></a>
- <dd>Negated ("non-cond") multi-way conditional: If any of the <code>anyN</code>
- conditions evaluates to <code>NIL</code>, <code>prgN</code> is executed and the
- result returned. Otherwise (all conditions evaluate to non-<code>NIL</code>),
- <code>NIL</code> is returned. See also <code><a
- href="#cond">cond</a></code>, <code><a
- href="#ifn">ifn</a></code> and <code><a
- href="#unless">unless</a></code>.
- <pre><code>
- : (nond
- ((= 3 3) (println 1))
- ((= 3 4) (println 2))
- (NIL (println 3)) )
- 2
- -> 2
- </code></pre>
- <dt><a name="nor"><code>(nor 'any ..) -> flg</code></a>
- <dd>Logical NOR. The expressions <code>any</code> are evaluated from left to
- right. If a non-<code>NIL</code> value is encountered, <code>NIL</code> is
- returned immediately. Else <code>T</code> is returned. <code>(nor ..)</code> is
- equivalent to <code>(not (or ..))</code>.
- <pre><code>
- : (nor (lt0 7) (= 3 4))
- -> T
- </code></pre>
- <dt><a name="not"><code>(not 'any) -> flg</code></a>
- <dd>Logical negation. Returns <code>T</code> if <code>any</code> evaluates to
- <code>NIL</code>.
- <pre><code>
- : (not (== 'a 'a))
- -> NIL
- : (not (get 'a 'a))
- -> T
- </code></pre>
- <dt><a name="not/1"><code>not/1</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that succeeds if and only if
- the goal cannot be proven. See also <code><a
- href="#nil/1">nil/1</a></code>, <code><a
- href="#true/0">true/0</a></code> and <code><a
- href="#fail/0">fail/0</a></code>.
- <pre><code>
- : (? (equal 3 4))
- -> NIL
- : (? (not (equal 3 4)))
- -> T
- </code></pre>
- <dt><a name="nth"><code>(nth 'lst 'cnt ..) -> lst</code></a>
- <dd>Returns the tail of <code>lst</code> starting from the <code>cnt</code>'th
- element of <code>lst</code>. Successive <code>cnt</code> arguments operate on
- the results in the same way. <code>(nth 'lst 2)</code> is equivalent to
- <code>(cdr 'lst)</code>. See also <code><a href="#get">get</a></code>.
- <pre><code>
- : (nth '(a b c d) 2)
- -> (b c d)
- : (nth '(a (b c) d) 2 2)
- -> (c)
- : (cdadr '(a (b c) d))
- -> (c)
- </code></pre>
- <dt><a name="num?"><code>(num? 'any) -> num | NIL</code></a>
- <dd>Returns <code>any</code> when the argument <code>any</code> is a number,
- otherwise <code>NIL</code>. See also <code><a
- href="#sym?">sym?</a></code>, <code><a
- href="#atom">atom</a></code> and <code><a
- href="#pair">pair</a></code>.
- <pre><code>
- : (num? 123)
- -> 123
- : (num? (1 2 3))
- -> NIL
- </code></pre>
- </dl>
- <h1><a name="O">O</a></h1>
- <dl>
- <dt><a name="*ObjIdx"><code>*ObjIdx</code></a>
- <dd>Holds an <code><a href="#idx">idx</a></code> tree of objects
- created by <code><a href="#obj">obj</a></code>.
- <pre><code>
- </code></pre>
- <dt><a name="*Once"><code>*Once</code></a>
- <dd>Holds an <code><a href="#idx">idx</a></code> tree of already
- <code><a href="#load">load</a></code>ed source locations (as returned
- by <code><a href="#file">file</a></code>) See also <code><a
- href="#once">once</a></code>.
- <pre><code>
- : *Once
- -> (("lib/" "misc.l" . 11) (("lib/" "http.l" . 9) (("lib/" "form.l" . 11))))
- </code></pre>
- <dt><a name="*OS"><code>*OS</code></a>
- <dd>A global constant holding the name of the operating system. Possible values
- include <code>"Linux"</code>, <code>"FreeBSD"</code>, <code>"Darwin"</code> or
- <code>"Cygwin"</code>. See also <code><a href="#*CPU">*CPU</a></code>
- and <code><a href="#version">version</a></code>.
- <pre><code>
- : *OS
- -> "Linux"
- </code></pre>
- <dt><a name="obj"><code>(obj (typ sym [hook] val ..) [var1 val1 ..]) -> obj</code></a>
- <dt><code>(obj typ any [var1 val1 ..]) -> obj</code>
- <dd>Finds or creates a database object, and initializes additional properties
- using the <code>varN</code> and <code>valN</code> arguments. In the first form,
- a <code><a href="#request">request</a></code> for <code>(typ sym [hook]
- val ..)</code> is called, while the second form uses <code><a
- href="#cache">cache</a></code> to maintain objects without unique
- <code><a href="#+Key">+Key</a></code>s by indexing <code><a
- href="#*ObjIdx">*ObjIdx</a></code> with the <code>any</code> argument.
- <pre><code>
- : (obj ((+Item) nr 2) nm "Spare Part" sup `(db 'nr '+CuSu 2) inv 100 pr 1250)
- -> {3-2}
- </code></pre>
- <dt><a name="object"><code>(object 'sym 'any ['sym2 'any2 ..]) -> obj</code></a>
- <dd>Defines <code>sym</code> to be an object with the value (or type)
- <code>any</code>. The property list is initialized with all optionally supplied
- key-value pairs. See also <a href="#oop">OO Concepts</a>, <code><a
- href="#new">new</a></code>, <code><a
- href="#type">type</a></code> and <code><a
- href="#isa">isa</a></code>.
- <pre><code>
- : (object 'Obj '(+A +B +C) 'a 1 'b 2 'c 3)
- -> Obj
- : (show 'Obj)
- Obj (+A +B +C)
- c 3
- b 2
- a 1
- -> Obj
- </code></pre>
- <dt><a name="oct"><code>(oct 'num ['num]) -> sym</code></a>
- <dt><code>(oct 'sym) -> num</code>
- <dd>Converts a number <code>num</code> to an octal string, or an octal string
- <code>sym</code> to a number. In the first case, if the second argument is
- given, the result is separated by spaces into groups of such many digits. See
- also <code><a href="#bin">bin</a></code>, <code><a
- href="#hex">hex</a></code>, <code><a
- href="#fmt64">fmt64</a></code>, <code><a
- href="#hax">hax</a></code> and <code><a
- href="#format">format</a></code>.
- <pre><code>
- : (oct 73)
- -> "111"
- : (oct "111")
- -> 73
- : (oct 1234567 3)
- -> "4 553 207"
- </code></pre>
- <dt><a name="off"><code>(off var ..) -> NIL</code></a>
- <dd>Stores <code>NIL</code> in all <code>var</code> arguments. See also <code><a
- href="#on">on</a></code>, <code><a
- href="#onOff">onOff</a></code>, <code><a
- href="#zero">zero</a></code> and <code><a
- href="#one">one</a></code>.
- <pre><code>
- : (off A B)
- -> NIL
- : A
- -> NIL
- : B
- -> NIL
- </code></pre>
- <dt><a name="offset"><code>(offset 'lst1 'lst2) -> cnt | NIL</code></a>
- <dd>Returns the <code>cnt</code> position of the tail list <code>lst1</code> in
- <code>lst2</code>, or <code>NIL</code> if it is not found. See also <code><a
- href="#index">index</a></code>, <code><a
- href="#sub?">sub?</a></code> and <code><a
- href="#tail">tail</a></code>.
- <pre><code>
- : (offset '(c d e f) '(a b c d e f))
- -> 3
- : (offset '(c d e) '(a b c d e f))
- -> NIL
- </code></pre>
- <dt><a name="on"><code>(on var ..) -> T</code></a>
- <dd>Stores <code>T</code> in all <code>var</code> arguments. See also <code><a
- href="#off">off</a></code>, <code><a
- href="#onOff">onOff</a></code>, <code><a
- href="#zero">zero</a></code> and <code><a
- href="#one">one</a></code>.
- <pre><code>
- : (on A B)
- -> T
- : A
- -> T
- : B
- -> T
- </code></pre>
- <dt><a name="once"><code>(once . prg) -> any</code></a>
- <dd>Executes <code>prg</code> once, when the current file is <code><a
- href="#load">load</a></code>ed the first time. Subsequent loads at a
- later time will not execute <code>prg</code>, and <code>once</code> returns
- <code>NIL</code>. See also <code><a href="#*Once">*Once</a></code>.
- <pre><code>
- (once
- (zero *Cnt1 *Cnt2) # Init counters
- (load "file1.l" "file2.l") ) # Load other files
- `(once T) # Ignore next time the rest of this file
- </code></pre>
- <dt><a name="one"><code>(one var ..) -> 1</code></a>
- <dd>Stores <code>1</code> in all <code>var</code> arguments. See also <code><a
- href="#zero">zero</a></code>, <code><a
- href="#on">on</a></code>, <code><a href="refO.html#off">off</a></code>
- and <code><a href="#onOff">onOff</a></code>.
- <pre><code>
- : (one A B)
- -> 1
- : A
- -> 1
- : B
- -> 1
- </code></pre>
- <dt><a name="onOff"><code>(onOff var ..) -> flg</code></a>
- <dd>Logically negates the values of all <code>var</code> arguments. Returns the
- new value of the last symbol. See also <code><a
- href="#on">on</a></code>, <code><a href="refO.html#off">off</a></code>,
- <code><a href="#zero">zero</a></code> and <code><a
- href="#one">one</a></code>.
- <pre><code>
- : (onOff A B)
- -> T
- : A
- -> T
- : B
- -> T
- : (onOff A B)
- -> NIL
- : A
- -> NIL
- : B
- -> NIL
- </code></pre>
- <dt><a name="open"><code>(open 'any ['flg]) -> cnt | NIL</code></a>
- <dd>Opens the file with the name <code>any</code> in read/write mode (or
- read-only if <code>flg</code> is non-<code>NIL</code>), and returns a file
- descriptor <code>cnt</code> (or <code>NIL</code> on error). A leading
- "<code>@</code>" character in <code>any</code> is substituted with the
- <u>PicoLisp Home Directory</u>, as it was remembered during interpreter startup.
- If <code>flg</code> is <code>NIL</code> and the file does not exist, it is
- created. The file descriptor can be used in subsequent calls to <code><a
- href="#in">in</a></code> and <code><a
- href="#out">out</a></code>. See also <code><a
- href="#close">close</a></code> and <code><a
- href="#poll">poll</a></code>.
- <pre><code>
- : (open "x")
- -> 3
- </code></pre>
- <dt><a name="opid"><code>(opid) -> pid | NIL</code></a>
- <dd>Returns the corresponding process ID when the current output channel is
- writing to a pipe, otherwise <code>NIL</code>. See also <code><a
- href="#ipid">ipid</a></code> and <code><a
- href="#out">out</a></code>.
- <pre><code>
- : (out '(cat) (call 'ps "-p" (opid)))
- PID TTY TIME CMD
- 7127 pts/3 00:00:00 cat
- -> T
- </code></pre>
- <dt><a name="opt"><code>(opt) -> sym</code></a>
- <dd>Return the next command line argument ("option", as would be processed by
- <code><a href="#load">load</a></code>) as a string, and remove it from
- the remaining command line arguments. See also <a
- href="#invoc">Invocation</a> and <code><a
- href="#argv">argv</a></code>.
- <pre><code>
- $ pil -"de f () (println 'opt (opt))" -f abc -bye
- opt "abc"
- </code></pre>
- <dt><a name="or"><code>(or 'any ..) -> any</code></a>
- <dd>Logical OR. The expressions <code>any</code> are evaluated from left to
- right. If a non-<code>NIL</code> value is encountered, it is returned
- immediately. Else the result of the last expression is returned.
- <pre><code>
- : (or (= 3 3) (read))
- -> T
- : (or (= 3 4) (read))
- abc
- -> abc
- </code></pre>
- <dt><a name="or/2"><code>or/2</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that takes an arbitrary number
- of clauses, and succeeds if one of them can be proven. See also <code><a
- href="#not/1">not/1</a></code>.
- <pre><code>
- : (?
- (or
- ((equal 3 @X) (equal @X 4))
- ((equal 7 @X) (equal @X 7)) ) )
- @X=7
- -> NIL</code></pre>
- <dt><a name="out"><code>(out 'any . prg) -> any</code></a>
- <dd>Opens <code>any</code> as output channel during the execution of
- <code>prg</code>. The current output channel will be saved and restored
- appropriately. If the argument is <code>NIL</code>, standard output is used. If
- the argument is a symbol, it is used as a file name (opened in "append" mode if
- the first character is "<code>+</code>"). If it is a positive number, it is used
- as the descriptor of an open file. If it is a negative number, the saved output
- channel such many levels above the current one is used. Otherwise (if it is a
- list), it is taken as a command with arguments, and a pipe is opened for output.
- See also <code><a href="#opid">opid</a></code>, <code> <a
- href="#call">call</a></code>, <code><a
- href="#in">in</a></code>, <code> <a
- href="#err">err</a></code>, <code> <a
- href="#ctl">ctl</a></code>, <code><a
- href="#pipe">pipe</a></code>, <code> <a
- href="#poll">poll</a></code>, <code> <a
- href="#close">close</a></code> and <code><a
- href="#load">load</a></code>.
- <pre><code>
- : (out "a" (println 123 '(a b c) 'def)) # Write one line to file "a"
- -> def
- </code></pre>
- </dl>
- <h1><a name="P">P</a></h1>
- <dl>
- <dt><a name="*PPid"><code>*PPid</code></a>
- <dd>A global constant holding the process-id of the parent picolisp process, or
- <code>NIL</code> if the current process is a top level process.
- <pre><code>
- : (println *PPid *Pid)
- NIL 5286
- : (unless (fork) (println *PPid *Pid) (bye))
- 5286 5522
- </code></pre>
- <dt><a name="*Pid"><code>*Pid</code></a>
- <dd>A global constant holding the current process-id.
- <pre><code>
- : *Pid
- -> 6386
- : (call "ps") # Show processes
- PID TTY TIME CMD
- .... ... ........ .....
- 6386 pts/1 00:00:00 pil # <- current process
- 6388 pts/1 00:00:00 ps
- -> T
- </code></pre>
- <dt><a name="*Prompt"><code>*Prompt</code></a>
- <dd>Global variable holding a (possibly empty) <code>prg</code> body, which is
- executed - and the result <code><a href="#prin">prin</a></code>ted -
- every time before a prompt is output to the console in the
- "read-eval-print-loop" (REPL).
- <pre><code>
- : (de *Prompt (pack "[" (stamp) "]"))
- # *Prompt redefined
- -> *Prompt
- [2011-10-11 16:50:05]: (+ 1 2 3)
- -> 6
- [2011-10-11 16:50:11]:
- </code></pre>
- <dt><a name="pack"><code>(pack 'any ..) -> sym</code></a>
- <dd>Returns a transient symbol whose name is concatenated from all arguments
- <code>any</code>. A <code>NIL</code> arguments contributes nothing to the result
- string, a number is converted to a digit string, a symbol supplies the
- characters of its name, and for a list its elements are taken. See also <code><a
- href="#text">text</a></code> and <code><a
- href="#glue">glue</a></code>.
- <pre><code>
- : (pack 'car " is " 1 '(" symbol " name))
- -> "car is 1 symbol name"
- </code></pre>
- <dt><a name="pad"><code>(pad 'cnt 'any) -> sym</code></a>
- <dd>Returns a transient symbol with <code>any</code> <code><a
- href="#pack">pack</a></code>ed with leading '0' characters, up to a
- field width of <code>cnt</code>. See also <code><a
- href="#format">format</a></code> and <code><a
- href="#align">align</a></code>.
- <pre><code>
- : (pad 5 1)
- -> "00001"
- : (pad 5 123456789)
- -> "123456789"
- </code></pre>
- <dt><a name="pair"><code>(pair 'any) -> any</code></a>
- <dd>Returns <code>any</code> when the argument is a cons pair. See also <code><a
- href="#atom">atom</a></code>, <code><a
- href="#num?">num?</a></code>, <code><a
- href="#sym?">sym?</a></code> and <code><a
- href="#lst?">lst?</a></code>.
- <pre><code>
- : (pair NIL)
- -> NIL
- : (pair (1 . 2))
- -> (1 . 2)
- : (pair (1 2 3))
- -> (1 2 3)
- </code></pre>
- <dt><a name="part/3"><code>part/3</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that succeeds if the first
- argument, after <code><a href="#fold">fold</a></code>ing it to a
- canonical form, is a <i>substring</i> of the folded string representation of the
- result of applying the <code><a href="#get">get</a></code> algorithm to
- the following arguments. Typically used as filter predicate in <code><a
- href="#select/3">select/3</a></code> database queries. See also
- <code><a href="#sub?">sub?</a></code>, <code><a
- href="#isa/2">isa/2</a></code>, <code><a
- href="#same/3">same/3</a></code>, <code><a
- href="#bool/3">bool/3</a></code>, <code><a
- href="#range/3">range/3</a></code>, <code><a
- href="#head/3">head/3</a></code>, <code><a
- href="#fold/3">fold/3</a></code> and <code><a
- href="#tolr/3">tolr/3</a></code>.
- <pre><code>
- : (?
- @Nr (1 . 5)
- @Nm "part"
- (select (@Item)
- ((nr +Item @Nr) (nm +Item @Nm))
- (range @Nr @Item nr)
- (part @Nm @Item nm) ) )
- @Nr=(1 . 5) @Nm="part" @Item={3-1}
- @Nr=(1 . 5) @Nm="part" @Item={3-2}
- -> NIL
- </code></pre>
- <dt><a name="pass"><code>(pass 'fun ['any ..]) -> any</code></a>
- <dd>Passes to <code>fun</code> all arguments <code>any</code>, and all remaining
- variable arguments (<code>@</code>) as they would be returned by <code><a
- href="#rest">rest</a></code>. <code>(pass 'fun 'any)</code> is
- equivalent to <code>(apply 'fun (rest) 'any)</code>. See also <code><a
- href="#apply">apply</a></code>.
- <pre><code>
- : (de bar (A B . @)
- (println 'bar A B (rest)) )
- -> bar
- : (de foo (A B . @)
- (println 'foo A B)
- (pass bar 1)
- (pass bar 2) )
- -> foo
- : (foo 'a 'b 'c 'd 'e 'f)
- foo a b
- bar 1 c (d e f)
- bar 2 c (d e f)
- -> (d e f)
- </code></pre>
- <dt><a name="pat?"><code>(pat? 'any) -> pat | NIL</code></a>
- <dd>Returns <code>any</code> when the argument <code>any</code> is a symbol
- whose name starts with an at-mark "<code>@</code>", otherwise <code>NIL</code>.
- <pre><code>
- : (pat? '@)
- -> @
- : (pat? "@Abc")
- -> "@Abc"
- : (pat? "ABC")
- -> NIL
- : (pat? 123)
- -> NIL
- </code></pre>
- <dt><a name="patch"><code>(patch 'lst 'any . prg) -> any</code></a>
- <dd>Destructively replaces all sub-expressions of <code>lst</code>, that
- <code><a href="#match">match</a></code> the pattern <code>any</code>,
- by the result of the execution of <code>prg</code>. See also <code><a
- href="#daemon">daemon</a></code> and <code><a
- href="#redef">redef</a></code>.
- <pre><code>
- : (pp 'hello)
- (de hello NIL
- (prinl "Hello world!") )
- -> hello
- : (patch hello 'prinl 'println)
- -> NIL
- : (pp 'hello)
- (de hello NIL
- (println "Hello world!") )
- -> hello
- : (patch hello '(prinl @S) (fill '(println "We said: " . @S)))
- -> NIL
- : (hello)
- We said: Hello world!
- -> "Hello world!"
- </code></pre>
- <dt><a name="path"><code>(path 'any) -> sym</code></a>
- <dd>Substitutes any leading "<code>@</code>" character in the <code>any</code>
- argument with the <u>PicoLisp Home Directory</u>, as it was remembered during
- interpreter startup. Optionally, the name may be preceded by a "<code>+</code>"
- character (as used by <code><a href="#in">in</a></code> and <code><a
- href="#out">out</a></code>). This mechanism is used internally by all
- I/O functions. See also <a href="#invoc">Invocation</a>, <code><a
- href="#basename">basename</a></code> and <code><a
- href="#dirname">dirname</a></code>.
- <pre><code>
- $ /usr/bin/picolisp /usr/lib/picolisp/lib.l
- : (path "a/b/c")
- -> "a/b/c"
- : (path "@a/b/c")
- -> "/usr/lib/picolisp/a/b/c"
- : (path "+@a/b/c")
- -> "+/usr/lib/picolisp/a/b/c"
- </code></pre>
- <dt><a name="peek"><code>(peek) -> sym</code></a>
- <dd>Single character look-ahead: Returns the same character as the next call to
- <code><a href="#char">char</a></code> would return. See also <code><a
- href="#skip">skip</a></code>.
- <pre><code>
- $ cat a
- # Comment
- abcd
- $ pil +
- : (in "a" (list (peek) (char)))
- -> ("#" "#")
- </code></pre>
- <dt><a name="permute/2"><code>permute/2</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that succeeds if the second
- argument is a permutation of the list in the second argument. See also <code><a
- href="#append/3">append/3</a></code>.
- <pre><code>
- : (? (permute (a b c) @X))
- @X=(a b c)
- @X=(a c b)
- @X=(b a c)
- @X=(b c a)
- @X=(c a b)
- @X=(c b a)
- -> NIL
- </code></pre>
- <dt><a name="pick"><code>(pick 'fun 'lst ..) -> any</code></a>
- <dd>Applies <code>fun</code> to successive elements of <code>lst</code> until
- non-<code>NIL</code> is returned. Returns that value, or <code>NIL</code> if
- <code>fun</code> did not return non-<code>NIL</code> for any element of
- <code>lst</code>. When additional <code>lst</code> arguments are given, their
- elements are also passed to <code>fun</code>. <code>(pick 'fun 'lst)</code> is
- equivalent to <code>(fun (find 'fun 'lst))</code>. See also <code><a
- href="#seek">seek</a></code>, <code><a
- href="#find">find</a></code> and <code><a
- href="#extract">extract</a></code>.
- <pre><code>
- : (setq A NIL B 1 C NIL D 2 E NIL F 3)
- -> 3
- : (find val '(A B C D E))
- -> B
- : (pick val '(A B C D E))
- -> 1
- </code></pre>
- <dt><a name="pico"><code>pico</code></a>
- <dd>(64-bit version only) A global constant holding the initial (default)
- namespace of internal symbols. Its value is a cons pair of two '<code><a
- href="#idx">idx</a></code>' trees, one for symbols with short names and
- one for symbols with long names (more than 7 bytes in the name). See also
- <code><a href="#symbols">symbols</a></code>, <code><a
- href="#import">import</a></code> and <code><a
- href="#intern">intern</a></code>.
- <pre><code>
- : (symbols)
- -> pico
- : (cdr pico)
- -> (rollback (*NoTrace (*CtryCode (+IdxFold) genStrKey) basename ...
- </code></pre>
- <dt><a name="pil"><code>(pil ['any ..]) -> sym</code></a>
- <dd>Returns the path name to the <code><a
- href="#pack">pack</a></code>ed <code>any</code> arguments in
- the directory ".pil/" in the user's home directory.
- See also <code><a href="#tmp">tmp</a></code>.
- <pre><code>
- : (pil "history") # Path to the line editor's history file
- -> "/home/app/.pil/history"
- </code></pre>
- <dt><a name="pilog"><code>(pilog 'lst . prg) -> any</code></a>
- <dd>Evaluates a <a href="#pilog">Pilog</a> query, and executes
- <code>prg</code> for each result set with all Pilog variables bound to their
- matching values. See also <code><a href="#solve">solve</a></code>,
- <code><a href="#?">?</a></code>, <code><a
- href="#goal">goal</a></code> and <code><a
- href="#prove">prove</a></code>.
- <pre><code>
- : (pilog '((append @X @Y (a b c))) (println @X '- @Y))
- NIL - (a b c)
- (a) - (b c)
- (a b) - (c)
- (a b c) - NIL
- -> NIL
- </code></pre>
- <dt><a name="pipe"><code>(pipe exe) -> cnt</code></a>
- <dt><code>(pipe exe . prg) -> any</code>
- <dd>Executes <code>exe</code> in a <code><a
- href="#fork">fork</a></code>'ed child process (which terminates
- thereafter). In the first form, <code>pipe</code> just returns a file descriptor
- to write to the standard input and read from the standard output of that
- process. In the second form, it opens the standard output of that process as
- input channel during the execution of <code>prg</code>. The current input
- channel will be saved and restored appropriately. See also <code><a
- href="#later">later</a></code>, <code><a
- href="#ipid">ipid</a></code>, <code><a
- href="#in">in</a></code> and <code><a
- href="#out">out</a></code>.
- <pre><code>
- : (pipe # equivalent to 'any'
- (prinl "(a b # Comment^Jc d)") # Child
- (read) ) # Parent
- -> (a b c d)
- : (pipe # pipe through an external program
- (out '(tr "[a-z]" "[A-Z]") # Child
- (prinl "abc def ghi") )
- (line T) ) # Parent
- -> "ABC DEF GHI"
- : (setq P
- (pipe
- (in NIL # Child: Read stdin
- (while (line T)
- (prinl (uppc @)) # and write to stdout
- (flush) ) ) ) )
- -> 3
- : (out P (prinl "abc def")) # Parent: Send line to child
- -> "abc def"
- : (in P (line)) # Parent: Read reply
- -> ("A" "B" "C" " " "D" "E" "F")
- </code></pre>
- <dt><a name="place"><code>(place 'cnt 'lst 'any) -> lst</code></a>
- <dd>Places <code>any</code> into <code>lst</code> at position <code>cnt</code>.
- This is a non-destructive operation. See also <code><a
- href="#insert">insert</a></code>, <code><a
- href="#remove">remove</a></code>, <code><a
- href="#append">append</a></code>, <code><a
- href="#delete">delete</a></code> and <code><a
- href="#replace">replace</a></code>.
- <pre><code>
- : (place 3 '(a b c d e) 777)
- -> (a b 777 d e)
- : (place 1 '(a b c d e) 777)
- -> (777 b c d e)
- : (place 9 '(a b c d e) 777)
- -> (a b c d e 777)
- </code></pre>
- <dt><a name="poll"><code>(poll 'cnt) -> cnt | NIL</code></a>
- <dd>Checks for the availability of data for reading on the file descriptor
- <code>cnt</code>. See also <code><a href="#open">open</a></code>,
- <code><a href="#in">in</a></code> and <code><a
- href="#close">close</a></code>.
- <pre><code>
- : (and (poll *Fd) (in @ (read))) # Prevent blocking
- </code></pre>
- <dt><a name="pool"><code>(pool ['sym1 ['lst] ['sym2] ['sym3]]) -> T</code></a>
- <dd>Opens the file <code>sym1</code> as a database file in read/write mode. If
- the file does not exist, it is created. A currently open database is closed.
- <code>lst</code> is a list of block size scale factors (i.e. numbers),
- defaulting to (2) (for a single file with a 256 byte block size). If
- <code>lst</code> is given, an individual database file is opened for each item.
- If <code>sym2</code> is non-<code>NIL</code>, it is opened in append-mode as an
- asynchronous replication journal. If <code>sym3</code> is non-<code>NIL</code>,
- it is opened for reading and appending, to be used as a synchronous transaction
- log during <code><a href="#commit">commit</a></code>s. See also
- <code><a href="#dbs">dbs</a></code>, <code><a
- href="#*Dbs">*Dbs</a></code> and <code><a
- href="#journal">journal</a></code>.
- <pre><code>
- : (pool "/dev/hda2")
- -> T
- : *Dbs
- -> (1 2 2 4)
- : (pool "dbFile" *Dbs)
- -> T
- :
- abu:~/pico ls -l dbFile*
- -rw-r--r-- 1 abu abu 256 2007-06-11 07:57 dbFile1
- -rw-r--r-- 1 abu abu 13 2007-06-11 07:57 dbFile2
- -rw-r--r-- 1 abu abu 13 2007-06-11 07:57 dbFile3
- -rw-r--r-- 1 abu abu 13 2007-06-11 07:57 dbFile4
- </code></pre>
- <dt><a name="pop"><code>(pop 'var) -> any</code></a>
- <dd>Pops the first element (CAR) from the stack in <code>var</code>. See also
- <code><a href="#push">push</a></code>, <code><a
- href="#queue">queue</a></code>, <code><a
- href="#cut">cut</a></code>, <code><a
- href="#del">del</a></code> and <code><a
- href="#fifo">fifo</a></code>.
- <pre><code>
- : (setq S '((a b c) (1 2 3)))
- -> ((a b c) (1 2 3))
- : (pop S)
- -> a
- : (pop (cdr S))
- -> 1
- : (pop 'S)
- -> (b c)
- : S
- -> ((2 3))
- </code></pre>
- <dt><a name="port"><code>(port ['T] 'cnt|(cnt . cnt) ['var]) -> cnt</code></a>
- <dd>Opens a TCP-Port <code>cnt</code> (or a UDP-Port if the first argument is
- <code>T</code>), and returns a socket descriptor suitable as an argument for
- <code><a href="#listen">listen</a></code> or <code><a
- href="#accept">accept</a></code> (or <code><a
- href="#udp">udp</a></code>, respectively). If <code>cnt</code> is zero,
- some free port number is allocated. If a pair of <code>cnt</code>s is given
- instead, it should be a range of numbers which are tried in turn. When
- <code>var</code> is given, it is bound to the port number.
- <pre><code>
- : (port 0 'A) # Allocate free port
- -> 4
- : A
- -> 1034 # Got 1034
- : (port (4000 . 4008) 'A) # Try one of these ports
- -> 5
- : A
- -> 4002
- </code></pre>
- <dt><a name="pp"><code>(pp 'sym) -> sym</code></a>
- <dt><code>(pp 'sym 'cls) -> sym</code>
- <dt><code>(pp '(sym . cls)) -> sym</code>
- <dd>Pretty-prints the function or method definition of <code>sym</code>. The
- output format would regenerate that same definition when read and executed. See
- also <code><a href="#pretty">pretty</a></code>, <code><a
- href="#debug">debug</a></code> and <code><a
- href="#vi">vi</a></code>.
- <pre><code>
- : (pp 'tab)
- (de tab (Lst . @)
- (for N Lst
- (let V (next)
- (and (gt0 N) (space (- N (length V))))
- (prin V)
- (and
- (lt0 N)
- (space (- 0 N (length V))) ) ) )
- (prinl) )
- -> tab
- : (pp 'has> '+Entity)
- (dm has> (Var Val)
- (or
- (nor Val (get This Var))
- (has> (meta This Var) Val (get This Var)) ) )
- -> has>
- : (more (can 'has>) pp)
- (dm (has> . +relation) (Val X)
- (and (= Val X) X) )
- (dm (has> . +Fold) (Val X)
- (extra
- Val
- (if (= Val (fold Val)) (fold X) X) ) )
- (dm (has> . +Entity) (Var Val)
- (or
- (nor Val (get This Var))
- (has> (meta This Var) Val (get This Var)) ) )
- (dm (has> . +List) (Val X)
- (and
- Val
- (or
- (extra Val X)
- (find '((X) (extra Val X)) X) ) ) )
- (dm (has> . +Bag) (Val X)
- (and
- Val
- (or (super Val X) (car (member Val X))) ) )
- </code></pre>
- <dt><a name="pr"><code>(pr 'any ..) -> any</code></a>
- <dd>Binary print: Prints all <code>any</code> arguments to the current output
- channel in encoded binary format. See also <code><a
- href="#rd">rd</a></code>, <code><a
- href="#bytes">bytes</a></code>, <code><a
- href="#tell">tell</a></code>, <code><a
- href="#hear">hear</a></code> and <code><a
- href="#wr">wr</a></code>.
- <pre><code>
- : (out "x" (pr 7 "abc" (1 2 3) 'a)) # Print to "x"
- -> a
- : (hd "x")
- 00000000 04 0E 0E 61 62 63 01 04 02 04 04 04 06 03 05 61 ...abc.........a
- -> NIL
- </code></pre>
- <dt><a name="prEval"><code>(prEval 'prg ['cnt]) -> any</code></a>
- <dd>Executes <code>prg</code>, similar to <code><a
- href="#run">run</a></code>, by evaluating all expressions in
- <code>prg</code> (within the binding environment given by <code>cnt-1</code>).
- As a side effect, all atomic expressions will be printed with <code><a
- href="#prinl">prinl</a></code>. See also <code><a
- href="#eval">eval</a></code>.
- <pre><code>
- : (let Prg 567
- (prEval
- '("abc" (prinl (+ 1 2 3)) Prg 987) ) )
- abc
- 6
- 567
- 987
- -> 987
- </code></pre>
- <dt><a name="pre?"><code>(pre? 'any1 'any2) -> any2 | NIL</code></a>
- <dd>Returns <code>any2</code> when the string representation of
- <code>any1</code> is a prefix of the string representation of <code>any2</code>.
- See also <code><a href="#sub?">sub?</a></code> and <code><a
- href="#head">head</a></code>.
- <pre><code>
- : (pre? "abc" "abcdefg")
- -> "abcdef"
- : (pre? "def" "abcdefg")
- -> NIL
- : (pre? (+ 3 4) "7fach")
- -> "7fach"
- : (pre? NIL "abcdefg")
- -> "abcdefg"
- : (pre? "abc" '(a b c d e f g))
- -> "abcdefg"
- : (pre? '(a b c) "abcdefg")
- -> "abcdefg"
- </code></pre>
- <dt><a name="pretty"><code>(pretty 'any 'cnt)</code></a>
- <dd>Pretty-prints <code>any</code>. If <code>any</code> is an atom, or a list
- with a <code><a href="#size">size</a></code> not greater than 12, it is
- <code><a href="#print">print</a></code>ed as is. Otherwise, only the
- opening parenthesis and the CAR of the list is printed, all other elementes are
- pretty-printed recursively indented by three spaces, followed by a space and the
- corresponding closing parenthesis. The initial indentation level
- <code>cnt</code> defaults to zero. See also <code><a
- href="#pp">pp</a></code>.
- <pre><code>
- : (pretty '(a (b c d) (e (f (g) (h) (i)) (j (k) (l) (m))) (n o p) q))
- (a
- (b c d)
- (e
- (f (g) (h) (i))
- (j (k) (l) (m)) )
- (n o p)
- q )-> ")"
- </code></pre>
- <dt><a name="prin"><code>(prin 'any ..) -> any</code></a>
- <dd>Prints the string representation of all <code>any</code> arguments to the
- current output channel. No space or newline is printed between individual items,
- or after the last item. For lists, all elements are <code>prin</code>'ted
- recursively. See also <code><a href="#prinl">prinl</a></code>.
- <pre><code>
- : (prin 'abc 123 '(a 1 b 2))
- abc123a1b2-> (a 1 b 2)
- </code></pre>
- <dt><a name="prinl"><code>(prinl 'any ..) -> any</code></a>
- <dd>Prints the string representation of all <code>any</code> arguments to the
- current output channel, followed by a newline. No space or newline is printed
- between individual items. For lists, all elements are <code>prin</code>'ted
- recursively. See also <code><a href="#prin">prin</a></code>.
- <pre><code>
- : (prinl 'abc 123 '(a 1 b 2))
- abc123a1b2
- -> (a 1 b 2)
- </code></pre>
- <dt><a name="print"><code>(print 'any ..) -> any</code></a>
- <dd>Prints all <code>any</code> arguments to the current output channel. If
- there is more than one argument, a space is printed between successive
- arguments. No space or newline is printed after the last item. See also <code><a
- href="#println">println</a></code>, <code><a
- href="#printsp">printsp</a></code>, <code><a
- href="#sym">sym</a></code> and <code><a
- href="#str">str</a></code>
- <pre><code>
- : (print 123)
- 123-> 123
- : (print 1 2 3)
- 1 2 3-> 3
- : (print '(a b c) 'def)
- (a b c) def-> def
- </code></pre>
- <dt><a name="println"><code>(println 'any ..) -> any</code></a>
- <dd>Prints all <code>any</code> arguments to the current output channel,
- followed by a newline. If there is more than one argument, a space is printed
- between successive arguments. See also <code><a
- href="#print">print</a></code>, <code><a
- href="#printsp">printsp</a></code>.
- <pre><code>
- : (println '(a b c) 'def)
- (a b c) def
- -> def
- </code></pre>
- <dt><a name="printsp"><code>(printsp 'any ..) -> any</code></a>
- <dd>Prints all <code>any</code> arguments to the current output channel,
- followed by a space. If there is more than one argument, a space is printed
- between successive arguments. See also <code><a
- href="#print">print</a></code>, <code><a
- href="#println">println</a></code>.
- <pre><code>
- : (printsp '(a b c) 'def)
- (a b c) def -> def
- </code></pre>
- <dt><a name="prior"><code>(prior 'lst1 'lst2) -> lst | NIL</code></a>
- <dd>Returns the cell in <code>lst2</code> which immediately precedes the cell
- <code>lst1</code>, or <code>NIL</code> if <code>lst1</code> is not found in
- <code>lst2</code> or is the very first cell. <code><a
- href="#==">==</a></code> is used for comparison (pointer equality). See
- also <code><a href="#offset">offset</a></code> and <code><a
- href="#memq">memq</a></code>.
- <pre><code>
- : (setq L (1 2 3 4 5 6))
- -> (1 2 3 4 5 6)
- : (setq X (cdddr L))
- -> (4 5 6)
- : (prior X L)
- -> (3 4 5 6)
- </code></pre>
- <dt><a name="proc"><code>(proc 'sym ..) -> T</code></a>
- <dd>(Debug mode on Linux only) Shows a list of processes with command names
- given by the <code>sym</code> arguments, using the system <code>ps</code>
- utility. See also <code><a href="#kids">kids</a></code>, <code><a
- href="#kill">kill</a></code> and <code><a
- href="#hd">hd</a></code>.
- <pre><code>
- : (proc 'pil)
- PID PPID STARTED SIZE %CPU WCHAN CMD
- 16993 3267 12:38:21 1516 0.5 - /usr/bin/picolisp /usr/lib/picolisp/lib.l /usr/bin/pil +
- 15731 1834 12:36:35 2544 0.1 - /usr/bin/picolisp /usr/lib/picolisp/lib.l /usr/bin/pil app/main.l -main -go +
- 15823 15731 12:36:44 2548 0.0 - /usr/bin/picolisp /usr/lib/picolisp/lib.l /usr/bin/pil app/main.l -main -go +
- -> T
- </code></pre>
- <dt><a name="prog"><code>(prog . prg) -> any</code></a>
- <dd>Executes <code>prg</code>, and returns the result of the last expression.
- See also <code><a href="#nil">nil</a></code>, <code><a
- href="#t">t</a></code>, <code><a
- href="#prog1">prog1</a></code> and <code><a
- href="#prog2">prog2</a></code>.
- <pre><code>
- : (prog (print 1) (print 2) (print 3))
- 123-> 3
- </code></pre>
- <dt><a name="prog1"><code>(prog1 'any1 . prg) -> any1</code></a>
- <dd>Executes all arguments, and returns the result of the first expression
- <code>any1</code>. See also <code><a href="#nil">nil</a></code>,
- <code><a href="#t">t</a></code>, <code><a
- href="#prog">prog</a></code> and <code><a
- href="#prog2">prog2</a></code>.
- <pre><code>
- : (prog1 (print 1) (print 2) (print 3))
- 123-> 1
- </code></pre>
- <dt><a name="prog2"><code>(prog2 'any1 'any2 . prg) -> any2</code></a>
- <dd>Executes all arguments, and returns the result of the second expression
- <code>any2</code>. See also <code><a href="#nil">nil</a></code>,
- <code><a href="#t">t</a></code>, <code><a
- href="#prog">prog</a></code> and <code><a
- href="#prog1">prog1</a></code>.
- <pre><code>
- : (prog2 (print 1) (print 2) (print 3))
- 123-> 2
- </code></pre>
- <dt><a name="prop"><code>(prop 'sym1|lst ['sym2|cnt ..] 'sym) -> var</code></a>
- <dd>Fetches a property for a property key <code>sym</code> from a symbol. That
- symbol is <code>sym1</code> (if no other arguments are given), or a symbol found
- by applying the <code><a href="#get">get</a></code> algorithm to
- <code>sym1|lst</code> and the following arguments. The property (the cons pair,
- not just its value) is returned, suitable for direct (destructive) manipulations
- with functions expecting a <code>var</code> argument. See also <code><a
- href="#::">::</a></code>.
- <pre><code>
- : (put 'X 'cnt 0)
- -> 0
- : (prop 'X 'cnt)
- -> (0 . cnt)
- : (inc (prop 'X 'cnt)) # Directly manipulate the property value
- -> 1
- : (get 'X 'cnt)
- -> 1
- </code></pre>
- <dt><a name="protect"><code>(protect . prg) -> any</code></a>
- <dd>Executes <code>prg</code>, and returns the result of the last expression. If
- a signal is received during that time, its handling will be delayed until the
- execution of <code>prg</code> is completed. See also <code><a
- href="#alarm">alarm</a></code>, <a href="refH.html#*Hup">*Hup</a>, <a
- href="#*Sig1">*Sig[12]</a> and <code><a
- href="#kill">kill</a></code>.
- <pre><code>
- : (protect (journal "db1.log" "db2.log"))
- -> T
- </code></pre>
- <dt><a name="prove"><code>(prove 'lst ['lst]) -> lst</code></a>
- <dd>The <a href="#pilog">Pilog</a> interpreter. Tries to prove the query
- list in the first argument, and returns an association list of symbol-value
- pairs, or <code>NIL</code> if not successful. The query list is modified as a
- side effect, allowing subsequent calls to <code>prove</code> for further
- results. The optional second argument may contain a list of symbols; in that
- case the successful matches of rules defined for these symbols will be traced.
- See also <code><a href="#goal">goal</a></code>, <code><a
- href="#->">-></a></code> and <code><a
- href="#unify">unify</a></code>.
- <pre><code>
- : (prove (goal '((equal 3 3))))
- -> T
- : (prove (goal '((equal 3 @X))))
- -> ((@X . 3))
- : (prove (goal '((equal 3 4))))
- -> NIL
- </code></pre>
- <dt><a name="prune"><code>(prune ['cnt])</code></a>
- <dd>Optimizes memory usage by pruning in-memory nodes of database trees.
- Typically called repeatedly during bulk data imports. If <code>cnt</code> is
- <code>NIL</code>, further pruning will be disabled. Otherwise, all nodes which
- have not been accessed (with <code><a href="#fetch">fetch</a></code> or
- <code><a href="#store">store</a></code>) for <code>cnt</code> calls to
- <code>prune</code> will be <code><a href="#wipe">wipe</a></code>d. See
- also <code><a href="#lieu">lieu</a></code>.
- <pre><code>
- (in File1
- (while (someData)
- (new T '(+Cls1) ..)
- (at (0 . 10000) (commit) (prune 100)) ) )
- (in File2
- (while (moreData)
- (new T '(+Cls2) ..)
- (at (0 . 10000) (commit) (prune 100)) ) )
- (commit)
- (prune)
- </code></pre>
- <dt><a name="push"><code>(push 'var 'any ..) -> any</code></a>
- <dd>Implements a stack using a list in <code>var</code>. The <code>any</code>
- arguments are cons'ed in front of the value list. See also <code><a
- href="#push1">push1</a></code>, <code><a
- href="#push1q">push1q</a></code>, <code><a
- href="#pop">pop</a></code>, <code><a
- href="#queue">queue</a></code> and <code><a
- href="#fifo">fifo</a></code>.
- <pre><code>
- : (push 'S 3) # Use the VAL of 'S' as a stack
- -> 3
- : S
- -> (3)
- : (push 'S 2)
- -> 2
- : (push 'S 1)
- -> 1
- : S
- -> (1 2 3)
- : (push S 999) # Now use the CAR of the list in 'S'
- -> 999
- : (push S 888 777)
- -> 777
- : S
- -> ((777 888 999 . 1) 2 3)
- </code></pre>
- <dt><a name="push1"><code>(push1 'var 'any ..) -> any</code></a>
- <dd>Maintains a unique list in <code>var</code>. Each <code>any</code> argument
- is cons'ed in front of the value list only if it is not already a <code><a
- href="#member">member</a></code> of that list. See also <code><a
- href="#push">push</a></code>, <code><a
- href="#push1q">push1q</a></code>, <code><a
- href="#pop">pop</a></code> and <code><a
- href="#queue">queue</a></code>.
- <pre><code>
- : (push1 'S 1 2 3)
- -> 3
- : S
- -> (3 2 1)
- : (push1 'S 2 4)
- -> 4
- : S
- -> (4 3 2 1)
- </code></pre>
- <dt><a name="push1q"><code>(push1q 'var 'any ..) -> any</code></a>
- <dd>Maintains a unique list in <code>var</code>. Each <code>any</code> argument
- is cons'ed in front of the value list only if it is not already <code><a
- href="#memq">memq</a></code> of that list (pointer equality). See also
- <code><a href="#push">push</a></code>, <code><a
- href="#push1">push1</a></code>, <code><a
- href="#pop">pop</a></code> and <code><a
- href="#queue">queue</a></code>.
- <pre><code>
- : (push1q 'S 'a (1) 'b (2) 'c)
- -> c
- : S
- -> (c (2) b (1) a)
- : (push1q 'S 'b (1) 'd) # (1) is not pointer equal to the previous one
- -> d
- : S
- -> (d (1) c (2) b (1) a) # (1) is twice in the list
- </code></pre>
- <dt><a name="put"><code>(put 'sym1|lst ['sym2|cnt ..] 'sym|0 'any) ->
- any</code></a> <dd>Stores a new value <code>any</code> for a property key
- <code>sym</code> (or in the symbol value for zero) in a symbol. That symbol is
- <code>sym1</code> (if no other arguments are given), or a symbol found by
- applying the <code><a href="#get">get</a></code> algorithm to
- <code>sym1|lst</code> and the following arguments. See also <code><a
- href="#=:">=:</a></code>.
- <pre><code>
- : (put 'X 'a 1)
- -> 1
- : (get 'X 'a)
- -> 1
- : (prop 'X 'a)
- -> (1 . a)
- : (setq L '(A B C))
- -> (A B C)
- : (setq B 'D)
- -> D
- : (put L 2 0 'p 5) # Store '5' under the 'p' property of the value of 'B'
- -> 5
- : (getl 'D)
- -> ((5 . p))
- </code></pre>
- <dt><a name="put!"><code>(put! 'obj 'sym 'any) -> any</code></a>
- <dd><a href="#trans">Transaction</a> wrapper function for <code><a
- href="#put">put</a></code>. Note that for setting property values of
- entities typically the <code><a
- href="#entityMesssages">put!></a></code> message is used. See also
- <code><a href="#new!">new!</a></code>, <code><a
- href="#set!">set!</a></code> and <code><a
- href="#inc!">inc!</a></code>.
- <pre><code>
- (put! Obj 'cnt 0) # Setting a property of a non-entity object
- </code></pre>
- <dt><a name="putl"><code>(putl 'sym1|lst1 ['sym2|cnt ..] 'lst) -> lst</code></a>
- <dd>Stores a complete new property list <code>lst</code> in a symbol. That
- symbol is <code>sym1</code> (if no other arguments are given), or a symbol found
- by applying the <code><a href="#get">get</a></code> algorithm to
- <code>sym1|lst1</code> and the following arguments. All previously defined
- properties for that symbol are lost. See also <code><a
- href="#getl">getl</a></code> and <code><a
- href="#maps">maps</a></code>.
- <pre><code>
- : (putl 'X '((123 . a) flg ("Hello" . b)))
- -> ((123 . a) flg ("Hello" . b))
- : (get 'X 'a)
- -> 123
- : (get 'X 'b)
- -> "Hello"
- : (get 'X 'flg)
- -> T
- </code></pre>
- <dt><a name="pwd"><code>(pwd) -> sym</code></a>
- <dd>Returns the path to the current working directory. See also <code><a
- href="#dir">dir</a></code> and <code><a
- href="#cd">cd</a></code>.
- <pre><code>
- : (pwd)
- -> "/home/app"
- </code></pre>
- </dl>
- <h1><a name="Q">Q</a></h1>
- <dl>
- <dt><a name="qsym"><code>(qsym . sym) -> lst</code></a>
- <dd>Returns a cons pair of the value and property list of <code>sym</code>. See
- also <code><a href="#quote">quote</a></code>, <code><a
- href="#val">val</a></code> and <code><a
- href="#getl">getl</a></code>.
- <pre><code>
- : (setq A 1234)
- -> 1234
- : (put 'A 'a 1)
- -> 1
- : (put 'A 'b 2)
- -> 2
- : (put 'A 'f T)
- -> T
- : (qsym . A)
- -> (1234 f (2 . b) (1 . a))
- </code></pre>
- <dt><a name="quote"><code>(quote . any) -> any</code></a>
- <dd>Returns <code>any</code> unevaluated. The reader recognizes the single quote
- char <code>'</code> as a macro for this function. See also <code><a
- href="#lit">lit</a></code>.
- <pre><code>
- : 'a
- -> a
- : '(foo a b c)
- -> (foo a b c)
- : (quote (quote (quote a)))
- -> ('('(a)))
- </code></pre>
- <dt><a name="query"><code>(query 'lst ['lst]) -> flg</code></a>
- <dd>Handles an interactive <a href="#pilog">Pilog</a> query. The two
- <code>lst</code> arguments are passed to <code><a
- href="#prove">prove</a></code>. <code>query</code> displays each
- result, waits for console input, and terminates when a non-empty line is
- entered. See also <code><a href="#?">?</a></code>, <code><a
- href="#pilog">pilog</a></code> and <code><a
- href="#solve">solve</a></code>.
- <pre><code>
- : (query (goal '((append @X @Y (a b c)))))
- @X=NIL @Y=(a b c)
- @X=(a) @Y=(b c). # Stop
- -> NIL
- </code></pre>
- <dt><a name="queue"><code>(queue 'var 'any) -> any</code></a>
- <dd>Implements a queue using a list in <code>var</code>. The <code>any</code>
- argument is (destructively) concatenated to the end of the value list. See also
- <code><a href="#push">push</a></code>, <code><a
- href="#pop">pop</a></code> and <code><a
- href="#fifo">fifo</a></code>.
- <pre><code>
- : (queue 'A 1)
- -> 1
- : (queue 'A 2)
- -> 2
- : (queue 'A 3)
- -> 3
- : A
- -> (1 2 3)
- : (pop 'A)
- -> 1
- : A
- -> (2 3)
- </code></pre>
- <dt><a name="quit"><code>(quit ['any ['any]])</code></a>
- <dd>Stops current execution. If no arguments are given, all pending <code><a
- href="#finally">finally</a></code> expressions are executed and control
- is returned to the top level read-eval-print loop. Otherwise, an error handler
- is entered. The first argument can be some error message, and the second might
- be the reason for the error. See also <code><a href="#errors">Error
- Handling</a></code>.
- <pre><code>
- : (de foo (X) (quit "Sorry, my error" X))
- -> foo
- : (foo 123) # 'X' is bound to '123'
- 123 -- Sorry, my error # Error entered
- ? X # Inspect 'X'
- -> 123
- ? # Empty line: Exit
- :
- </code></pre>
- </dl>
- <h1><a name="R">R</a></h1>
- <dl>
- <dt><a name="*Run"><code>*Run</code></a>
- <dd>This global variable can hold a list of <code>prg</code> expressions which
- are used during <code><a href="#key">key</a></code>, <code><a
- href="#sync">sync</a></code>, <code><a
- href="#wait">wait</a></code> and <code><a
- href="#listen">listen</a></code>. The first element of each expression
- must either be a positive number (thus denoting a file descriptor to wait for)
- or a negative number (denoting a timeout value in milliseconds (in that case
- another number must follow to hold the remaining time)). A <code>select</code>
- system call is performed with these values, and the corresponding
- <code>prg</code> body is executed when input data are available or when a
- timeout occurred. See also <code><a href="#task">task</a></code>.
- <pre><code>
- : (de *Run (-2000 0 (println '2sec))) # Install 2-sec-timer
- -> *Run
- : 2sec # Prints "2sec" every 2 seconds
- 2sec
- 2sec
- # (Ctrl-D) Exit
- $
- </code></pre>
- <dt><a name="+Ref"><code>+Ref</code></a>
- <dd>Prefix class for maintaining non-unique indexes to <code><a
- href="#+relation">+relation</a></code>s, a subclass of <code><a
- href="#+index">+index</a></code>. Accepts an optional argument for a
- <code><a href="#+Hook">+Hook</a></code> attribute. See also <a
- href="#dbase">Database</a>.
- <pre><code>
- (rel tel (+Fold +Ref +String)) # Phone number with folded, non-unique index
- </code></pre>
- <dt><a name="+Ref2"><code>+Ref2</code></a>
- <dd>Prefix class for maintaining a secondary ("backing") index to <code><a
- href="#+relation">+relation</a></code>s. Can only be used as a prefix
- class to <code><a href="#+Key">+Key</a></code> or <code><a
- href="#+Ref">+Ref</a></code>. It maintains an index in the current
- (sub)class, in addition to that in one of the superclasses, to allow
- (sub)class-specific queries. See also <a
- href="#dbase">Database</a>.
- <pre><code>
- (class +Ord +Entity) # Order class
- (rel nr (+Need +Key +Number)) # Order number
- ...
- (class +EuOrd +Ord) # EU-specific order subclass
- (rel nr (+Ref2 +Key +Number)) # Order number with backing index
- </code></pre>
- <dt><a name="+relation"><code>+relation</code></a>
- <dd>Abstract base class of all database relations. Relation objects are usually
- defined with <code><a href="#rel">rel</a></code>. The class hierarchy
- includes the classes <code><a href="#+Any">+Any</a></code>, <code><a
- href="#+Bag">+Bag</a></code>, <code><a
- href="#+Bool">+Bool</a></code>, <code><a
- href="#+Number">+Number</a></code>, <code><a
- href="#+Date">+Date</a></code>, <code><a
- href="#+Time">+Time</a></code>, <code><a
- href="#+Symbol">+Symbol</a></code>, <code><a
- href="#+String">+String</a></code>, <code><a
- href="#+Link">+Link</a></code>, <code><a
- href="#+Joint">+Joint</a></code> and <code><a
- href="#+Blob">+Blob</a></code>, and the prefix classes <code><a
- href="#+Hook">+Hook</a></code>, <code><a
- href="#+Hook2">+Hook2</a></code>, <code><a
- href="#+index">+index</a></code>, <code><a
- href="#+Key">+Key</a></code>, <code><a
- href="#+Ref">+Ref</a></code>, <code><a
- href="#+Ref2">+Ref2</a></code>, <code><a
- href="#+Idx">+Idx</a></code>, <code><a
- href="#+IdxFold">+IdxFold</a></code>, <code><a
- href="#+Sn">+Sn</a></code>, <code><a
- href="#+Fold">+Fold</a></code>, <code><a
- href="#+Aux">+Aux</a></code>, <code><a
- href="#+UB">+UB</a></code>, <code><a
- href="#+Dep">+Dep</a></code>, <code><a
- href="#+List">+List</a></code>, <code><a
- href="#+Need">+Need</a></code>, <code><a
- href="#+Mis">+Mis</a></code> and <code><a
- href="#+Alt">+Alt</a></code>. See also <a
- href="#dbase">Database</a> and <code><a
- href="#+Entity">+Entity</a></code>.
- <p><a name="relationMesssages">Messages</a> to relation objects include
- <pre><code>
- mis> (Val Obj) # Return error if mismatching type or value
- has> (Val X) # Check if the value is present
- put> (Obj Old New) # Put new value
- rel> (Obj Old New) # Maintain relational structures
- lose> (Obj Val) # Delete relational structures
- keep> (Obj Val) # Restore deleted relational structures
- zap> (Obj Val) # Clean up relational structures
- </code></pre>
- <dt><a name="rand"><code>(rand ['cnt1 'cnt2] | ['T]) -> cnt | flg</code></a>
- <dd>Returns a pseudo random number in the range cnt1 .. cnt2 (or -2147483648 ..
- +2147483647 if no arguments are given). If the argument is <code>T</code>, a
- boolean value <code>flg</code> is returned. See also <code><a
- href="#seed">seed</a></code>.
- <pre><code>
- : (rand 3 9)
- -> 3
- : (rand 3 9)
- -> 7
- </code></pre>
- <dt><a name="range"><code>(range 'num1 'num2 ['num3]) -> lst</code></a>
- <dd>Produces a list of numbers in the range <code>num1</code> through
- <code>num2</code>. When <code>num3</code> is non-<code>NIL</code>), it is used
- to increment <code>num1</code> (if it is smaller than <code>num2</code>) or to
- decrement <code>num1</code> (if it is greater than <code>num2</code>). See also
- <code><a href="#need">need</a></code>.
- <pre><code>
- : (range 1 6)
- -> (1 2 3 4 5 6)
- : (range 6 1)
- -> (6 5 4 3 2 1)
- : (range -3 3)
- -> (-3 -2 -1 0 1 2 3)
- : (range 3 -3 2)
- -> (3 1 -1 -3)
- </code></pre>
- <dt><a name="range/3"><code>range/3</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that succeeds if the first
- argument is in the range of the result of applying the <code><a
- href="#get">get</a></code> algorithm to the following arguments.
- Typically used as filter predicate in <code><a
- href="#select/3">select/3</a></code> database queries. See also
- <code><a href="#cmp">Comparing</a></code>, <code><a
- href="#isa/2">isa/2</a></code>, <code><a
- href="#same/3">same/3</a></code>, <code><a
- href="#bool/3">bool/3</a></code>, <code><a
- href="#head/3">head/3</a></code>, <code><a
- href="#fold/3">fold/3</a></code>, <code><a
- href="#part/3">part/3</a></code> and <code><a
- href="#tolr/3">tolr/3</a></code>.
- <pre><code>
- : (?
- @Nr (1 . 5) # Numbers between 1 and 5
- @Nm "part"
- (select (@Item)
- ((nr +Item @Nr) (nm +Item @Nm))
- (range @Nr @Item nr)
- (part @Nm @Item nm) ) )
- @Nr=(1 . 5) @Nm="part" @Item={3-1}
- @Nr=(1 . 5) @Nm="part" @Item={3-2}
- -> NIL
- </code></pre>
- <dt><a name="rank"><code>(rank 'any 'lst ['flg]) -> lst</code></a>
- <dd>Searches a ranking list. <code>lst</code> should be sorted. Returns the
- element from <code>lst</code> with a maximal CAR less or equal to
- <code>any</code> (if <code>flg</code> is <code>NIL</code>), or with a minimal
- CAR greater or equal to <code>any</code> (if <code>flg</code> is
- non-<code>NIL</code>), or <code>NIL</code> if no match is found. See also
- <code><a href="#assoc">assoc</a></code> and <a
- href="#cmp">Comparing</a>.
- <pre><code>
- : (rank 0 '((1 . a) (100 . b) (1000 . c)))
- -> NIL
- : (rank 50 '((1 . a) (100 . b) (1000 . c)))
- -> (1 . a)
- : (rank 100 '((1 . a) (100 . b) (1000 . c)))
- -> (100 . b)
- : (rank 300 '((1 . a) (100 . b) (1000 . c)))
- -> (100 . b)
- : (rank 9999 '((1 . a) (100 . b) (1000 . c)))
- -> (1000 . c)
- : (rank 50 '((1000 . a) (100 . b) (1 . c)) T)
- -> (100 . b)
- </code></pre>
- <dt><a name="rassoc"><code>(rassoc 'any 'lst) -> lst</code></a>
- <dd>Reverse <code><a href="#assoc">assoc</a></code>. Returns the first
- element from <code>lst</code> with its CDR equal to <code>any</code>, or
- <code>NIL</code> if no match is found. See also <code><a
- href="#assoc">assoc</a></code> and <code><a
- href="#asoq">asoq</a></code>.
- <pre><code>
- : (rassoc 7 '((999 1 2 3) ("b" . 7) ("ok" "Hello")))
- -> ("b" . 7)
- : (rassoc (1 2 3) '((999 1 2 3) ("b" . 7) ("ok" "Hello")))
- -> (999 1 2 3)
- : (rassoc 'u '((999 1 2 3) ("b" . 7) ("ok" "Hello")))
- -> NIL
- </code></pre>
- <dt><a name="raw"><code>(raw ['flg]) -> flg</code></a>
- <dd>Console mode control function. When called without arguments, it returns the
- current console mode (<code>NIL</code> for "cooked mode"). Otherwise, the
- console is set to the new state. See also <code><a
- href="#key">key</a></code>.
- <pre><code>
- $ pil
- : (raw)
- -> NIL
- $ pil +
- : (raw)
- -> T
- </code></pre>
- <dt><a name="rc"><code>(rc 'sym 'any1 ['any2]) -> any</code></a>
- <dd>Fetches a value from a resource file <code>sym</code>, or stores a value
- <code>any2</code> in that file, using a key <code>any1</code>. All values are
- stored in a list in the file, using <code><a
- href="#assoc">assoc</a></code>. During the whole operation, the file is
- exclusively locked with <code><a href="#ctl">ctl</a></code>.
- <pre><code>
- : (info "a.rc") # File exists?
- -> NIL # No
- : (rc "a.rc" 'a 1) # Store 1 for 'a'
- -> 1
- : (rc "a.rc" 'b (2 3 4)) # Store (2 3 4) for 'b'
- -> (2 3 4)
- : (rc "a.rc" 'c 'b) # Store 'b' for 'c'
- -> b
- : (info "a.rc") # Check file
- -> (28 733124 . 61673)
- : (in "a.rc" (echo)) # Display it
- ((c . b) (b 2 3 4) (a . 1))
- -> T
- : (rc "a.rc" 'c) # Fetch value for 'c'
- -> b
- : (rc "a.rc" @) # Fetch value for 'b'
- -> (2 3 4)
- </code></pre>
- <dt><a name="rd"><code>(rd ['sym]) -> any</code></a>
- <dt><code>(rd 'cnt) -> num | NIL</code>
- <dd>Binary read: Reads one item from the current input channel in encoded binary
- format. When called with a <code>cnt</code> argument (second form), that number
- of raw bytes (in big endian format if <code>cnt</code> is positive, otherwise
- little endian) is read as a single number. Upon end of file, if the
- <code>sym</code> argument is given, it is returned, otherwise <code>NIL</code>.
- See also <code><a href="#pr">pr</a></code>, <code><a
- href="#tell">tell</a></code>, <code><a
- href="#hear">hear</a></code> and <code><a
- href="#wr">wr</a></code>.
- <pre><code>
- : (out "x" (pr 'abc "EOF" 123 "def"))
- -> "def"
- : (in "x" (rd))
- -> abc
- : (in "x"
- (make
- (use X
- (until (== "EOF" (setq X (rd "EOF"))) # '==' detects end of file
- (link X) ) ) ) )
- -> (abc "EOF" 123 "def") # as opposed to reading a symbol "EOF"
- : (in "/dev/urandom" (rd 20))
- -> 396737673456823753584720194864200246115286686486
- </code></pre>
- <dt><a name="read"><code>(read ['sym1 ['sym2]]) -> any</code></a>
- <dd>Reads one item from the current input channel. <code>NIL</code> is returned
- upon end of file. When called without arguments, an arbitrary Lisp expression is
- read. Otherwise, a token (a number, an internal symbol, a transient symbol (for
- punctuation), or a list of symbols (for a string)) is read. In that case,
- <code>sym1</code> specifies which set of characters to accept for continuous
- symbol names (in addition to the standard alphanumerical characters), and
- <code>sym2</code> an optional comment character. See also <code><a
- href="#any">any</a></code>, <code><a
- href="#str">str</a></code>, <code><a
- href="#line">line</a></code>, <code><a
- href="#skip">skip</a></code> and <code><a
- href="#eof">eof</a></code>.
- <pre><code>
- : (list (read) (read) (read)) # Read three things from console
- 123 # a number
- abcd # a symbol
- (def # and a list
- ghi
- jkl
- )
- -> (123 abcd (def ghi jkl))
- : (make (while (read "_" "#") (link @)))
- abc = def_ghi("xyz"+-123) # Comment
- NIL
- -> (abc "=" def_ghi "(" ("x" "y" "z") "+" "-" 123 ")")
- </code></pre>
- <dt><a name="recur"><code>(recur fun) -> any</code></a>
- <dt><a name="recurse"><code>(recurse ..) -> any</code></a>
- <dd>Implements anonymous recursion, by defining the function
- <code>recurse</code> on the fly. During the execution of <code>fun</code>, the
- symbol <code>recurse</code> is bound to the function definition
- <code>fun</code>. See also <code><a href="#let">let</a></code> and
- <code><a href="#lambda">lambda</a></code>.
- <pre><code>
- : (de fibonacci (N)
- (when (lt0 N)
- (quit "Bad fibonacci" N) )
- (recur (N)
- (if (>= 2 N)
- 1
- (+
- (recurse (dec N))
- (recurse (- N 2)) ) ) ) )
- -> fibonacci
- : (fibonacci 22)
- -> 17711
- : (fibonacci -7)
- -7 -- Bad fibonacci
- </code></pre>
- <dt><a name="redef"><code>(redef sym . fun) -> sym</code></a>
- <dd>Redefines <code>sym</code> in terms of itself. The current definition is
- saved in a new symbol, which is substituted for each occurrence of
- <code>sym</code> in <code>fun</code>, and which is also returned. See also
- <code><a href="#de">de</a></code>, <code><a
- href="#undef">undef</a></code>, <code><a
- href="#daemon">daemon</a></code> and <code><a
- href="#patch">patch</a></code>.
- <pre><code>
- : (de hello () (prinl "Hello world!"))
- -> hello
- : (pp 'hello)
- (de hello NIL
- (prinl "Hello world!") )
- -> hello
- : (redef hello (A B)
- (println 'Before A)
- (prog1 (hello) (println 'After B)) )
- -> "hello"
- : (pp 'hello)
- (de hello (A B)
- (println 'Before A)
- (prog1 ("hello") (println 'After B)) )
- -> hello
- : (hello 1 2)
- Before 1
- Hello world!
- After 2
- -> "Hello world!"
- : (redef * @
- (msg (rest))
- (pass *) )
- -> "*"
- : (* 1 2 3)
- (1 2 3)
- -> 6
- : (redef + @
- (pass (ifn (num? (next)) pack +) (arg)) )
- -> "+"
- : (+ 1 2 3)
- -> 6
- : (+ "a" 'b '(c d e))
- -> "abcde"
- </code></pre>
- <dt><a name="rel"><code>(rel sym lst [any ..]) -> any</code></a>
- <dd>Defines a relation for <code>sym</code> in the current class <code><a
- href="#*Class">*Class</a></code>, using <code>lst</code> as the list of
- classes for that relation, and possibly additional arguments <code>any</code>
- for its initialization. See also <a href="#dbase">Database</a>, <code><a
- href="#class">class</a></code>, <code><a
- href="#extend">extend</a></code>, <code><a
- href="#dm">dm</a></code> and <code><a
- href="#var">var</a></code>.
- <pre><code>
- (class +Person +Entity)
- (rel nm (+List +Ref +String)) # Names
- (rel tel (+Ref +String)) # Telephone
- (rel adr (+Joint) prs (+Address)) # Address
- (class +Address +Entity)
- (rel cit (+Need +Hook +Link) (+City)) # City
- (rel str (+List +Ref +String) cit) # Street
- (rel prs (+List +Joint) adr (+Person)) # Inhabitants
- (class +City +Entity)
- (rel nm (+List +Ref +String)) # Zip / Names
- </code></pre>
- <dt><a name="release"><code>(release 'sym) -> NIL</code></a>
- <dd>Releases the mutex represented by the file 'sym'. This is the reverse
- operation of <code><a href="#acquire">acquire</a></code>.
- <pre><code>
- : (release "sema1")
- -> NIL
- </code></pre>
- <dt><a name="remote/2"><code>remote/2</code></a>
- <dd><a href="#pilog">Pilog</a> predicate for remote database queries. It
- takes a list and an arbitrary number of clauses. The list should contain a Pilog
- variable for the result in the CAR, and a list of resources in the CDR. The
- clauses will be evaluated on remote machines according to these resources. Each
- resource must be a cons pair of two functions, an "out" function in the CAR, and
- an "in" function in the CDR. See also <code><a
- href="#*Ext">*Ext</a></code>, <code><a
- href="#select/3">select/3</a></code> and <code><a
- href="#db/3">db/3</a></code>.
- <pre><code>
- (setq *Ext # Set up external offsets
- (mapcar
- '((@Host @Ext)
- (cons @Ext
- (curry (@Host @Ext (Sock)) (Obj)
- (when (or Sock (setq Sock (connect @Host 4040)))
- (ext @Ext
- (out Sock (pr (cons 'qsym Obj)))
- (prog1
- (in Sock (rd))
- (unless @
- (close Sock)
- (off Sock) ) ) ) ) ) ) )
- '("localhost")
- '(20) ) )
- (de rsrc () # Simple resource handler, ignoring errors or EOFs
- (extract
- '((@Ext Host)
- (let? @Sock (connect Host 4040)
- (cons
- (curry (@Ext @Sock) (X) # out
- (ext @Ext (out @Sock (pr X))) )
- (curry (@Ext @Sock) () # in
- (ext @Ext (in @Sock (rd))) ) ) ) )
- '(20)
- '("localhost") ) )
- : (?
- @Nr (1 . 3)
- @Sup 2
- @Rsrc (rsrc)
- (remote (@Item . @Rsrc)
- (db nr +Item @Nr @Item)
- (val @Sup @Item sup nr) )
- (show @Item) )
- {L-2} (+Item)
- pr 1250
- inv 100
- sup {K-2}
- nm Spare Part
- nr 2
- @Nr=(1 . 3) @Sup=2 @Rsrc=((((X) (ext 20 (out 16 (pr X)))) NIL (ext 20 (in 16 (rd))))) @Item={L-2}
- -> NIL
- </code></pre>
- <dt><a name="remove"><code>(remove 'cnt 'lst) -> lst</code></a>
- <dd>Removes the element at position <code>cnt</code> from <code>lst</code>. This
- is a non-destructive operation. See also <code><a
- href="#insert">insert</a></code>, <code><a
- href="#place">place</a></code>, <code><a
- href="#append">append</a></code>, <code><a
- href="#delete">delete</a></code> and <code><a
- href="#replace">replace</a></code>.
- <pre><code>
- : (remove 3 '(a b c d e))
- -> (a b d e)
- : (remove 1 '(a b c d e))
- -> (b c d e)
- : (remove 9 '(a b c d e))
- -> (a b c d e)
- </code></pre>
- <dt><a name="repeat"><code>(repeat) -> lst</code></a>
- <dd>Makes the current <a href="#pilog">Pilog</a> definition "tail
- recursive", by closing the previously defined rules in the definition's T
- property to a circular list. See also <code><a
- href="#repeat/0">repeat/0</a></code> and <code><a
- href="#be">be</a></code>.
- <pre><code>
- (be a (1)) # Define three facts
- (be a (2))
- (be a (3))
- (repeat) # Unlimited supply
- : (? (a @N))
- @N=1
- @N=2
- @N=3
- @N=1
- @N=2
- @N=3. # Stop
- -> NIL
- </code></pre>
- <dt><a name="repeat/0"><code>repeat/0</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that always succeeds, also on
- backtracking. See also <code><a href="#repeat">repeat</a></code> and
- <code><a href="#true/0">true/0</a></code>.
- <pre><code>
- : (be integer (@I) # Generate unlimited supply of integers
- (^ @C (box 0)) # Init to zero
- (repeat) # Repeat from here
- (^ @I (inc (-> @C))) )
- -> integer
- : (? (integer @X))
- @X=1
- @X=2
- @X=3
- @X=4. # Stop
- -> NIL
- </code></pre>
- <dt><a name="replace"><code>(replace 'lst 'any1 'any2 ..) -> lst</code></a>
- <dd>Replaces in <code>lst</code> all occurrences of <code>any1</code> with
- <code>any2</code>. For optional additional argument pairs, this process is
- repeated. This is a non-destructive operation. See also <code><a
- href="#append">append</a></code>, <code><a
- href="#delete">delete</a></code>, <code><a
- href="#insert">insert</a></code>, <code><a
- href="#remove">remove</a></code> and <code><a
- href="#place">place</a></code>.
- <pre><code>
- : (replace '(a b b a) 'a 'A)
- -> (A b b A)
- : (replace '(a b b a) 'b 'B)
- -> (a B B a)
- : (replace '(a b b a) 'a 'B 'b 'A)
- -> (B A A B)
- </code></pre>
- <dt><a name="request"><code>(request 'typ 'sym ['hook] 'val ..) -> obj</code></a>
- <dd>Returns a database object. If a matching object cannot be found (using
- <code><a href="#db">db</a></code>), a new object of the given type is
- created (using <code><a href="#new">new</a></code>). See also <code><a
- href="#obj">obj</a></code>.
- <pre><code>
- : (request '(+Item) 'nr 2)
- -> {3-2}
- </code></pre>
- <dt><a name="rest"><code>(rest) -> lst</code></a>
- <dd>Can only be used inside functions with a variable number of arguments (with
- <code>@</code>). Returns the list of all remaining arguments from the internal
- list. See also <code><a href="#args">args</a></code>, <code><a
- href="#next">next</a></code>, <code><a
- href="#arg">arg</a></code> and <code><a
- href="#pass">pass</a></code>.
- <pre><code>
- : (de foo @ (println (rest)))
- -> foo
- : (foo 1 2 3)
- (1 2 3)
- -> (1 2 3)
- </code></pre>
- <dt><a name="retract"><code>(retract) -> lst</code></a>
- <dd>Removes a <a href="#pilog">Pilog</a> fact or rule. See also <code><a
- href="#be">be</a></code>, <code><a
- href="#clause">clause</a></code>, <code><a
- href="#asserta">asserta</a></code> and <code><a
- href="#assertz">assertz</a></code>.
- <pre><code>
- : (be a (1))
- -> a
- : (be a (2))
- -> a
- : (be a (3))
- -> a
- : (retract '(a (2)))
- -> (((1)) ((3)))
- : (? (a @N))
- @N=1
- @N=3
- -> NIL
- </code></pre>
- <dt><a name="retract/1"><code>retract/1</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that removes a fact or rule.
- See also <code><a href="#retract">retract</a></code>, <code><a
- href="#asserta/1">asserta/1</a></code> and <code><a
- href="#assertz/1">assertz/1</a></code>.
- <pre><code>
- : (be a (1))
- -> a
- : (be a (2))
- -> a
- : (be a (3))
- -> a
- : (? (retract (a 2)))
- -> T
- : (rules 'a)
- 1 (be a (1))
- 2 (be a (3))
- -> a
- </code></pre>
- <dt><a name="reverse"><code>(reverse 'lst) -> lst</code></a>
- <dd>Returns a reversed copy of <code>lst</code>. See also <code><a
- href="#flip">flip</a></code>.
- <pre><code>
- : (reverse (1 2 3 4))
- -> (4 3 2 1)
- </code></pre>
- <dt><a name="rewind"><code>(rewind) -> flg</code></a>
- <dd>Sets the file position indicator for the current output stream to the
- beginning of the file, and truncates the file length to zero. Returns
- <code>T</code> when successful. See also <code><a
- href="#flush">flush</a></code>.
- <pre><code>
- : (out "a" (prinl "Hello world"))
- -> "Hello world"
- : (in "a" (echo))
- Hello world
- -> T
- : (info "a")
- -> (12 733216 . 53888)
- : (out "a" (rewind))
- -> T
- : (info "a")
- -> (0 733216 . 53922)
- </code></pre>
- <dt><a name="rollback"><code>(rollback) -> flg</code></a>
- <dd>Cancels a transaction, by discarding all modifications of external symbols.
- See also <code><a href="#commit">commit</a></code>.
- <pre><code>
- : (pool "db")
- -> T
- # .. Modify external objects ..
- : (rollback) # Rollback
- -> T
- </code></pre>
- <dt><a name="root"><code>(root 'tree) -> (num . sym)</code></a>
- <dd>Returns the root of a database index tree, with the number of entries in
- <code>num</code>, and the base node in <code>sym</code>. See also <code><a
- href="#tree">tree</a></code>.
- <pre><code>
- : (root (tree 'nr '+Item))
- -> (7 . {7-1})
- </code></pre>
- <dt><a name="rot"><code>(rot 'lst ['cnt]) -> lst</code></a>
- <dd>Rotate: The contents of the cells of <code>lst</code> are (destructively)
- shifted right, and the value from the last cell is stored in the first cell.
- Without the optional <code>cnt</code> argument, the whole list is rotated,
- otherwise only the first <code>cnt</code> elements. See also <code><a
- href="#flip">flip</a></code> .
- <pre><code>
- : (rot (1 2 3 4)) # Rotate all four elements
- -> (4 1 2 3)
- : (rot (1 2 3 4 5 6) 3) # Rotate only the first three elements
- -> (3 1 2 4 5 6)
- </code></pre>
- <dt><a name="round"><code>(round 'num1 'num2) -> sym</code></a>
- <dd>Formats a number <code>num1</code> with <code>num2</code> decimal places,
- according to the current scale <code><a href="#*Scl">*Scl</a></code>.
- <code>num2</code> defaults to 3. See also <a href="#num-io">Numbers</a>
- and <code><a href="#format">format</a></code>.
- <pre><code>
- : (scl 4) # Set scale to 4
- -> 4
- : (round 123456) # Format with three decimal places
- -> "12.346"
- : (round 123456 2) # Format with two decimal places
- -> "12.35"
- : (format 123456 *Scl) # Format with full precision
- -> "12.3456"
- </code></pre>
- <dt><a name="rules"><code>(rules 'sym ..) -> sym</code></a>
- <dd>Prints all rules defined for the <code>sym</code> arguments. See also <a
- href="#pilog">Pilog</a> and <code><a href="ref.html#be">be</a></code>.
- <pre><code>
- : (rules 'member 'append)
- 1 (be member (@X (@X . @)))
- 2 (be member (@X (@ . @Y)) (member @X @Y))
- 1 (be append (NIL @X @X))
- 2 (be append ((@A . @X) @Y (@A . @Z)) (append @X @Y @Z))
- -> append
- </code></pre>
- <dt><a name="run"><code>(run 'any ['cnt ['lst]]) -> any</code></a>
- <dd>If <code>any</code> is an atom, <code>run</code> behaves like <code><a
- href="#eval">eval</a></code>. Otherwise <code>any</code> is a list,
- which is evaluated in sequence. The last result is returned. If a binding
- environment offset <code>cnt</code> is given, that evaluation takes place in the
- corresponding environment, and an optional <code>lst</code> of excluded symbols
- can be supplied. See also <code><a href="#up">up</a></code>.
- <pre><code>
- : (run '((println (+ 1 2 3)) (println 'OK)))
- 6
- OK
- -> OK
- : (de f Prg
- (let A 12
- (println (cons 'Prg Prg) (cons 'A A))
- (run Prg 1) ) )
- -> f
- : (let (Prg 77 A 99)
- (f
- (println (cons 'Prg Prg) (cons 'A A)) ) )
- (Prg (println (cons 'Prg Prg) (cons 'A A))) (A . 12)
- (Prg . 77) (A . 99)
- -> (A . 99)
- </code></pre>
- </dl>
- <h1><a name="S">S</a></h1>
- <dl>
- <dt><a name="*Scl"><code>*Scl</code></a>
- <dd>A global variable holding the current fixpoint input scale. See also <a
- href="#num-io">Numbers</a> and <code><a
- href="#scl">scl</a></code>.
- <pre><code>
- : (str "123.45") # Default value of '*Scl' is 0
- -> (123)
- : (setq *Scl 3)
- -> 3
- : (str "123.45")
- -> (123450)
- : 123.4567
- -> 123457
- : 12.3456
- -> 12346
- </code></pre>
- <dt><a name="*Sig1"><code>*Sig1</code></a>
- <dt><a name="*Sig2"><code>*Sig2</code></a>
- <dd>Global variables holding (possibly empty) <code>prg</code> bodies, which
- will be executed when a SIGUSR1 signal (or a SIGUSR2 signal, respectively) is
- sent to the current process. See also <code><a
- href="#alarm">alarm</a></code>, <code><a
- href="#sigio">sigio</a></code> and <code><a
- href="#*Hup">*Hup</a></code>.
- <pre><code>
- : (de *Sig1 (msg 'SIGUSR1))
- -> *Sig1
- </code></pre>
- <dt><a name="*Solo"><code>*Solo</code></a>
- <dd>A global variable indicating exclusive database access. Its value is
- <code>0</code> initially, set to <code>T</code> (or <code>NIL</code>) during
- cooperative database locks when <code><a href="#lock">lock</a></code>
- is successfully called with a <code>NIL</code> (or non-<code>NIL</code>)
- argument. See also <code><a href="#*Zap">*Zap</a></code>.
- <pre><code>
- : *Solo
- -> 0
- : (lock *DB)
- -> NIL
- : *Solo
- -> NIL
- : (rollback)
- -> T
- : *Solo
- -> 0
- : (lock)
- -> NIL
- : *Solo
- -> T
- : (rollback)
- -> T
- : *Solo
- -> T
- </code></pre>
- <dt><a name="+Sn"><code>+Sn</code></a>
- <dd>Prefix class for maintaining indexes according to a modified soundex
- algorithm, for tolerant name searches, to <code><a
- href="#+String">+String</a></code> relations. Typically used in
- combination with the <code><a href="#+Idx">+Idx</a></code> prefix
- class. See also <a href="#dbase">Database</a>.
- <pre><code>
- (rel nm (+Sn +Idx +String)) # Name
- </code></pre>
- <dt><a name="+String"><code>+String</code></a>
- <dd>Class for string (transient symbol) relations, a subclass of <code><a
- href="#+Symbol">+Symbol</a></code>. Accepts an optional argument for
- the string length (currently not used). See also <a
- href="#dbase">Database</a>.
- <pre><code>
- (rel nm (+Sn +Idx +String)) # Name, indexed by soundex and substrings
- </code></pre>
- <dt><a name="+Swap"><code>+Swap</code></a>
- <dd>Prefix class for <code><a href="#+relation">+relation</a></code>s
- where the data are to be stored in the value of a separate external symbol
- instead of the relation's object. Typically used for data which are relatively
- large and/or rarely accessed. Doesn't work with bidirectional relations
- (<code><a href="#+Joint">+Joint</a></code> or <code><a
- href="#+index">+index</a></code>). See also <a
- href="#dbase">Database</a>.
- <pre><code>
- (rel pw (+Swap +String)) # Password
- (rel nr (+Swap +List +Number)) # List of bignums
- </code></pre>
- <dt><a name="+Symbol"><code>+Symbol</code></a>
- <dd>Class for symbolic relations, a subclass of <code><a
- href="#+relation">+relation</a></code>. Objects of that class typically
- maintain internal symbols, as opposed to the more often-used <code><a
- href="#+String">+String</a></code> for transient symbols. See also <a
- href="#dbase">Database</a>.
- <pre><code>
- (rel perm (+List +Symbol)) # Permission list
- </code></pre>
- <dt><a name="same/3"><code>same/3</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that succeeds if the first
- argument matches the result of applying the <code><a
- href="#get">get</a></code> algorithm to the following arguments.
- Typically used as filter predicate in <code><a
- href="#select/3">select/3</a></code> database queries. See also
- <code><a href="#isa/2">isa/2</a></code>, <code><a
- href="#bool/3">bool/3</a></code>, <code><a
- href="#range/3">range/3</a></code>, <code><a
- href="#head/3">head/3</a></code>, <code><a
- href="#fold/3">fold/3</a></code>, <code><a
- href="#part/3">part/3</a></code> and <code><a
- href="#tolr/3">tolr/3</a></code>.
- <pre><code>
- : (?
- @Nr 2
- @Nm "Spare"
- (select (@Item)
- ((nr +Item @Nr) (nm +Item @Nm))
- (same @Nr @Item nr)
- (head @Nm @Item nm) ) )
- @Nr=2 @Nm="Spare" @Item={3-2}
- </code></pre>
- <dt><a name="scan"><code>(scan 'tree ['fun] ['any1] ['any2] ['flg])</code></a>
- <dd>Scans through a database tree by applying <code>fun</code> to all key-value
- pairs. <code>fun</code> should be a function accepting two arguments for key and
- value. It defaults to <code><a href="#println">println</a></code>.
- <code>any1</code> and <code>any2</code> may specify a range of keys. If
- <code>any2</code> is greater than <code>any1</code>, the traversal will be in
- opposite direction. Note that the keys need not to be atomic, depending on the
- application's index structure. If <code>flg</code> is non-<code>NIL</code>,
- partial keys are skipped. See also <code><a
- href="#tree">tree</a></code>, <code><a
- href="#iter">iter</a></code>, <code><a
- href="#init">init</a></code> and <code><a
- href="#step">step</a></code>.
- <pre><code>
- : (scan (tree 'nm '+Item))
- ("ASLRSNSTRSTN" {3-3} . T) {3-3}
- ("Additive" {3-4}) {3-4}
- ("Appliance" {3-6}) {3-6}
- ("Auxiliary Construction" . {3-3}) {3-3}
- ("Construction" {3-3}) {3-3}
- ("ENNSNNTTTF" {3-4} . T) {3-4}
- ("Enhancement Additive" . {3-4}) {3-4}
- ("Fittings" {3-5}) {3-5}
- ("GTSTFLNS" {3-6} . T) {3-6}
- ("Gadget Appliance" . {3-6}) {3-6}
- ...
- : (scan (tree 'nm '+Item) println NIL T T) # 'flg' is non-NIL
- ("Auxiliary Construction" . {3-3}) {3-3}
- ("Enhancement Additive" . {3-4}) {3-4}
- ("Gadget Appliance" . {3-6}) {3-6}
- ("Main Part" . {3-1}) {3-1}
- ("Metal Fittings" . {3-5}) {3-5}
- ("Spare Part" . {3-2}) {3-2}
- ("Testartikel" . {3-8}) {3-8}
- -> {7-6}
- </code></pre>
- <dt><a name="scl"><code>(scl 'num [. prg]) -> num</code></a>
- <dd>If <code>prg</code> is given, it binds <code><a
- href="#*Scl">*Scl</a></code> dynamically to <code>num</code> during the
- execution of <code>prg</code>. Otherwise, it sets <code><a
- href="#*Scl">*Scl</a></code> globally to <code>num</code>. See also <a
- href="#num-io">Numbers</a>.
- <pre><code>
- : (scl 0)
- -> 0
- : (str "123.45")
- -> (123)
- : (scl 1)
- -> 1
- : (read)
- 123.45
- -> 1235
- : (scl 3)
- -> 3
- : (str "123.45")
- -> (123450)
- : (scl 1 (str "123.45"))
- -> (1235)
- : *Scl
- -> 3
- </code></pre>
- <dt><a name="script"><code>(script 'any ..) -> any</code></a>
- <dd>The first <code>any</code> argument is <code><a
- href="#load">load</a></code>ed, with the remaining arguments <code><a
- href="#pass">pass</a></code>ed as variable arguments. They can be
- accessed with <code><a href="#next">next</a></code>, <code><a
- href="#arg">arg</a></code>, <code><a
- href="#args">args</a></code> and <code><a
- href="#rest">rest</a></code>. With that, the syntax in the script is
- the same as that in the body of a function with variable arguments (see <a
- href="#lambda">lambda expression</a>s, "when the CAR is the symbol @").
- <pre><code>
- $ cat x
- (* (next) (next))
- $ pil +
- : (script "x" 3 4)
- -> 12
- </code></pre>
- <dt><a name="sect"><code>(sect 'lst 'lst) -> lst</code></a>
- <dd>Returns the intersection of the <code>lst</code> arguments. See also
- <code><a href="#diff">diff</a></code>.
- <pre><code>
- : (sect (1 2 3 4) (3 4 5 6))
- -> (3 4)
- : (sect (1 2 3) (4 5 6))
- -> NIL
- </code></pre>
- <dt><a name="seed"><code>(seed 'any) -> cnt</code></a>
- <dd>Initializes the random generator's seed, and returns a pseudo random number
- in the range -2147483648 .. +2147483647. See also <code><a
- href="#rand">rand</a></code> and <code><a
- href="#hash">hash</a></code>.
- <pre><code>
- : (seed "init string")
- -> 2015582081
- : (rand)
- -> -706917003
- : (rand)
- -> 1224196082
- : (seed (time))
- -> 128285383
- </code></pre>
- <dt><a name="seek"><code>(seek 'fun 'lst ..) -> lst</code></a>
- <dd>Applies <code>fun</code> to <code>lst</code> and all successive CDRs, until
- non-<code>NIL</code> is returned. Returns the tail of <code>lst</code> starting
- with that element (and stores the non-<code>NIL</code> value in the global
- variable <code><a href="#@@">@@</a></code>), or <code>NIL</code> if
- <code>fun</code> did not return non-<code>NIL</code> for any element of
- <code>lst</code>. When additional <code>lst</code> arguments are given, they are
- passed to <code>fun</code> in the same way. See also <code><a
- href="#find">find</a></code>, <code><a
- href="#pick">pick</a></code>.
- <pre><code>
- : (seek '((X) (> (car X) 9)) (1 5 8 12 19 22))
- -> (12 19 22)
- </code></pre>
- <dt><a name="select"><code>(select [var ..] cls [hook|T] [var val ..]) -> obj | NIL</code></a>
- <dd>(Debug mode only) Interactive database function, loosely modelled after the
- SQL '<code>SELECT</code>' command. A (limited) front-end to the Pilog <code><a
- href="#select/3">select/3</a></code> predicate. When called with only a
- <code>cls</code> argument, <code>select</code> steps through all objects of that
- class, and <code><a href="#show">show</a></code>s their complete
- contents (this is analog to 'SELECT * from CLS'). If <code>cls</code> is
- followed by attribute/value specifications, the search is limited to these
- values (this is analog to 'SELECT * from CLS where VAR = VAL'). If between the
- <code>select</code> function and <code>cls</code> one or several attribute names
- are supplied, only these attribute (instead of the full <code>show</code>) are
- printed. These attribute specifications may also be lists, then the <code><a
- href="#get">get</a></code> algorithm will be used to retrieve related
- data. See also <code><a href="#update">update</a></code>, <a
- href="#dbase">Database</a> and <a href="ref.html#pilog">Pilog</a>.
- <pre><code>
- : (select +Item) # Show all items
- {3-1} (+Item)
- nr 1
- pr 29900
- inv 100
- sup {2-1}
- nm "Main Part"
- {3-2} (+Item)
- nr 2
- pr 1250
- inv 100
- sup {2-2}
- nm "Spare Part"
- . # Stop
- -> {3-2}
- : (select +Item nr 3) # Show only item 3
- {3-3} (+Item)
- nr 3
- sup {2-1}
- pr 15700
- nm "Auxiliary Construction"
- inv 100
- . # Stop
- -> {3-3}
- # Show selected attributes for items 3 through 3
- : (select nr nm pr (sup nm) +Item nr (3 . 5))
- 3 "Auxiliary Construction" 157.00 "Active Parts Inc." {3-3}
- 4 "Enhancement Additive" 9.99 "Seven Oaks Ltd." {3-4}
- 5 "Metal Fittings" 79.80 "Active Parts Inc." {3-5}
- -> NIL
- </code></pre>
- <dt><a name="select/3"><code>select/3</code></a>
- <dd><a href="#pilog">Pilog</a> database predicate that allows combined
- searches over <code><a href="#+index">+index</a></code> and other
- relations. It takes a list of Pilog variables, a list of generator clauses, and
- an arbitrary number of filter clauses. The functionality is described in detail
- in <a href="select.html">The 'select' Predicate</a>. See also <code><a
- href="#db/3">db/3</a></code>, <code><a
- href="#isa/2">isa/2</a></code>, <code><a
- href="#same/3">same/3</a></code>, <code><a
- href="#bool/3">bool/3</a></code>, <code><a
- href="#range/3">range/3</a></code>, <code><a
- href="#head/3">head/3</a></code>, <code><a
- href="#fold/3">fold/3</a></code>, <code><a
- href="#part/3">part/3</a></code>, <code><a
- href="#tolr/3">tolr/3</a></code> and <code><a
- href="#remote/2">remote/2</a></code>.
- <pre><code>
- : (?
- @Nr (2 . 5) # Select all items with numbers between 2 and 5
- @Sup "Active" # and suppliers matching "Active"
- (select (@Item) # Bind results to '@Item'
- ((nr +Item @Nr) (nm +CuSu @Sup (sup +Item))) # Generator clauses
- (range @Nr @Item nr) # Filter clauses
- (part @Sup @Item sup nm) ) )
- @Nr=(2 . 5) @Sup="Active" @Item={3-3}
- @Nr=(2 . 5) @Sup="Active" @Item={3-5}
- -> NIL
- </code></pre>
- <dt><a name="send"><code>(send 'msg 'obj ['any ..]) -> any</code></a>
- <dd>Sends the message <code>msg</code> to the object <code>obj</code>,
- optionally with arguments <code>any</code>. If the message cannot be located in
- <code>obj</code>, its classes and superclasses, an error <code>"Bad
- message"</code> is issued. See also <a href="#oop">OO Concepts</a>,
- <code><a href="#try">try</a></code>, <code><a
- href="#method">method</a></code>, <code><a
- href="#meth">meth</a></code>, <code><a
- href="#super">super</a></code> and <code><a
- href="#extra">extra</a></code>.
- <pre><code>
- : (send 'stop> Dlg) # Equivalent to (stop> Dlg)
- -> NIL
- </code></pre>
- <dt><a name="seq"><code>(seq 'cnt|sym1) -> sym | NIL</code></a>
- <dd>Sequential single step: Returns the <i>first</i> external symbol in the
- <code>cnt</code>'th database file, or the <i>next</i> external symbol following
- <code>sym1</code> in the database, or <code>NIL</code> when the end of the
- database is reached. See also <code><a href="#free">free</a></code>.
- <pre><code>
- : (pool "db")
- -> T
- : (seq *DB)
- -> {2}
- : (seq @)
- -> {3}
- </code></pre>
- <dt><a name="set"><code>(set 'var 'any ..) -> any</code></a>
- <dd>Stores new values <code>any</code> in the <code>var</code> arguments. See
- also <code><a href="#setq">setq</a></code>, <code><a
- href="#val">val</a></code>, <code><a
- href="#con">con</a></code> and <code><a
- href="#def">def</a></code>.
- <pre><code>
- : (set 'L '(a b c) (cdr L) '999)
- -> 999
- : L
- -> (a 999 c)
- </code></pre>
- <dt><a name="set!"><code>(set! 'obj 'any) -> any</code></a>
- <dd><a href="#trans">Transaction</a> wrapper function for <code><a
- href="#set">set</a></code>. Note that for setting the value of entities
- typically the <code><a href="#entityMesssages">set!></a></code> message
- is used. See also <code><a href="#new!">new!</a></code>, <code><a
- href="#put!">put!</a></code> and <code><a
- href="#inc!">inc!</a></code>.
- <pre><code>
- (set! Obj (* Count Size)) # Setting a non-entity object to a numeric value
- </code></pre>
- <dt><a name="setq"><code>(setq var 'any ..) -> any</code></a>
- <dd>Stores new values <code>any</code> in the <code>var</code> arguments. See
- also <code><a href="#set">set</a></code>, <code><a
- href="#val">val</a></code> and <code><a
- href="#def">def</a></code>.
- <pre><code>
- : (setq A 123 B (list A A)) # Set 'A' to 123, then 'B' to (123 123)
- -> (123 123)
- </code></pre>
- <dt><a name="show"><code>(show 'any ['sym|cnt ..]) -> any</code></a>
- <dd>Shows the name, value and property list of a symbol found by applying the
- <code><a href="#get">get</a></code> algorithm to <code>any</code> and
- the following arguments. See also <code><a href="#edit">edit</a></code>
- and <code><a href="#view">view</a></code>.
- <pre><code>
- : (setq A 123456)
- -> 123456
- : (put 'A 'x 1)
- -> 1
- : (put 'A 'lst (9 8 7))
- -> (9 8 7)
- : (put 'A 'flg T)
- -> T
- : (show 'A)
- A 123456
- flg
- lst (9 8 7)
- x 1
- -> A
- : (show 'A 'lst 2)
- -> 8
- </code></pre>
- <dt><a name="show/1"><code>show/1</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that always succeeds, and shows
- the name, value and property list of the argument symbol. See also <code><a
- href="#show">show</a></code>.
- <pre><code>
- : (? (db nr +Item 2 @Item) (show @Item))
- {3-2} (+Item)
- nm "Spare Part"
- nr 2
- pr 1250
- inv 100
- sup {2-2}
- @Item={3-2}
- -> NIL
- </code></pre>
- <dt><a name="sigio"><code>(sigio 'cnt . prg) -> cnt</code></a>
- <dd>Sets a signal handler <code>prg</code> for SIGIO on the file descriptor
- <code>cnt</code>. Returns the file descriptor. See also <code><a
- href="#alarm">alarm</a></code>, <code><a
- href="#*Hup">*Hup</a></code> and <code><a
- href="#*Sig1">*Sig[12]</a></code>.
- <pre><code>
- # First session
- : (sigio (setq *SigSock (port T 4444)) # Register signal handler at UDP port
- (while (udp *SigSock) # Queue all received data
- (fifo '*SigQueue @) ) )
- -> 3
- # Second session
- : (for I 7 (udp "localhost" 4444 I)) # Send numbers to first session
- # First session
- : (fifo '*SigQueue)
- -> 1
- : (fifo '*SigQueue)
- -> 2
- </code></pre>
- <dt><a name="size"><code>(size 'any) -> cnt</code></a>
- <dd>Returns the "size" of <code>any</code>. For numbers this is the number of
- bytes needed for the value, for external symbols it is the number of bytes it
- would occupy in the database, for other symbols it is the number of bytes
- occupied by the UTF-8 representation of the name, and for lists it is the total
- number of cells in this list and all its sublists. See also <code><a
- href="#length">length</a></code> and <code><a
- href="#bytes">bytes</a></code>.
- <pre><code>
- : (size "abc")
- -> 3
- : (size "äbc")
- -> 4
- : (size 127) # One byte
- -> 1
- : (size 128) # Two bytes (eight bits plus sign bit!)
- -> 2
- : (size (1 (2) 3))
- -> 4
- : (size (1 2 3 .))
- -> 3
- </code></pre>
- <dt><a name="skip"><code>(skip ['any]) -> sym</code></a>
- <dd>Skips all whitespace (and comments if <code>any</code> is given) in the
- input stream. Returns the next available character, or <code>NIL</code> upon end
- of file. See also <code><a href="#peek">peek</a></code> and <code><a
- href="#eof">eof</a></code>.
- <pre><code>
- $ cat a
- # Comment
- abcd
- $ pil +
- : (in "a" (skip "#"))
- -> "a"
- </code></pre>
- <dt><a name="solve"><code>(solve 'lst [. prg]) -> lst</code></a>
- <dd>Evaluates a <a href="#pilog">Pilog</a> query and, returns the list
- of result sets. If <code>prg</code> is given, it is executed for each result
- set, with all Pilog variables bound to their matching values, and returns a list
- of the results. See also <code><a href="#pilog">pilog</a></code>,
- <code><a href="#?">?</a></code>, <code><a
- href="#goal">goal</a></code> and <code><a
- href="#prove">prove</a></code>.
- <pre><code>
- : (solve '((append @X @Y (a b c))))
- -> (((@X) (@Y a b c)) ((@X a) (@Y b c)) ((@X a b) (@Y c)) ((@X a b c) (@Y)))
- : (solve '((append @X @Y (a b c))) @X)
- -> (NIL (a) (a b) (a b c))
- </code></pre>
- <dt><a name="sort"><code>(sort 'lst ['fun]) -> lst</code></a>
- <dd>Sorts <code>lst</code> by destructively exchanging its elements. If
- <code>fun</code> is given, it is used as a "less than" predicate for
- comparisons. Typically, <code>sort</code> is used in combination with <a
- href="#by">by</a>, giving shorter and often more efficient solutions
- than with the predicate function. See also <a href="#cmp">Comparing</a>,
- <code><a href="#group">group</a></code>, <code><a
- href="#maxi">maxi</a></code>, <code><a
- href="#mini">mini</a></code> and <code><a
- href="#uniq">uniq</a></code>.
- <pre><code>
- : (sort '(a 3 1 (1 2 3) d b 4 T NIL (a b c) (x y z) c 2))
- -> (NIL 1 2 3 4 a b c d (1 2 3) (a b c) (x y z) T)
- : (sort '(a 3 1 (1 2 3) d b 4 T NIL (a b c) (x y z) c 2) >)
- -> (T (x y z) (a b c) (1 2 3) d c b a 4 3 2 1 NIL)
- : (by cadr sort '((1 4 3) (5 1 3) (1 2 4) (3 8 5) (6 4 5)))
- -> ((5 1 3) (1 2 4) (1 4 3) (6 4 5) (3 8 5))
- </code></pre>
- <dt><a name="space"><code>(space ['cnt]) -> cnt</code></a>
- <dd>Prints <code>cnt</code> spaces, or a single space when <code>cnt</code> is
- not given. See also <code><a href="#beep">beep</a></code>, <code><a
- href="#prin">prin</a></code> and <code><a
- href="#char">char</a></code>.
- <pre><code>
- : (space)
- -> 1
- : (space 1)
- -> 1
- : (space 2)
- -> 2
- </code></pre>
- <dt><a name="sp?"><code>(sp? 'any) -> flg</code></a>
- <dd>Returns <code>T</code> when the argument <code>any</code> is
- <code>NIL</code>, or if it is a string (symbol) that consists only of whitespace
- characters.
- <pre><code>
- : (sp? " ")
- -> T
- : (sp? "ABC")
- -> NIL
- : (sp? 123)
- -> NIL
- </code></pre>
- <dt><a name="split"><code>(split 'lst 'any ..) -> lst</code></a>
- <dd>Splits <code>lst</code> at all places containing an element <code>any</code>
- and returns the resulting list of sublists. See also <code><a
- href="#stem">stem</a></code>.
- <pre><code>
- : (split (1 a 2 b 3 c 4 d 5 e 6) 'e 3 'a)
- -> ((1) (2 b) (c 4 d 5) (6))
- : (mapcar pack (split (chop "The quick brown fox") " "))
- -> ("The" "quick" "brown" "fox")
- </code></pre>
- <dt><a name="sqrt"><code>(sqrt 'num ['flg|num]) -> num</code></a>
- <dd>Returns the square root of the <code>num</code> argument. If
- <code>flg</code> is given and non-<code>NIL</code>, the result will be rounded.
- If in addition to that <code>flg</code> is a number, the first argument will be
- multiplied with it before doing the square root calculation. See also <code><a
- href="#*/">*/</a></code>.
- <pre><code>
- : (sqrt 64)
- -> 8
- : (sqrt 1000)
- -> 31
- : (sqrt 1000 T)
- -> 32
- : (sqrt 10000000000000000000000000000000000000000)
- -> 100000000000000000000
- : (scl 6)
- -> 6
- : (sqrt 2.0 1.0)
- -> 1414214
- </code></pre>
- <dt><a name="stack"><code>(stack ['cnt]) -> cnt | (.. sym . cnt)</code></a>
- <dd>(64-bit version only) Maintains the stack segment size for <a
- href="#coroutines">coroutines</a> (the main stack segment is limited -
- while at least one coroutine is running - to four times that size). If called
- without a <code>cnt</code> argument, or if already one or more coroutines are
- running, the current size in kilobytes is returned. Otherwise, the stack segment
- size is set to the new value (default 64 kB). If there are running coroutines,
- their tags will be <code><a href="#cons">cons</a></code>ed in front of
- the size. See also <code><a href="#heap">heap</a></code>.
- <pre><code>
- $ ulimit -s unlimited && pil + # Guarantee stack space
- : (stack) # Current size
- -> 64 # 64 kB
- : (stack 200) # Set to 200 kB
- -> 200
- : (co 'inc (let N 0 (loop (yield (inc 'N))))) # Create two coroutines
- -> 1
- : (co 'dec (let N 0 (loop (yield (dec 'N)))))
- -> -1
- : (stack)
- -> (dec inc . 200)
- </code></pre>
- <dt><a name="stamp"><code>(stamp ['dat 'tim]|['T]) -> sym</code></a>
- <dd>Returns a date-time string in the form "YYYY-MM-DD HH:MM:SS". If
- <code>dat</code> and <code>tim</code> is missing, the current date and time is
- used. If <code>T</code> is passed, the current Coordinated Universal Time (UTC)
- is used instead. See also <code><a href="#date">date</a></code> and
- <code><a href="#time">time</a></code>.
- <pre><code>
- : (stamp)
- -> "2000-09-12 07:48:04"
- : (stamp (date) 0)
- -> "2000-09-12 00:00:00"
- : (stamp (date 2000 1 1) (time 12 0 0))
- -> "2000-01-01 12:00:00"
- </code></pre>
- <dt><a name="state"><code>(state 'var (sym|lst exe [. prg]) ..) -> any</code></a>
- <dd>Implements a finite state machine. The variable <code>var</code> holds the
- current state as a symbolic value. When a clause is found that contains the
- current state in its CAR <code>sym|lst</code> value, and where the
- <code>exe</code> in its CADR evaluates to non-<code>NIL</code>, the current
- state will be set to that value, the body <code>prg</code> in the CDDR will be
- executed, and the result returned. <code>T</code> is a catch-all for any state.
- If no state-condition matches, <code>NIL</code> is returned. See also <code><a
- href="#case">case</a></code>, <code><a
- href="#cond">cond</a></code> and <code><a
- href="#job">job</a></code>.
- <pre><code>
- : (de tst ()
- (job '((Cnt . 4))
- (state '(start)
- (start 'run
- (printsp 'start) )
- (run (and (gt0 (dec 'Cnt)) 'run)
- (printsp 'run) )
- (run 'stop
- (printsp 'run) )
- (stop 'start
- (setq Cnt 4)
- (println 'stop) ) ) ) )
- -> tst
- : (do 12 (tst))
- start run run run run stop
- start run run run run stop
- -> stop
- : (pp 'tst)
- (de tst NIL
- (job '((Cnt . 4))
- (state '(start)
- ...
- -> tst
- : (do 3 (tst))
- start run run -> run
- : (pp 'tst)
- (de tst NIL
- (job '((Cnt . 2))
- (state '(run)
- ...
- -> tst
- </code></pre>
- <dt><a name="stem"><code>(stem 'lst 'any ..) -> lst</code></a>
- <dd>Returns the tail of <code>lst</code> that does not contain any of the
- <code>any</code> arguments. <code>(stem 'lst 'any ..)</code> is equivalent to
- <code>(last (split 'lst 'any ..))</code>. See also <code><a
- href="#tail">tail</a></code> and <code><a
- href="#split">split</a></code>.
- <pre><code>
- : (stem (chop "abc/def\\ghi") "/" "\\")
- -> ("g" "h" "i")
- </code></pre>
- <dt><a name="step"><code>(step 'lst ['flg]) -> any</code></a>
- <dd>Single-steps iteratively through a database tree. <code>lst</code> is a
- structure as received from <code><a href="#init">init</a></code>. If
- <code>flg</code> is non-<code>NIL</code>, partial keys are skipped. See also
- <code><a href="#tree">tree</a></code>, <code><a
- href="#scan">scan</a></code>, <code><a
- href="#iter">iter</a></code>, <code><a
- href="#leaf">leaf</a></code> and <code><a
- href="#fetch">fetch</a></code>.
- <pre><code>
- : (setq Q (init (tree 'nr '+Item) 3 5))
- -> (((3 . 5) ((3 NIL . {3-3}) (4 NIL . {3-4}) (5 NIL . {3-5}) (6 NIL . {3-6}) (7 NIL . {3-8}))))
- : (get (step Q) 'nr)
- -> 3
- : (get (step Q) 'nr)
- -> 4
- : (get (step Q) 'nr)
- -> 5
- : (get (step Q) 'nr)
- -> NIL
- </code></pre>
- <dt><a name="store"><code>(store 'tree 'any1 'any2 ['(num1 . num2)])</code></a>
- <dd>Stores a value <code>any2</code> for the key <code>any1</code> in a database
- tree. <code>num1</code> is a database file number, as used in <code><a
- href="#new">new</a></code> (defaulting to 1), and <code>num2</code> a
- database block size (defaulting to 256). When <code>any2</code> is
- <code>NIL</code>, the corresponding entry is deleted from the tree. See also
- <code><a href="#tree">tree</a></code> and <code><a
- href="#fetch">fetch</a></code>.
- <pre><code>
- : (store (tree 'nr '+Item) 2 '{3-2})
- </code></pre>
- <dt><a name="str"><code>(str 'sym ['sym1]) -> lst</code></a>
- <dt><code>(str 'lst) -> sym</code>
- <dd>In the first form, the string <code>sym</code> is parsed into a list. This
- mechanism is also used by <code><a href="#load">load</a></code>. If
- <code>sym1</code> is given, it should specify a set of characters, and
- <code>str</code> will then return a list of tokens analog to <code><a
- href="#read">read</a></code>. The second form does the reverse
- operation by building a string from a list. See also <code><a
- href="#any">any</a></code>, <code><a
- href="#name">name</a></code> and <code><a
- href="#sym">sym</a></code>.
- <pre><code>
- : (str "a (1 2) b")
- -> (a (1 2) b)
- : (str '(a "Hello" DEF))
- -> "a \"Hello\" DEF"
- : (str "a*3+b*4" "_")
- -> (a "*" 3 "+" b "*" 4)
- </code></pre>
- <dt><a name="str?"><code>(str? 'any) -> sym | NIL</code></a>
- <dd>Returns the argument <code>any</code> when it is a transient symbol
- (string), otherwise <code>NIL</code>. See also <code><a
- href="#sym?">sym?</a></code>, <code><a
- href="#box?">box?</a></code> and <code><a
- href="#ext?">ext?</a></code>.
- <pre><code>
- : (str? 123)
- -> NIL
- : (str? '{ABC})
- -> NIL
- : (str? 'abc)
- -> NIL
- : (str? "abc")
- -> "abc"
- </code></pre>
- <dt><a name="strDat"><code>(strDat 'sym) -> dat</code></a>
- <dd>Converts a string <code>sym</code> in the date format of the current
- <code><a href="#locale">locale</a></code> to a <code><a
- href="#date">date</a></code>. See also <code><a
- href="#expDat">expDat</a></code>, <code><a
- href="#$dat">$dat</a></code> and <code><a
- href="#datStr">datStr</a></code>.
- <pre><code>
- : (strDat "2007-06-01")
- -> 733134
- : (strDat "01.06.2007")
- -> NIL
- : (locale "DE" "de")
- -> NIL
- : (strDat "01.06.2007")
- -> 733134
- : (strDat "1.6.2007")
- -> 733134
- </code></pre>
- <dt><a name="strip"><code>(strip 'any) -> any</code></a>
- <dd>Strips all leading <code>quote</code> symbols from <code>any</code>.
- <pre><code>
- : (strip 123)
- -> 123
- : (strip '''(a))
- -> (a)
- : (strip (quote quote a b c))
- -> (a b c)
- </code></pre>
- <dt><a name="struct"><code>(struct 'num 'any 'any ..) -> any</code></a>
- <dd>Creates or extracts data structures, suitable to be passed to or returned
- from <code><a href="#native">native</a></code> C functions. The first
- <code>num</code> argument should be a native value, either a scalar, or a
- pointer obtained by calling functions like <code>malloc()</code>. The second
- argument <code>any</code> is a <a href="#natResult">result
- specification</a>, while all following <a
- href="#natItem">initialization items</a> are stored in the structure
- pointed to by the first argument. See also <a href="native.html">Native C
- Calls</a>.
- <pre><code>
- : (scl 2)
- -> 2
- ## /* We assume the following C structure */
- ## typedef struct value {
- ## int x, y;
- ## double a, b, c;
- ## long z;
- ## char nm[4];
- ## } value;
- # Allocate structure
- : (setq P (native "@" "malloc" 'N 44))
- -> 9204032
- # Store two integers, three doubles, one long, and four characters
- : (struct P 'N -7 -4 (1.0 0.11 0.22 0.33) (7 . 8) 65 66 67 0)
- -> 9204032
- # Extract the structure
- : (struct P '((I . 2) (1.0 . 3) N (C . 4)))
- -> ((7 4) (11 22 33) 7 ("A" "B" "C" NIL))
- # Do both in a single call (allowing conversions of data types)
- : (struct P
- '((I . 2) (1.0 . 3) N (C . 4))
- -7 -4 (1.0 0.11 0.22 0.33) (7 . 8) 65 66 67 0 )
- -> ((7 4) (11 22 33) 7 ("A" "B" "C" NIL))
- # De-allocate structure
- : (native "@" "free" NIL P)
- -> NIL
- </code></pre>
- <dt><a name="sub?"><code>(sub? 'any1 'any2) -> any2 | NIL</code></a>
- <dd>Returns <code>any2</code> when the string representation of
- <code>any1</code> is a substring of the string representation of
- <code>any2</code>. See also <code><a href="#pre?">pre?</a></code>,
- <code><a href="#offset">offset</a></code> and <code><a
- href="#index">index</a></code>.
- <pre><code>
- : (sub? "def" "abcdefg")
- -> "abcdefg"
- : (sub? "abb" "abcdefg")
- -> NIL
- : (sub? NIL "abcdefg")
- -> "abcdefg"
- : (sub? "def" '(a b c d e f g))
- -> "abcdefg"
- : (sub? '(d e f) "abcdefg")
- -> "abcdefg"
- </code></pre>
- <dt><a name="subr"><code>(subr 'sym) -> num</code></a>
- <dd>Converts a Lisp-function that was previously converted with <code><a
- href="#expr">expr</a></code> back to a C-function.
- <pre><code>
- : car
- -> 67313448
- : (expr 'car)
- -> (@ (pass $385260187))
- : (subr 'car)
- -> 67313448
- : car
- -> 67313448
- </code></pre>
- <dt><a name="sum"><code>(sum 'fun 'lst ..) -> num</code></a>
- <dd>Applies <code>fun</code> to each element of <code>lst</code>. When
- additional <code>lst</code> arguments are given, their elements are also passed
- to <code>fun</code>. Returns the sum of all numeric values returned from
- <code>fun</code>.
- <pre><code>
- : (setq A 1 B 2 C 3)
- -> 3
- : (sum val '(A B C))
- -> 6
- : (sum * (3 4 5) (5 6 7)) # Vector dot product
- -> 74
- : (sum # Total size of symbol list values
- '((X)
- (and (pair (val X)) (size @)) )
- (what) )
- -> 32021
- </code></pre>
- <dt><a name="super"><code>(super ['any ..]) -> any</code></a>
- <dd>Can only be used inside methods. Sends the current message to the current
- object <code>This</code>, this time starting the search for a method at the
- superclass(es) of the class where the current method was found. See also <a
- href="#oop">OO Concepts</a>, <code><a
- href="#extra">extra</a></code>, <code><a
- href="#method">method</a></code>, <code><a
- href="#meth">meth</a></code>, <code><a
- href="#send">send</a></code> and <code><a
- href="#try">try</a></code>.
- <pre><code>
- (dm stop> () # 'stop>' method of current class
- (super) # Call the 'stop>' method of the superclass
- ... ) # other things
- </code></pre>
- <dt><a name="swap"><code>(swap 'var 'any) -> any</code></a>
- <dd>Set the value of <code>var</code> to <code>any</code>, and return the
- previous value. See also <code><a href="#xchg">xchg</a></code> and
- <code><a href="#set">set</a></code>.
- <pre><code>
- : (setq A 7 L (1 2 3))
- -> (1 2 3)
- : (swap (cdr L) (swap 'A 'xyz))
- -> 2
- : A
- -> xyz
- : L
- -> (1 7 3)
- </code></pre>
- <dt><a name="sym"><code>(sym 'any) -> sym</code></a>
- <dd>Generate the printed representation of <code>any</code> into the name of a
- new symbol <code>sym</code>. This is the reverse operation of <code><a
- href="#any">any</a></code>. See also <code><a
- href="#name">name</a></code> and <code><a
- href="#str">str</a></code>.
- <pre><code>
- : (sym '(abc "Hello" 123))
- -> "(abc \"Hello\" 123)"
- </code></pre>
- <dt><a name="sym?"><code>(sym? 'any) -> flg</code></a>
- <dd>Returns <code>T</code> when the argument <code>any</code> is a symbol. See
- also <code><a href="#num?">num?</a></code>, <code><a
- href="#atom">atom</a></code>, <code><a
- href="#pair">pair</a></code>, <code><a
- href="#str?">str?</a></code>, <code><a
- href="#box?">box?</a></code> and <code><a
- href="#ext?">ext?</a></code>.
- <pre><code>
- : (sym? 'a)
- -> T
- : (sym? NIL)
- -> T
- : (sym? 123)
- -> NIL
- : (sym? '(a b))
- -> NIL
- </code></pre>
- <dt><a name="symbols"><code>(symbols) -> sym</code></a>
- <dt><code>(symbols 'sym1) -> sym2</code>
- <dt><code>(symbols 'sym1 'sym ..) -> sym2</code>
- <dd>(64-bit version only) Creates and manages namespaces of internal symbols: In
- the first form, the current namespace is returned. In the second form, the
- current namespace is set to <code>sym1</code>, and the previous namespace
- <code>sym2</code> is returned. In the third form, <code>sym1</code> is assigned
- a <code><a href="#balance">balance</a></code>d copy of the existing
- namespace(s) <code>sym</code>, and becomes the new current namespace, returning
- the previous namespace <code>sym2</code>. If in the third form more than one
- <code>sym</code> argument is given, possibly conflicting symbols in later
- namespaces are not interned into <code>sym2</code>. See also <code><a
- href="#pico">pico</a></code>, <code><a
- href="#local">local</a></code>, <code><a
- href="#import">import</a></code>, <code><a
- href="#intern">intern</a></code> and <code><a
- href="#load">load</a></code>.
- <pre><code>
- : (symbols 'myLib 'pico)
- -> pico
- myLib: (de foo (X)
- (bar (inc X)) )
- -> foo
- myLib: (symbols 'pico)
- -> myLib
- : (pp 'foo)
- (de foo . NIL)
- -> foo
- : (pp 'myLib~foo)
- (de "foo" (X)
- ("bar" (inc X)) )
- -> "foo"
- : (symbols 'myLib)
- -> pico
- myLib: (pp 'foo)
- (de foo (X)
- (bar (inc X)) )
- -> foo
- myLib:
- </code></pre>
- <dt><a name="sync"><code>(sync) -> flg</code></a>
- <dd>Waits for pending data from all family processes. While other processes are
- still sending data (via the <code><a href="#tell">tell</a></code>
- mechanism), a <code>select</code> system call is executed for all file
- descriptors and timers in the <code>VAL</code> of the global variable <code><a
- href="#*Run">*Run</a></code>. When used in a non-database context,
- <code>(tell)</code> should be called in the end to inform the parent process
- that it may grant synchronization to other processes waiting for
- <code>sync</code>. In a database context, where <code>sync</code> is usually
- called by <code><a href="#dbSync">dbSync</a></code>, this is not
- necessary because it is done internally by <code><a
- href="#commit">commit</a></code> or <code><a
- href="#rollback">rollback</a></code>.
- See also <code><a
- href="#key">key</a></code> and <code><a
- href="#wait">wait</a></code>.
- <pre><code>
- : (or (lock) (sync)) # Ensure database consistency
- -> T # (numeric process-id if lock failed)
- </code></pre>
- <dt><a name="sys"><code>(sys 'any ['any]) -> sym</code></a>
- <dd>Returns or sets a system environment variable.
- <pre><code>
- : (sys "TERM") # Get current value
- -> "xterm"
- : (sys "TERM" "vt100") # Set new value
- -> "vt100"
- : (sys "TERM")
- -> "vt100"
- </code></pre>
- </dl>
- <h1><a name="T">T</a></h1>
- <dl>
- <dt><a name="*Tmp"><code>*Tmp</code></a>
- <dd>A global variable holding the temporary directory name created with <code><a
- href="#tmp">tmp</a></code>. See also <code><a
- href="#*Bye">*Bye</a></code>.
- <pre><code>
- : *Bye
- -> ((saveHistory) (and *Tmp (call 'rm "-r" *Tmp)))
- : (tmp "foo" 123)
- -> "/home/app/.pil/tmp/27140/foo123"
- : *Tmp
- -> "/home/app/.pil/tmp/27140/"
- </code></pre>
- <p><dt><a name="*Tsm"><code>*Tsm</code></a>
- <dd>A global variable which may hold a cons pair of two strings with escape
- sequences, to switch on and off an alternative transient symbol markup. If set,
- <code><a href="#print">print</a></code> will output these sequences to
- the console instead of the standard double quote markup characters. An easy way
- to switch on transient symbol markup is loading "@lib/tsm.l".
- <pre><code>
- : (de *Tsm "^[[4m" . "^[[24m") # vt100 escape sequences for underline
- -> *Tsm
- : <u>Hello world</u>
- -> <u>Hello world</u>
- : (off *Tsm)
- -> NIL
- : "Hello world" # No underlining
- -> "Hello world"
- </code></pre>
- <dt><a name="+Time"><code>+Time</code></a>
- <dd>Class for clock time values (as calculated by <code><a
- href="#time">time</a></code>), a subclass of <code><a
- href="#+Number">+Number</a></code>. See also <a
- href="#dbase">Database</a>.
- <pre><code>
- (rel tim (+Time)) # Time of the day
- </code></pre>
- <dt><a name="T"><code>T</code></a>
- <dd>A global constant, evaluating to itself. <code>T</code> is commonly returned
- as the boolean value "true" (though any non-<code>NIL</code> values could be
- used). It represents the absolute maximum, as it is larger than any other
- object. As a property key, it is used to store <a
- href="#pilog">Pilog</a> clauses, and inside Pilog clauses it is the
- <i>cut</i> operator. See also <code><a href="#nilSym">NIL</a></code> and
- and <a href="#cmp">Comparing</a>.
- <pre><code>
- : T
- -> T
- : (= 123 123)
- -> T
- : (get 'not T)
- -> ((@P (1 (-> @P)) T (fail)) (@P))
- </code></pre>
- <dt><a name="This"><code>This</code></a>
- <dd>Holds the current object during method execution (see <a
- href="#oop">OO Concepts</a>), or inside the body of a <code><a
- href="#with">with</a></code> statement. As it is a normal symbol,
- however, it can be used in normal bindings anywhere. See also <code><a
- href="#isa">isa</a></code>, <code><a href="ref_.html#:">:</a></code>,
- <code><a href="#=:">=:</a></code>, <code><a
- href="#::">::</a></code> and <code><a
- href="#var:">var:</a></code>.
- <pre><code>
- : (with 'X (println 'This 'is This))
- This is X
- -> X
- : (put 'X 'a 1)
- -> 1
- : (put 'X 'b 2)
- -> 2
- : (put 'Y 'a 111)
- -> 111
- : (put 'Y 'b 222)
- -> 222
- : (mapcar '((This) (cons (: a) (: b))) '(X Y))
- -> ((1 . 2) (111 . 222))
- </code></pre>
- <dt><a name="t"><code>(t . prg) -> T</code></a>
- <dd>Executes <code>prg</code>, and returns <code>T</code>. See also <code><a
- href="#nil">nil</a></code>, <code><a
- href="#prog">prog</a></code>, <code><a
- href="#prog1">prog1</a></code> and <code><a
- href="#prog2">prog2</a></code>.
- <pre><code>
- : (t (println 'OK))
- OK
- -> T
- </code></pre>
- <dt><a name="tab"><code>(tab 'lst 'any ..) -> NIL</code></a>
- <dd>Print all <code>any</code> arguments in a tabular format. <code>lst</code>
- should be a list of numbers, specifying the field width for each argument. All
- items in a column will be left-aligned for negative numbers, otherwise
- right-aligned. See also <code><a href="#align">align</a></code>,
- <code><a href="#center">center</a></code> and <code><a
- href="#wrap">wrap</a></code>.
- <pre><code>
- : (let Fmt (-3 14 14)
- (tab Fmt "Key" "Rand 1" "Rand 2")
- (tab Fmt "---" "------" "------")
- (for C '(A B C D E F)
- (tab Fmt C (rand) (rand)) ) )
- Key Rand 1 Rand 2
- --- ------ ------
- A 0 1481765933
- B -1062105905 -877267386
- C -956092119 812669700
- D 553475508 -1702133896
- E 1344887256 -1417066392
- F 1812158119 -1999783937
- -> NIL
- </code></pre>
- <dt><a name="tail"><code>(tail 'cnt|lst 'lst) -> lst</code></a>
- <dd>Returns the last <code>cnt</code> elements of <code>lst</code>. If
- <code>cnt</code> is negative, it is added to the length of <code>lst</code>. If
- the first argument is a <code>lst</code>, <code>tail</code> is a predicate
- function returning that argument list if it is <code>equal</code> to the tail of
- the second argument, and <code>NIL</code> otherwise. <code>(tail -2 Lst)</code>
- is equivalent to <code>(nth Lst 3)</code>. See also <code><a
- href="#offset">offset</a></code>, <code><a
- href="#head">head</a></code>, <code><a
- href="#last">last</a></code> and <code><a
- href="#stem">stem</a></code>.
- <pre><code>
- : (tail 3 '(a b c d e f))
- -> (d e f)
- : (tail -2 '(a b c d e f))
- -> (c d e f)
- : (tail 0 '(a b c d e f))
- -> NIL
- : (tail 10 '(a b c d e f))
- -> (a b c d e f)
- : (tail '(d e f) '(a b c d e f))
- -> (d e f)
- </code></pre>
- <dt><a name="task"><code>(task 'num ['num] [sym 'any ..] [. prg]) -> lst</code></a>
- <dd>A front-end to the <code><a href="#*Run">*Run</a></code> global. If
- called with only a single <code>num</code> argument, the corresponding entry is
- removed from the value of <code>*Run</code>. Otherwise, a new entry is created.
- If an entry with that key already exists, an error is issued. For negative
- numbers, a second number must be supplied. If <code>sym</code>/<code>any</code>
- arguments are given, a <code><a href="#job">job</a></code> environment
- is built for thie <code>*Run</code> entry. See also <code><a
- href="#forked">forked</a></code> and <code><a
- href="#timeout">timeout</a></code>.
- <pre><code>
- : (task -10000 5000 N 0 (msg (inc 'N))) # Install task
- -> (-10000 5000 (job '((N . 0)) (msg (inc 'N)))) # for every 10 seconds
- : 1 # ... after 5 seconds
- 2 # ... after 10 seconds
- 3 # ... after 10 seconds
- (task -10000) # remove again
- -> NIL
- : (task (port T 4444) (eval (udp @))) # Receive RPC via UDP
- -> (3 (eval (udp @)))
- # Another session (on the same machine)
- : (udp "localhost" 4444 '(println *Pid)) # Send RPC message
- -> (println *Pid)
- </code></pre>
- <dt><a name="telStr"><code>(telStr 'sym) -> sym</code></a>
- <dd>Formats a telephone number according to the current <code><a
- href="#locale">locale</a></code>. If the string head matches the local
- country code, it is replaced with <code>0</code>, otherwise <code>+</code> is
- prepended. See also <code><a href="#expTel">expTel</a></code>, <code><a
- href="#datStr">datStr</a></code>, <code><a
- href="#money">money</a></code> and <code><a
- href="#format">format</a></code>.
- <pre><code>
- : (telStr "49 1234 5678-0")
- -> "+49 1234 5678-0"
- : (locale "DE" "de")
- -> NIL
- : (telStr "49 1234 5678-0")
- -> "01234 5678-0"
- </code></pre>
- <dt><a name="tell"><code>(tell ['cnt] 'sym ['any ..]) -> any</code></a>
- <dd>Family IPC: Send an executable list <code>(sym any ..)</code> to all family
- members (i.e. all children of the current process, and all other children of the
- parent process, see <code><a href="#fork">fork</a></code>) for
- automatic execution. When the <code>cnt</code> argument is given and non-zero,
- it should be the PID of such a process, and the list will be sent only to that
- process. When called without arguments, no message is actually sent, and the
- parent process may grant <code><a href="#sync">sync</a></code> to the
- next waiting process. <code>tell</code> is also used internally by <code><a
- href="#commit">commit</a></code> to notify about database changes. When
- called explicitly, the size of the message is limited to the POSIX constant
- PIPE_BUF. See also <code><a href="#kids">kids</a></code> and <code><a
- href="#hear">hear</a></code>.
- <pre><code>
- : (call 'ps "x") # Show processes
- PID TTY STAT TIME COMMAND
- ..
- 1321 pts/0 S 0:00 /usr/bin/picolisp .. # Parent process
- 1324 pts/0 S 0:01 /usr/bin/picolisp .. # First child
- 1325 pts/0 S 0:01 /usr/bin/picolisp .. # Second child
- 1326 pts/0 R 0:00 ps x
- -> T
- : *Pid # We are the second child
- -> 1325
- : (tell 'println '*Pid) # Ask all others to print their Pid's
- 1324
- -> *Pid
- </code></pre>
- <dt><a name="test"><code>(test 'any . prg)</code></a>
- <dd>Executes <code>prg</code>, and issues an <code><a
- href="#errors">error</a></code> if the result does not <code><a
- href="#match">match</a></code> the <code>any</code> argument. See also
- <code><a href="#assert">assert</a></code>.
- <pre><code>
- : (test 12 (* 3 4))
- -> NIL
- : (test 12 (+ 3 4))
- ((+ 3 4))
- 12 -- 'test' failed
- ?
- </code></pre>
- <dt><a name="text"><code>(text 'any1 'any ..) -> sym</code></a>
- <dd>Builds a new transient symbol (string) from the string representation of
- <code>any1</code>, by replacing all occurrences of an at-mark "<code>@</code>",
- followed by one of the letters "<code>1</code>" through "<code>9</code>", and
- "<code>A</code>" through "<code>Z</code>", with the corresponding
- <code>any</code> argument. In this context "<code>@A</code>" refers to the 10th
- argument. A literal at-mark in the text can be represented by two successive
- at-marks. See also <code><a href="#pack">pack</a></code> and <code><a
- href="#glue">glue</a></code>.
- <pre><code>
- : (text "abc @1 def @2" 'XYZ 123)
- -> "abc XYZ def 123"
- : (text "a@@bc.@1" "de")
- -> "a@bc.de"
- </code></pre>
- <dt><a name="throw"><code>(throw 'sym 'any)</code></a>
- <dd>Non-local jump into a previous <code><a
- href="#catch">catch</a></code> environment with the jump label
- <code>sym</code> (or <code>T</code> as a catch-all). Any pending <code><a
- href="#finally">finally</a></code> expressions are executed, local
- symbol bindings are restored, open files are closed and internal data structures
- are reset appropriately, as the environment was at the time when the
- corresponding <code>catch</code> was called. Then <code>any</code> is returned
- from that <code>catch</code>. See also <code><a
- href="#quit">quit</a></code>.
- <pre><code>
- : (de foo (N)
- (println N)
- (throw 'OK) )
- -> foo
- : (let N 1 (catch 'OK (foo 7)) (println N))
- 7
- 1
- -> 1
- </code></pre>
- <dt><a name="tick"><code>(tick (cnt1 . cnt2) . prg) -> any</code></a>
- <dd>Executes <code>prg</code>, then (destructively) adds the number of elapsed
- user ticks to the <code>cnt1</code> parameter, and the number of elapsed system
- ticks to the <code>cnt2</code> parameter. Thus, <code>cnt1</code> and
- <code>cnt2</code> will finally contain the total number of user and system time
- ticks spent in <code>prg</code> and all functions called (this works also for
- recursive functions). For execution profiling, <code>tick</code> is usually
- inserted into words with <code>prof</code>, and removed with
- <code>unprof</code>. See also <code><a href="#usec">usec</a></code>.
- <pre><code>
- : (de foo () # Define function with empty loop
- (tick (0 . 0) (do 100000000)) )
- -> foo
- : (foo) # Execute it
- -> NIL
- : (pp 'foo)
- (de foo NIL
- (tick (97 . 0) (do 100000000)) ) # 'tick' incremented 'cnt1' by 97
- -> foo
- </code></pre>
- <dt><a name="till"><code>(till 'any ['flg]) -> lst|sym</code></a>
- <dd>Reads from the current input channel till a character contained in
- <code>any</code> is found (or until end of file if <code>any</code> is
- <code>NIL</code>). If <code>flg</code> is <code>NIL</code>, a list of
- single-character transient symbols is returned. Otherwise, a single string is
- returned. See also <code><a href="#from">from</a></code> and <code><a
- href="#line">line</a></code>.
- <pre><code>
- : (till ":")
- abc:def
- -> ("a" "b" "c")
- : (till ":" T)
- abc:def
- -> "abc"
- </code></pre>
- <dt><a name="tim$"><code>(tim$ 'tim ['flg]) -> sym</code></a>
- <dd>Formats a <code><a href="#time">time</a></code> <code>tim</code>.
- If <code>flg</code> is <code>NIL</code>, the format is HH:MM, otherwise it is
- HH:MM:SS. See also <code><a href="#$tim">$tim</a></code> and <code><a
- href="#dat$">dat$</a></code>.
- <pre><code>
- : (tim$ (time))
- -> "10:57"
- : (tim$ (time) T)
- -> "10:57:56"
- </code></pre>
- <dt><a name="time"><code>(time ['T]) -> tim</code></a>
- <dt><code>(time 'tim) -> (h m s)</code>
- <dt><code>(time 'h 'm ['s]) -> tim | NIL</code>
- <dt><code>(time '(h m [s])) -> tim | NIL</code>
- <dd>Calculates the time of day, represented as the number of seconds since
- midnight. When called without arguments, the current local time is returned.
- When called with a <code>T</code> argument, the time of the last call to
- <code><a href="#date">date</a></code> is returned. When called with a
- single number <code>tim</code>, it is taken as a time value and a list with the
- corresponding hour, minute and second is returned. When called with two or three
- numbers (or a list of two or three numbers) for the hour, minute (and optionally
- the second), the corresponding time value is returned (or <code>NIL</code> if
- they do not represent a legal time). See also <code><a
- href="#date">date</a></code>, <code><a
- href="#stamp">stamp</a></code>, <code><a
- href="#usec">usec</a></code>, <code><a
- href="#tim$">tim$</a></code> and <code><a
- href="#$tim">$tim</a></code>.
- <pre><code>
- : (time) # Now
- -> 32334
- : (time 32334) # Now
- -> (8 58 54)
- : (time 12 70) # Illegal time
- -> NIL
- </code></pre>
- <dt><a name="timeout"><code>(timeout ['num])</code></a>
- <dd>Sets or refreshes a timeout value in the <code><a
- href="#*Run">*Run</a></code> global, so that the current process
- executes <code><a href="#bye">bye</a></code> after the given period. If
- called without arguments, the timeout is removed. See also <code><a
- href="#task">task</a></code>.
- <pre><code>
- : (timeout 3600000) # Timeout after one hour
- -> (-1 3600000 (bye))
- : *Run # Look after a few seconds
- -> ((-1 3574516 (bye)))
- </code></pre>
- <dt><a name="tmp"><code>(tmp ['any ..]) -> sym</code></a>
- <dd>Returns the path name to the <code><a
- href="#pack">pack</a></code>ed <code>any</code> arguments in a
- process-local temporary directory. The directory name consists of the path to
- ".pil/tmp/" in the user's home directory, followed by the current process ID
- <code><a href="#*Pid">*Pid</a></code>. This directory is automatically
- created if necessary, and removed upon termination of the process (<code><a
- href="#bye">bye</a></code>). See also <code><a
- href="#pil">pil</a></code>, <code><a
- href="#*Tmp">*Tmp</a></code> and <code><a
- href="#*Bye">*Bye</a></code> .
- <pre><code>
- : *Pid
- -> 27140
- : (tmp "foo" 123)
- -> "/home/app/.pil/tmp/27140/foo123"
- : (out (tmp "foo" 123) (println 'OK))
- -> OK
- : (dir (tmp))
- -> ("foo123")
- : (in (tmp "foo" 123) (read))
- -> OK
- </code></pre>
- <dt><a name="tolr/3"><code>tolr/3</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that succeeds if the first
- argument, after <code><a href="#fold">fold</a></code>ing it to a
- canonical form, is either a <i>substring</i> or a <code><a
- href="#+Sn">+Sn</a></code> <i>soundex</i> match of the result of
- applying the <code><a href="#get">get</a></code> algorithm to the
- following arguments. Typically used as filter predicate in <code><a
- href="#select/3">select/3</a></code> database queries. See also
- <code><a href="#isa/2">isa/2</a></code>, <code><a
- href="#same/3">same/3</a></code>, <code><a
- href="#bool/3">bool/3</a></code>, <code><a
- href="#range/3">range/3</a></code>, <code><a
- href="#head/3">head/3</a></code>, <code><a
- href="#fold/3">fold/3</a></code> and <code><a
- href="#part/3">part/3</a></code>.
- <pre><code>
- : (?
- @Nr (1 . 5)
- @Nm "Sven"
- (select (@CuSu)
- ((nr +CuSu @Nr) (nm +CuSu @Nm))
- (range @Nr @CuSu nr)
- (tolr @Nm @CuSu nm) )
- (val @Name @CuSu nm) )
- @Nr=(1 . 5) @Nm="Sven" @CuSu={2-2} @Name="Seven Oaks Ltd."
- </code></pre>
- <dt><a name="touch"><code>(touch 'sym) -> sym</code></a>
- <dd>When <code>sym</code> is an external symbol, it is marked as "modified" so
- that upon a later <code><a href="#commit">commit</a></code> it will be
- written to the database file. An explicit call of <code>touch</code> is only
- necessary when the value or properties of <code>sym</code> are indirectly
- modified.
- <pre><code>
- : (get '{2} 'lst)
- -> (1 2 3 4 5)
- : (set (cdr (get (touch '{2}) 'lst)) 999) # Only read-access, need 'touch'
- -> 999
- : (get '{2} 'lst) # Modified second list element
- -> (1 999 3 4 5)
- </code></pre>
- <dt><a name="trace"><code>(trace 'sym) -> sym</code></a>
- <dt><code>(trace 'sym 'cls) -> sym</code>
- <dt><code>(trace '(sym . cls)) -> sym</code>
- <dd>(Debug mode only) Inserts a <code><a href="#$">$</a></code> trace
- function call at the beginning of the function or method body of
- <code>sym</code>, so that trace information will be printed before and after
- execution. Built-in functions (C-function pointer) are automatically converted
- to Lisp expressions (see <code><a href="#expr">expr</a></code>). See
- also <code><a href="#*Dbg">*Dbg</a></code>, <code><a
- href="#traceAll">traceAll</a></code> and <code><a
- href="#untrace">untrace</a></code>, <code><a
- href="#debug">debug</a></code> and <code><a
- href="#lint">lint</a></code>.
- <pre><code>
- : (trace '+)
- -> +
- : (+ 3 4)
- + : 3 4
- + = 7
- -> 7
- </code></pre>
- <dt><a name="traceAll"><code>(traceAll ['lst]) -> sym</code></a>
- <dd>(Debug mode only) Traces all Lisp level functions by inserting a <code><a
- href="#$">$</a></code> function call at the beginning. <code>lst</code>
- may contain symbols which are to be excluded from that process. In addition, all
- symbols in the global variable <code>*NoTrace</code> are excluded. See also
- <code><a href="#trace">trace</a></code>, <code><a
- href="#untrace">untrace</a></code> and <code><a
- href="#*Dbg">*Dbg</a></code>.
- <pre><code>
- : (traceAll) # Trace all Lisp level functions
- -> balance
- </code></pre>
- <dt><a name="trail"><code>(trail ['flg]) -> lst</code></a>
- <dd>(64-bit version only) Returns a stack backtrace for the current point of
- program execution. The list elements are either list expressions (denoting
- function or method calls), or symbols followed by their corresponding values. If
- <code>flg</code> is <code>NIL</code>, the symbols and their values are omitted,
- and only the expressions are returned. See also <code><a
- href="#bt">bt</a></code>, <code><a
- href="#up">up</a></code> and <code><a
- href="#env">env</a></code>.
- <pre><code>
- : (de f (A B)
- (g (inc A) (dec B)) )
- -> f
- : (de g (X Y)
- (trail T) )
- -> g
- : (f 3 4)
- -> ((f 3 4) A 3 B 4 (g (inc A) (dec B)) X 4 Y 3)
- </code></pre>
- <dt><a name="tree"><code>(tree 'sym 'cls ['hook]) -> tree</code></a>
- <dd>Returns a data structure specifying a database index tree. <code>sym</code>
- and <code>cls</code> determine the relation, with an optional <code>hook</code>
- object. See also <code><a href="#root">root</a></code>, <code><a
- href="#fetch">fetch</a></code>, <code><a
- href="#store">store</a></code>, <code><a
- href="#count">count</a></code>, <code><a
- href="#leaf">leaf</a></code>, <code><a
- href="#minKey">minKey</a></code>, <code><a
- href="#maxKey">maxKey</a></code>, <code><a
- href="#init">init</a></code>, <code><a
- href="#step">step</a></code>, <code><a
- href="#scan">scan</a></code>, <code><a
- href="#iter">iter</a></code>, <code><a
- href="#prune">prune</a></code>, <code><a
- href="#zapTree">zapTree</a></code> and <code><a
- href="#chkTree">chkTree</a></code>.
- <pre><code>
- : (tree 'nm '+Item)
- -> (nm . +Item)
- </code></pre>
- <dt><a name="trim"><code>(trim 'lst) -> lst</code></a>
- <dd>Returns a copy of <code>lst</code> with all trailing whitespace characters
- or <code>NIL</code> elements removed. See also <code><a
- href="#clip">clip</a></code>.
- <pre><code>
- : (trim (1 NIL 2 NIL NIL))
- -> (1 NIL 2)
- : (trim '(a b " " " "))
- -> (a b)
- </code></pre>
- <dt><a name="true/0"><code>true/0</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that always succeeds. See also
- <code><a href="#fail/0">fail/0</a></code> and <code><a
- href="#repeat/0">repeat/0</a></code>.
- <pre><code>
- : (? (true))
- -> T
- </code></pre>
- <dt><a name="try"><code>(try 'msg 'obj ['any ..]) -> any</code></a>
- <dd>Tries to send the message <code>msg</code> to the object <code>obj</code>,
- optionally with arguments <code>any</code>. If <code>obj</code> is not an
- object, or if the message cannot be located in <code>obj</code>, in its classes
- or superclasses, <code>NIL</code> is returned. See also <a
- href="#oop">OO Concepts</a>, <code><a
- href="#send">send</a></code>, <code><a
- href="#method">method</a></code>, <code><a
- href="#meth">meth</a></code>, <code><a
- href="#super">super</a></code> and <code><a
- href="#extra">extra</a></code>.
- <pre><code>
- : (try 'msg> 123)
- -> NIL
- : (try 'html> 'a)
- -> NIL
- </code></pre>
- <dt><a name="type"><code>(type 'any) -> lst</code></a>
- <dd>Return the type (list of classes) of the object <code>sym</code>. See also
- <a href="#oop">OO Concepts</a>, <code><a
- href="#isa">isa</a></code>, <code><a
- href="#class">class</a></code>, <code><a
- href="#new">new</a></code> and <code><a
- href="#object">object</a></code>.
- <pre><code>
- : (type '{1A;3})
- (+Address)
- : (type '+DnButton)
- -> (+Tiny +Rid +JS +Able +Button)
- </code></pre>
- </dl>
- <h1><a name="U">U</a></h1>
- <dl>
- <dt><a name="*Uni"><code>*Uni</code></a>
- <dd>A global variable holding an <code><a href="#idx">idx</a></code>
- tree, with all unique data that were collected with the comma (<code>,</code>)
- read-macro. Typically used for localization. See also <code><a
- href="#macro-io">Read-Macros</a></code> and <code><a
- href="#locale">locale</a></code>.
- <pre><code>
- : (off *Uni) # Clear
- -> NIL
- : ,"abc" # Collect a transient symbol
- -> "abc"
- : ,(1 2 3) # Collect a list
- -> (1 2 3)
- : *Uni
- -> ("abc" NIL (1 2 3))
- </code></pre>
- <dt><a name="+UB"><code>+UB</code></a>
- <dd>Prefix class for <code><a href="#+Aux">+Aux</a></code> to maintain
- an UB-Tree index instead of the direct values. This allows efficient range
- access to multi-dimensional data. Only positive numeric keys are supported. See
- also <code><a href="#ubIter">ubIter</a></code> and <a
- href="#dbase">Database</a>.
- <pre><code>
- (class +Pos +Entity)
- (rel x (+UB +Aux +Ref +Number) (y z))
- (rel y (+Number))
- (rel z (+Number))
- : (scan (tree 'x '+Pos))
- (288362200753438306 . {13}) {13}
- (348187139486943716 . {16}) {16}
- (605261596962573238 . {11}) {11}
- (638523558602802506 . {7}) {7} # UBKEY of (453062 450921 613956)
- (654697989157410399 . {12}) {12}
- ...
- : (show '{7})
- {7} (+Pos)
- x 453062
- y 450921
- z 613956
- -> {7}
- # Discrete queries work the same way as without the +UB prefix
- : (db 'x '+Pos 453062 'y 450921 'z 613956)
- -> {7}
- : (aux 'x '+Pos 453062 450921 613956)
- -> {7}
- : (? (db x +Pos (453062 450921 613956) @Pos))
- @Pos={7}
- -> NIL
- # Range queries work efficiently with 'collect'. Note that though also Pilog
- queries can handle UB-trees, they may do so sub-optimally for certain ranges.
- : (collect 'x '+Pos (200000 200000 200000) (899999 899999 899999))
- -> ({7} {14} {17} {15})
- </code></pre>
- <dt><a name="u"><code>(u) -> T</code></a>
- <dd>(Debug mode only) Removes <code><a href="#!">!</a></code> all
- breakpoints in all subexpressions of the current breakpoint. Typically used when
- single-stepping a function or method with <code><a
- href="#debug">debug</a></code>. See also <code><a
- href="#d">d</a></code> and <code><a
- href="#unbug">unbug</a></code>.
- <pre><code>
- ! (u) # Unbug subexpression(s) at breakpoint
- -> T
- </code></pre>
- <dt><a name="ubIter"><code>(ubIter 'tree 'dim 'fun 'lst1 'lst2)</code></a>
- <dd>Efficiently iterates through a database <code><a
- href="#+UB">+UB</a></code> tree, by applying <code>fun</code> to all
- values. <code>dim</code> is the number of the key dimensions, <code>lst1</code>
- and <code>lst2</code> specify a range of keys. <code><a
- href="#collect">collect</a></code> uses <code>ubIter</code> internally
- for UB-tree queries. See also <code><a href="#iter">iter</a></code>.
- <pre><code>
- : (ubIter (tree 'x '+Pos) 3 show (200000 200000 200000) (899999 899999 899999))
- {7} (+Pos)
- z 613956
- y 450921
- x 453062
- {14} (+Pos)
- z 771372
- y 262217
- x 862358
- {17} (+Pos)
- z 676836
- y 529576
- x 398229
- {15} (+Pos)
- z 889332
- y 691799
- x 265381
- -> NIL
- </code></pre>
- <dt><a name="udp"><code>(udp 'any1 'any2 'any3) -> any</code></a>
- <dt><code>(udp 'cnt) -> any</code>
- <dd>Simple unidirectional sending/receiving of UDP packets. In the first form,
- <code>any3</code> is sent to a UDP server listening at host <code>any1</code>,
- port <code>any2</code>. In the second form, one item is received from a UDP
- socket <code>cnt</code>, established with <code><a
- href="#port">port</a></code>. See also <code><a
- href="#listen">listen</a></code> and <code><a
- href="#connect">connect</a></code>.
- <pre><code>
- # First session
- : (port T 6666)
- -> 3
- : (udp 3) # Receive a datagram
- # Second session (on the same machine)
- : (udp "localhost" 6666 '(a b c))
- -> (a b c)
- # First session
- -> (a b c)
- </code></pre>
- <dt><a name="ultimo"><code>(ultimo 'y 'm) -> cnt</code></a>
- <dd>Returns the <code><a href="#date">date</a></code> of the last day
- of the month <code>m</code> in the year <code>y</code>. See also <code><a
- href="#day">day</a></code> and <code><a
- href="#week">week</a></code>.
- <pre><code>
- : (date (ultimo 2007 1))
- -> (2007 1 31)
- : (date (ultimo 2007 2))
- -> (2007 2 28)
- : (date (ultimo 2004 2))
- -> (2004 2 29)
- : (date (ultimo 2000 2))
- -> (2000 2 29)
- : (date (ultimo 1900 2))
- -> (1900 2 28)
- </code></pre>
- <dt><a name="unbug"><code>(unbug 'sym) -> T</code></a>
- <dt><code>(unbug 'sym 'cls) -> T</code>
- <dt><code>(unbug '(sym . cls)) -> T</code>
- <dd>(Debug mode only) Removes all <code><a href="#!">!</a></code>
- breakpoints in the function or method body of sym, as inserted with <code><a
- href="#debug">debug</a></code> or <code><a
- href="#d">d</a></code>, or directly with <code><a
- href="#edit">edit</a></code>. See also <code><a
- href="#u">u</a></code>.
- <pre><code>
- : (pp 'tst)
- (de tst (N)
- (! println (+ 3 N)) ) # 'tst' has a breakpoint '!'
- -> tst
- : (unbug 'tst) # Unbug it
- -> T
- : (pp 'tst) # Restore
- (de tst (N)
- (println (+ 3 N)) )
- </code></pre>
- <dt><a name="undef"><code>(undef 'sym) -> fun</code></a>
- <dt><code>(undef 'sym 'cls) -> fun</code>
- <dt><code>(undef '(sym . cls)) -> fun</code>
- <dd>Undefines the function or method <code>sym</code>. Returns the previous
- definition. See also <code><a href="#de">de</a></code>, <code><a
- href="#dm">dm</a></code>, <code><a href="refD.html#def">def</a></code>
- and <code><a href="#redef">redef</a></code>.
- <pre><code>
- : (de hello () "Hello world!")
- -> hello
- : hello
- -> (NIL "Hello world!")
- : (undef 'hello)
- -> (NIL "Hello world!")
- : hello
- -> NIL
- </code></pre>
- <dt><a name="unify"><code>(unify 'any) -> lst</code></a>
- <dd>Unifies <code>any</code> with the current <a href="#pilog">Pilog</a>
- environment at the current level and with a value of <code>NIL</code>, and
- returns the new environment or <code>NIL</code> if not successful. See also
- <code><a href="#prove">prove</a></code> and <code><a
- href="#->">-></a></code>.
- <pre><code>
- : (? (^ @A (unify '(@B @C))))
- @A=(((NIL . @C) 0 . @C) ((NIL . @B) 0 . @B) T)
- </code></pre>
- <dt><a name="uniq"><code>(uniq 'lst) -> lst</code></a>
- <dd>Returns a unique list, by eliminating all duplicate elements from
- <code>lst</code>. See also <a href="#cmp">Comparing</a>, <code><a
- href="#sort">sort</a></code> and <code><a
- href="#group">group</a></code>.
- <pre><code>
- : (uniq (2 4 6 1 2 3 4 5 6 1 3 5))
- -> (2 4 6 1 3 5)
- </code></pre>
- <dt><a name="uniq/2"><code>uniq/2</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that succeeds if the second
- argument is not yet stored in the first argument's index structure. <code><a
- href="#idx">idx</a></code> is used internally storing for the values
- and checking for uniqueness. See also <code><a
- href="#member/2">member/2</a></code>.
- <pre><code>
- : (let U NIL
- (? (lst @X (a b c b c d)) (uniq U @X)) )
- @X=a
- @X=b
- @X=c
- @X=d
- -> NIL
- : (solve '((^ @B (box)) (lst @X (a b c b c d)) (uniq @B @X)) @X)
- -> (a b c d)
- </code></pre>
- <dt><a name="unless"><code>(unless 'any . prg) -> any</code></a>
- <dd>Conditional execution: When the condition <code>any</code> evaluates to
- non-<code>NIL</code>, <code>NIL</code> is returned. Otherwise <code>prg</code>
- is executed and the result returned. See also <code><a
- href="#when">when</a></code>.
- <pre><code>
- : (unless (= 3 3) (println 'Strange 'result))
- -> NIL
- : (unless (= 3 4) (println 'Strange 'result))
- Strange result
- -> result
- </code></pre>
- <dt><a name="until"><code>(until 'any . prg) -> any</code></a>
- <dd>Conditional loop: While the condition <code>any</code> evaluates to
- <code>NIL</code>, <code>prg</code> is repeatedly executed. If <code>prg</code>
- is never executed, <code>NIL</code> is returned. Otherwise the result of
- <code>prg</code> is returned. See also <code><a
- href="#while">while</a></code>.
- <pre><code>
- : (until (=T (setq N (read)))
- (println 'square (* N N)) )
- 4
- square 16
- 9
- square 81
- T
- -> 81
- </code></pre>
- <dt><a name="untrace"><code>(untrace 'sym) -> sym</code></a>
- <dt><code>(untrace 'sym 'cls) -> sym</code>
- <dt><code>(untrace '(sym . cls)) -> sym</code>
- <dd>(Debug mode only) Removes the <code><a href="#$">$</a></code> trace
- function call at the beginning of the function or method body of
- <code>sym</code>, so that no more trace information will be printed before and
- after execution. Built-in functions (C-function pointer) are automatically
- converted to their original form (see <code><a
- href="#subr">subr</a></code>). See also <code><a
- href="#trace">trace</a></code> and <code><a
- href="#traceAll">traceAll</a></code>.
- <pre><code>
- : (trace '+) # Trace the '+' function
- -> +
- : +
- -> (@ ($ + @ (pass $385455126))) # Modified for tracing
- : (untrace '+) # Untrace '+'
- -> +
- : +
- -> 67319120 # Back to original form
- </code></pre>
- <dt><a name="up"><code>(up [cnt] sym ['val]) -> any</code></a>
- <dd>Looks up (or modifies) the <code>cnt</code>'th previously saved value of
- <code>sym</code> in the corresponding enclosing environment. If <code>cnt</code>
- is not given, 1 is used. The 64-bit version also allows to omit the
- <code>sym</code> argument, then the corresponding expression (function or method
- call) is returned. See also <code><a href="#eval">eval</a></code>,
- <code><a href="#run">run</a></code>, <code><a
- href="#trail">trail</a></code> and <code><a
- href="#env">env</a></code>.
- <pre><code>
- : (let N 1 ((quote (N) (println N (up N))) 2))
- 2 1
- -> 1
- : (let N 1 ((quote (N) (println N (up N) (up N 7))) 2) N)
- 2 1 7
- -> 7
- : (de foo (N)
- (println (up)) # 64-bits only
- (inc N) )
- -> foo
- : (foo 7)
- (foo 7)
- -> 8
- </code></pre>
- <dt><a name="upd"><code>(upd sym ..) -> lst</code></a>
- <dd>Synchronizes the internal state of all passed (external) symbols by passing
- them to <code><a href="#wipe">wipe</a></code>. <code>upd</code> is the
- standard function passed to <code><a href="#commit">commit</a></code>
- during database <code><a href="#trans">transactions</a></code>.
- <pre><code>
- (commit 'upd) # Commit changes, informing all sister processes
- </code></pre>
- <dt><a name="update"><code>(update 'obj ['var]) -> obj</code></a>
- <dd>(Debug mode only) Interactive database function for modifying external
- symbols. When called only with an <code>obj</code> argument, <code>update</code>
- steps through the value and all properties of that object (and recursively also
- through substructures) and allows to edit them with the console line editor.
- When the <code>var</code> argument is given, only that single property is handed
- to the editor. To delete a property, <code>NIL</code> must be explicitly
- entered. <code>update</code> will correctly handle all <a
- href="#er">entity/relation</a> mechanisms. See also <code><a
- href="#select">select</a></code>, <code><a
- href="#edit">edit</a></code> and <a href="ref.html#dbase">Database</a>.
- <pre><code>
- : (show '{3-1}) # Show item 1
- {3-1} (+Item)
- nr 1
- pr 29900
- inv 100
- sup {2-1}
- nm "Main Part"
- -> {3-1}
- : (update '{3-1} 'pr) # Update the prices of that item
- {3-1} pr 299.00 # The cursor is right behind "299.00"
- -> {3-1}
- </code></pre>
- <dt><a name="upp?"><code>(upp? 'any) -> sym | NIL</code></a> <dd>Returns
- <code>any</code> when the argument is a string (symbol) that starts with an
- uppercase character. See also <code><a href="#uppc">uppc</a></code> and
- <code><a href="#low?">low?</a></code>
- <pre><code>
- : (upp? "A")
- -> "A"
- : (upp? "a")
- -> NIL
- : (upp? 123)
- -> NIL
- : (upp? ".")
- -> NIL
- </code></pre>
- <dt><a name="uppc"><code>(uppc 'any) -> any</code></a>
- <dd>Upper case conversion: If <code>any</code> is not a symbol, it is returned
- as it is. Otherwise, a new transient symbol with all characters of
- <code>any</code>, converted to upper case, is returned. See also <code><a
- href="#lowc">lowc</a></code>, <code><a
- href="#fold">fold</a></code> and <code><a
- href="#upp?">upp?</a></code>.
- <pre><code>
- : (uppc 123)
- -> 123
- : (uppc "abc")
- -> "ABC"
- : (uppc 'car)
- -> "CAR"
- </code></pre>
- <dt><a name="use"><code>(use sym . prg) -> any</code></a>
- <dt><code>(use (sym ..) . prg) -> any</code>
- <dd>Defines local variables. The value of the symbol <code>sym</code> - or the
- values of the symbols <code>sym</code> in the list of the second form - are
- saved, <code>prg</code> is executed, then the symbols are restored to their
- original values. During execution of <code>prg</code>, the values of the symbols
- can be temporarily modified. The return value is the result of <code>prg</code>.
- See also <code><a href="#bind">bind</a></code>, <code><a
- href="#job">job</a></code> and <code><a
- href="#let">let</a></code>.
- <pre><code>
- : (setq X 123 Y 456)
- -> 456
- : (use (X Y) (setq X 3 Y 4) (* X Y))
- -> 12
- : X
- -> 123
- : Y
- -> 456
- </code></pre>
- <dt><a name="useKey"><code>(useKey 'sym 'cls ['hook]) -> num</code></a>
- <dd>Generates or reuses a key for a database tree, by randomly trying to locate
- a free number. See also <code><a href="#genKey">genKey</a></code>.
- <pre><code>
- : (maxKey (tree 'nr '+Item))
- -> 8
- : (useKey 'nr '+Item)
- -> 12
- </code></pre>
- <dt><a name="usec"><code>(usec ['flg]) -> num</code></a>
- <dd>Returns a number of microseconds. If <code>flg</code> is
- non-<code>NIL</code>, the microsecond fraction of the last call to <code><a
- href="#time">time</a></code> is returned, otherwise the number of
- microseconds since interpreter startup. See also <code><a
- href="#date">date</a></code> and <code><a
- href="#tick">tick</a></code>.
- <pre><code>
- : (usec)
- -> 1154702479219050
- : (list (date (date)) (time (time T)) (usec T))
- -> ((2013 1 4) (10 12 39) 483321)
- </code></pre>
- </dl>
- <h1><a name="V">V</a></h1>
- <dl>
- <dt><a name="val"><code>(val 'var) -> any</code></a>
- <dd>Returns the current value of <code>var</code>. See also <code><a
- href="#setq">setq</a></code>, <code><a
- href="#set">set</a></code> and <code><a
- href="#def">def</a></code>.
- <pre><code>
- : (setq L '(a b c))
- -> (a b c)
- : (val 'L)
- -> (a b c)
- : (val (cdr L))
- -> b
- </code></pre>
- <dt><a name="val/3"><code>val/3</code></a>
- <dd><a href="#pilog">Pilog</a> predicate that returns the value of an
- object's attribute. Typically used in database queries. The first argument is a
- Pilog variable to bind the value, the second is the object, and the third and
- following arguments are used to apply the <code><a
- href="#get">get</a></code> algorithm to that object. See also <code><a
- href="#db/3">db/3</a></code> and <code><a
- href="#select/3">select/3</a></code>.
- <pre><code>
- : (?
- (db nr +Item (2 . 5) @Item) # Fetch articles 2 through 5
- (val @Nm @Item nm) # Get item description
- (val @Sup @Item sup nm) ) # and supplier's name
- @Item={3-2} @Nm="Spare Part" @Sup="Seven Oaks Ltd."
- @Item={3-3} @Nm="Auxiliary Construction" @Sup="Active Parts Inc."
- @Item={3-4} @Nm="Enhancement Additive" @Sup="Seven Oaks Ltd."
- @Item={3-5} @Nm="Metal Fittings" @Sup="Active Parts Inc."
- -> NIL
- </code></pre>
- <dt><a name="var"><code>(var sym . any) -> any</code></a>
- <dt><code>(var (sym . cls) . any) -> any</code>
- <dd>Defines a class variable <code>sym</code> with the initial value
- <code>any</code> for the current class, implicitly given by the value of the
- global variable <code><a href="#*Class">*Class</a></code>, or - in the
- second form - for the explicitly given class cls. See also <a
- href="#oop">OO Concepts</a>, <code><a
- href="#rel">rel</a></code> and <code><a
- href="#var:">var:</a></code>.
- <pre><code>
- : (class +A)
- -> +A
- : (var a . 1)
- -> 1
- : (var b . 2)
- -> 2
- : (show '+A)
- +A NIL
- b 2
- a 1
- -> +A
- </code></pre>
- <dt><a name="var:"><code>(var: sym) -> any</code></a>
- <dd>Fetches the value of a class variable <code>sym</code> for the current
- object <code><a href="#This">This</a></code>, by searching the property
- lists of its class(es) and supperclasses. See also <a href="#oop">OO
- Concepts</a>, <code><a href="#var">var</a></code>, <code><a
- href="#with">with</a></code>, <code><a
- href="#meta">meta</a></code>, <code><a href="ref_.html#:">:</a></code>,
- <code><a href="#=:">=:</a></code> and <code><a
- href="#::">::</a></code>.
- <pre><code>
- : (class +A)
- -> +A
- : (var a . 1)
- -> 1
- : (var b . 2)
- -> 2
- : (object 'O '(+A) 'a 9 'b 8)
- -> O
- : (with 'O (list (: a) (: b) (var: a) (var: b)))
- -> (9 8 1 2)
- </code></pre>
- <dt><a name="version"><code>(version ['flg]) -> lst</code></a>
- <dd>Prints the current version as a string of dot-separated numbers, and returns
- the current version as a list of numbers. The JVM- and C-versions print an
- additional "JVM" or "C", respectively, separated by a space. When
- <code>flg</code> is non-NIL, printing is suppressed. See also <code><a
- href="#*CPU">*CPU</a></code> and <code><a
- href="#*OS">*OS</a></code>.
- <pre><code>
- $ pil -version
- 3.0.1.22
- : (version T)
- -> (3 0 1 22)
- </code></pre>
- <dt><a name="vi"><code>(vi 'sym) -> sym</code></a>
- <dt><code>(vi 'sym 'cls) -> sym</code>
- <dt><code>(vi '(sym . cls)) -> sym</code>
- <dt><code>(vi) -> NIL</code>
- <dd>(Debug mode only) Opens the "vi" editor on the function or method definition
- of <code>sym</code>. A call to <code><a href="#ld">ld</a></code>
- thereafter will <code><a href="#load">load</a></code> the modified
- file. A call without arguments permanently switches the REPL line editor and the
- <code><a href="#edit">edit</a></code> function to "vi" mode. See also
- <code><a href="#doc">doc</a></code>, <code><a
- href="#edit">edit</a></code>, <code><a
- href="#em">em</a></code>, <code><a
- href="#*Dbg">*Dbg</a></code>, <code><a
- href="#debug">debug</a></code> and <code><a
- href="#pp">pp</a></code>.
- <pre><code>
- : (vi 'url> '+CuSu) # Edit the method's source code, then exit from 'vi'
- -> T
- </code></pre>
- <dt><a name="view"><code>(view 'lst ['T]) -> any</code></a>
- <dd>Views <code>lst</code> as tree-structured ASCII graphics. When the
- <code>T</code> argument is given, <code>lst</code> should be a binary tree
- structure (as generated by <code><a href="#idx">idx</a></code>), which
- is then shown as a left-rotated tree. See also <code><a
- href="#pretty">pretty</a></code> and <code><a
- href="#show">show</a></code>.
- <pre><code>
- : (balance 'I '(a b c d e f g h i j k l m n o))
- -> NIL
- : I
- -> (h (d (b (a) c) f (e) g) l (j (i) k) n (m) o)
- : (view I)
- +-- h
- |
- +---+-- d
- | |
- | +---+-- b
- | | |
- | | +---+-- a
- | | |
- | | +-- c
- | |
- | +-- f
- | |
- | +---+-- e
- | |
- | +-- g
- |
- +-- l
- |
- +---+-- j
- | |
- | +---+-- i
- | |
- | +-- k
- |
- +-- n
- |
- +---+-- m
- |
- +-- o
- -> NIL
- : (view I T)
- o
- n
- m
- l
- k
- j
- i
- h
- g
- f
- e
- d
- c
- b
- a
- -> NIL
- </code></pre>
- </dl>
- <h1><a name="W">W</a></h1>
- <dl>
- <dt><a name="wait"><code>(wait ['cnt] . prg) -> any</code></a>
- <dd>Waits for a condition. While the result of the execution of <code>prg</code>
- is <code>NIL</code>, a <code>select</code> system call is executed for all file
- descriptors and timers in the <code>VAL</code> of the global variable <code><a
- href="#*Run">*Run</a></code>. When <code>cnt</code> is
- non-<code>NIL</code>, the waiting time is limited to <code>cnt</code>
- milliseconds. Returns the result of <code>prg</code>. See also <code><a
- href="#key">key</a></code> and <code><a
- href="#sync">sync</a></code>.
- <pre><code>
- : (wait 2000) # Wait 2 seconds
- -> NIL
- : (prog
- (zero *Cnt)
- (setq *Run # Install background loop
- '((-2000 0 (println (inc '*Cnt)))) ) # Increment '*Cnt' every 2 sec
- (wait NIL (> *Cnt 6)) # Wait until > 6
- (off *Run) )
- 1 # Waiting ..
- 2
- 3
- 4
- 5
- 6
- 7
- -> NIL
- </code></pre>
- <dt><a name="week"><code>(week 'dat) -> num</code></a>
- <dd>Returns the number of the week for a given <code><a
- href="#date">date</a></code> <code>dat</code>. See also <code><a
- href="#day">day</a></code>, <code><a
- href="#ultimo">ultimo</a></code>, <code><a
- href="#datStr">datStr</a></code> and <code><a
- href="#strDat">strDat</a></code>.
- <pre><code>
- : (datStr (date))
- -> "2007-06-01"
- : (week (date))
- -> 22
- </code></pre>
- <dt><a name="when"><code>(when 'any . prg) -> any</code></a>
- <dd>Conditional execution: When the condition <code>any</code> evaluates to
- non-<code>NIL</code>, <code>prg</code> is executed and the result is returned.
- Otherwise <code>NIL</code> is returned. See also <code><a
- href="#unless">unless</a></code>.
- <pre><code>
- : (when (> 4 3) (println 'OK) (println 'Good))
- OK
- Good
- -> Good
- </code></pre>
- <dt><a name="while"><code>(while 'any . prg) -> any</code></a>
- <dd>Conditional loop: While the condition <code>any</code> evaluates to
- non-<code>NIL</code>, <code>prg</code> is repeatedly executed. If
- <code>prg</code> is never executed, <code>NIL</code> is returned. Otherwise the
- result of <code>prg</code> is returned. See also <code><a
- href="#until">until</a></code>.
- <pre><code>
- : (while (read)
- (println 'got: @) )
- abc
- got: abc
- 1234
- got: 1234
- NIL
- -> 1234
- </code></pre>
- <dt><a name="what"><code>(what 'sym) -> lst</code></a>
- <dd>(Debug mode only) Returns a list of all internal symbols that match the
- pattern string <code>sym</code>. See also <code><a
- href="#match">match</a></code>, <code><a
- href="#who">who</a></code>, <code><a
- href="#has">has</a></code> and <code><a
- href="#can">can</a></code>.
- <pre><code>
- : (what "cd@dr")
- -> (cdaddr cdaadr cddr cddddr cdddr cddadr cdadr)
- </code></pre>
- <dt><a name="who"><code>(who 'any) -> lst</code></a>
- <dd>(Debug mode only) Returns a list of all functions or method definitions that
- contain the atom or pattern <code>any</code>. See also <code><a
- href="#match">match</a></code>, <code><a
- href="#what">what</a></code>, <code><a
- href="#has">has</a></code> and <code><a
- href="#can">can</a></code>.
- <pre><code>
- : (who 'caddr) # Who is using 'caddr'?
- -> ($dat lint1 expDat datStr $tim tim$ mail _gen dat$ datSym)
- : (who "Type error")
- -> ((mis> . +Link) *Uni (mis> . +Joint))
- : (more (who "Type error") pp) # Pretty print all results
- (dm (mis> . +Link) (Val Obj)
- (and
- Val
- (nor (isa (: type) Val) (canQuery Val))
- "Type error" ) )
- . # Stop
- -> T
- </code></pre>
- <dt><a name="wipe"><code>(wipe 'sym|lst) -> sym|lst</code></a>
- <dd>Clears the <code>VAL</code> and the property list of <code>sym</code>, or of
- all symbols in the list <code>lst</code>. When a symbol is an external symbol,
- its state is also set to "not loaded". Does nothing when <code>sym</code> is an
- external symbol that has been modified or deleted ("dirty").
- <pre><code>
- : (setq A (1 2 3 4))
- -> (1 2 3 4)
- : (put 'A 'a 1)
- -> 1
- : (put 'A 'b 2)
- -> 2
- : (show 'A)
- A (1 2 3 4)
- b 2
- a 1
- -> A
- : (wipe 'A)
- -> A
- : (show 'A)
- A NIL
- -> A
- </code></pre>
- <dt><a name="with"><code>(with 'sym . prg) -> any</code></a>
- <dd>Saves the current object <code>This</code> and sets it to the new value
- <code>sym</code>. Then <code>prg</code> is executed, and <code>This</code> is
- restored to its previous value. The return value is the result of
- <code>prg</code>. Used typically to access the local data of <code>sym</code> in
- the same manner as inside a method body. <code>prg</code> is not executed (and
- <code>NIL</code> is returned) when <code>sym</code> is <code>NIL</code>.
- <code>(with 'X . prg)</code> is equivalent to <code>(let? This 'X . prg)</code>.
- <pre><code>
- : (put 'X 'a 1)
- -> 1
- : (put 'X 'b 2)
- -> 2
- : (with 'X (list (: a) (: b)))
- -> (1 2)
- </code></pre>
- <dt><a name="wr"><code>(wr 'cnt ..) -> cnt</code></a>
- <dd>Writes all <code>cnt</code> arguments as raw bytes to the current output
- channel. See also <code><a href="#rd">rd</a></code> and <code><a
- href="#pr">pr</a></code>.
- <pre><code>
- : (out "x" (wr 1 255 257)) # Write to "x"
- -> 257
- : (hd "x")
- 00000000 01 FF 01 ...
- -> NIL
- </code></pre>
- <dt><a name="wrap"><code>(wrap 'cnt 'lst) -> sym</code></a>
- <dd>Returns a transient symbol with all characters in <code>lst</code> <code><a
- href="#pack">pack</a></code>ed in lines with a maximal length of
- <code>cnt</code>. See also <code><a href="#tab">tab</a></code>,
- <code><a href="#align">align</a></code> and <code><a
- href="#center">center</a></code>.
- <pre><code>
- : (wrap 20 (chop "The quick brown fox jumps over the lazy dog"))
- -> "The quick brown fox^Jjumps over the lazy^Jdog"
- : (wrap 8 (chop "The quick brown fox jumps over the lazy dog"))
- -> "The^Jquick^Jbrown^Jfox^Jjumps^Jover the^Jlazy dog"
- </code></pre>
- </dl>
- <h1><a name="X">X</a></h1>
- <dl>
- <dt><a name="xchg"><code>(xchg 'var 'var ..) -> any</code></a>
- <dd>Exchange the values of successive <code>var</code> argument pairs. See also
- <code><a href="#swap">swap</a></code> and <code><a
- href="#set">set</a></code>.
- <pre><code>
- : (setq A 1 B 2 C '(a b c))
- -> (a b c)
- : (xchg 'A C 'B (cdr C))
- -> 2
- : A
- -> a
- : B
- -> b
- : C
- -> (1 2 c)
- </code></pre>
- <dt><a name="xor"><code>(xor 'any 'any) -> flg</code></a>
- <dd>Returns T if exactly one of the arguments evaluates to non-<code>NIL</code>.
- <pre><code>
- : (xor T NIL)
- -> T
- : (xor T T)
- -> NIL
- </code></pre>
- <dt><a name="x|"><code>(x| 'num ..) -> num</code></a>
- <dd>Returns the bitwise <code>XOR</code> of all <code>num</code> arguments. When
- one of the arguments evaluates to <code>NIL</code>, it is returned immediately.
- See also <code><a href="#&">&</a></code>, <code><a
- href="#|">|</a></code> and <code><a
- href="#bit?">bit?</a></code>.
- <pre><code>
- : (x| 2 7)
- -> 5
- : (x| 2 7 1)
- -> 4
- </code></pre>
- </dl>
- <h1><a name="Y">Y</a></h1>
- <dl>
- <dt><a name="yield"><code>(yield 'any ['sym]) -> any</code></a>
- <dd>(64-bit version only) Transfers control from the current <a
- href="#coroutines">coroutine</a> back to the caller (when the
- <code>sym</code> tag is not given), or to some other coroutine (specified by
- <code>sym</code>) to continue execution at the point where that coroutine had
- called <code>yield</code> before. In the first case, the value <code>any</code>
- will be returned from the corresponding <code><a
- href="#co">co</a></code> call, in the second case it will be the return
- value of that <code>yield</code> call. See also <code><a
- href="#stack">stack</a></code>, <code><a
- href="#catch">catch</a></code> and <code><a
- href="#throw">throw</a></code>.
- <pre><code>
- : (co "rt1" # Start first routine
- (msg (yield 1) " in rt1 from rt2") # Return '1', wait for value from "rt2"
- 7 ) # Then return '7'
- -> 1
- : (co "rt2" # Start second routine
- (yield 2 "rt1") ) # Send '2' to "rt1"
- 2 in rt1 from rt2
- -> 7
- </code></pre>
- <dt><a name="yoke"><code>(yoke 'any ..) -> any</code></a>
- <dd>Inserts one or several new elements <code>any</code> in front of the list in
- the current <code><a href="#make">make</a></code> environment.
- <code>yoke</code> returns the last inserted argument. See also <code><a
- href="#link">link</a></code>, <code><a
- href="#chain">chain</a></code> and <code><a
- href="#made">made</a></code>.
- <pre><code>
- : (make (link 2 3) (yoke 1) (link 4))
- -> (1 2 3 4)
- </code></pre>
- </dl>
- <h1><a name="Z">Z</a></h1>
- <dl>
- <dt><a name="*Zap"><code>*Zap</code></a>
- <dd>A global variable holding a list and a pathname. If given, and the value of
- <code><a href="#*Solo">*Solo</a></code> is <code>NIL</code>, external
- symbols which are no longer accessible can be collected in the CAR, e.g. during
- DB tree processing, and written to the file in the CDR at the next <code><a
- href="#commit">commit</a></code>. A (typically periodic) call to
- <code><a href="#zap_">zap_</a></code> will clean them up later.
- <pre><code>
- : (setq *Zap '(NIL . "db/app/_zap"))
- -> "db/app/_zap"
- </code></pre>
- <dt><a name="zap"><code>(zap 'sym) -> sym</code></a>
- <dd>"Delete" the symbol <code>sym</code>. For internal symbols, that means to
- remove it from the internal index, effectively transforming it to a transient
- symbol. For external symbols, it means to mark it as "deleted", so that upon a
- later <code><a href="#commit">commit</a></code> it will be removed from
- the database file. See also <code><a href="#intern">intern</a></code>.
- <pre><code>
- : (de foo (Lst) (car Lst)) # 'foo' calls 'car'
- -> foo
- : (zap 'car) # Delete the symbol 'car'
- -> "car"
- : (pp 'foo)
- (de foo (Lst)
- ("car" Lst) ) # 'car' is now a transient symbol
- -> foo
- : (foo (1 2 3)) # 'foo' still works
- -> 1
- : (car (1 2 3)) # Reader returns a new 'car' symbol
- !? (car (1 2 3))
- car -- Undefined
- ?
- </code></pre>
- <dt><a name="zapTree"><code>(zapTree 'sym)</code></a>
- <dd>Recursively deletes a tree structure from the database. See also <code><a
- href="#tree">tree</a></code>, <code><a
- href="#chkTree">chkTree</a></code> and <code><a
- href="#prune">prune</a></code>.
- <pre><code>
- : (zapTree (cdr (root (tree 'nm '+Item))))
- </code></pre>
- <dt><a name="zap_"><code>(zap_)</code></a>
- <dd>Delayed deletion (with <code><a href="#zap">zap</a></code>) of
- external symbols which were collected e.g. during DB tree processing. An
- auxiliary file (with the name taken from the CDR of the value of <code><a
- href="#*Zap">*Zap</a></code>, concatenated with a "<code>_</code>"
- character) is used as an intermediary file.
- <pre><code>
- : *Zap
- -> (NIL . "db/app/Z")
- : (call 'ls "-l" "db/app")
- ...
- -rw-r--r-- 1 abu abu 1536 2007-06-23 12:34 Z
- -rw-r--r-- 1 abu abu 1280 2007-05-23 12:15 Z_
- ...
- : (zap_)
- ...
- : (call 'ls "-l" "db/app")
- ...
- -rw-r--r-- 1 abu abu 1536 2007-06-23 12:34 Z_
- ...
- </code></pre>
- <dt><a name="zero"><code>(zero var ..) -> 0</code></a>
- <dd>Stores <code>0</code> in all <code>var</code> arguments. See also <code><a
- href="#one">one</a></code>, <code><a href="refO.html#on">on</a></code>,
- <code><a href="#off">off</a></code> and <code><a
- href="#onOff">onOff</a></code>.
- <pre><code>
- : (zero A B)
- -> 0
- : A
- -> 0
- : B
- -> 0
- </code></pre>
- </dl>
Add Comment
Please, Sign In to add comment