picolisp

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/picolisp.git/
Log | Files | Refs | README | LICENSE

refA.html (20863B)


      1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/1998/REC-html40-19980424/loose.dtd">
      2 <html lang="en">
      3 <head>
      4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      5 <title>A</title>
      6 <link rel="stylesheet" href="doc.css" type="text/css">
      7 </head>
      8 <body>
      9 
     10 <h1>A</h1>
     11 
     12 <dl>
     13 
     14 <dt><a name="*Adr"><code>*Adr</code></a>
     15 <dd>A global variable holding the IP address of last recently accepted client.
     16 See also <code><a href="refL.html#listen">listen</a></code> and <code><a
     17 href="refA.html#accept">accept</a></code>.
     18 
     19 <pre><code>
     20 : *Adr
     21 -> "127.0.0.1"
     22 </code></pre>
     23 
     24 <dt><a name="adr"><code>(adr 'var) -> num</code></a>
     25 <dt><code>(adr 'num) -> var</code>
     26 <dd>Converts, in the first form, a variable <code>var</code> (a symbol or a cons
     27 pair) into <code>num</code> (actually an encoded pointer). A symbol will result
     28 in a negative number, and a cons pair in a positive number. The second form
     29 converts a pointer back into the original <code>var</code>.
     30 
     31 <pre><code>
     32 : (setq X (box 7))
     33 -> $53063416137450
     34 : (adr X)
     35 -> -2961853431592
     36 : (adr @)
     37 -> $53063416137450
     38 : (val @)
     39 -> 7
     40 </code></pre>
     41 
     42 <dt><a name="*Allow"><code>*Allow</code></a>
     43 <dd>A global variable holding allowed access patterns. If its value is
     44 non-<code>NIL</code>, it should contain a list where the CAR is an <code><a
     45 href="refI.html#idx">idx</a></code> tree of allowed items, and the CDR a list of
     46 prefix strings. See also <code><a href="refA.html#allow">allow</a></code>,
     47 <code><a href="refA.html#allowed">allowed</a></code> and <code><a
     48 href="refP.html#pre?">pre?</a></code>.
     49 
     50 <pre><code>
     51 : (allowed ("app/")  # Initialize
     52    "!start" "!stop" "lib.css" "!psh" )
     53 -> NIL
     54 : (allow "!myFoo")  # additional item
     55 -> "!myFoo"
     56 : (allow "myDir/" T)  # additional prefix
     57 -> "myDir/"
     58 
     59 : *Allow
     60 -> (("!start" ("!psh" ("!myFoo")) "!stop" NIL "lib.css") "app/" "myDir/")
     61 
     62 : (idx *Allow)  # items
     63 -> ("!myFoo" "!psh" "!start" "!stop" "lib.css")
     64 : (cdr *Allow)  # prefixes
     65 -> ("app/" "myDir/")
     66 </code></pre>
     67 
     68 <dt><a name="+Alt"><code>+Alt</code></a>
     69 <dd>Prefix class specifying an alternative class for a <code><a
     70 href="refR.html#+relation">+relation</a></code>. This allows indexes or other
     71 side effects to be maintained in a class different from the current one. See
     72 also <a href="ref.html#dbase">Database</a>.
     73 
     74 <pre><code>
     75 (class +EuOrd +Ord)                    # EU-specific order subclass
     76 (rel nr (+Alt +Key +Number) +XyOrd)    # Maintain the key in the +XyOrd index
     77 </code></pre>
     78 
     79 <dt><a name="+Any"><code>+Any</code></a>
     80 <dd>Class for unspecified relations, a subclass of <code><a
     81 href="refR.html#+relation">+relation</a></code>. Objects of that class accept
     82 and maintain any type of Lisp data. Used often when there is no other suitable
     83 relation class available. See also <a href="ref.html#dbase">Database</a>.
     84 
     85 <p>In the following example <code>+Any</code> is used simply for the reason that
     86 there is no direct way to specify dotted pairs:
     87 
     88 <pre><code>
     89 (rel loc (+Any))  # Locale, e.g. ("DE" . "de")
     90 </code></pre>
     91 
     92 <dt><a name="+Aux"><code>+Aux</code></a>
     93 <dd>Prefix class maintaining auxiliary keys for <code><a
     94 href="refR.html#+relation">+relation</a></code>s, in addition to <code><a
     95 href="refR.html#+Ref">+Ref</a></code> or <code><a
     96 href="refI.html#+Idx">+Idx</a></code> indexes. Expects a list of auxiliary
     97 attributes of the same object, and combines all keys in that order into a single
     98 index key. See also <code><a href="refU.html#+UB">+UB</a></code>, <code><a
     99 href="refA.html#aux">aux</a></code> and <a href="ref.html#dbase">Database</a>.
    100 
    101 <pre><code>
    102 (rel nr (+Ref +Number))                # Normal, non-unique index
    103 (rel nm (+Aux +Ref +String) (nr txt))  # Combined name/number/text index
    104 (rel txt (+Aux +Sn +Idx +String) (nr)) # Text/number plus tolerant text index
    105 </code></pre>
    106 
    107 <dt><a name="abort"><code>(abort 'cnt . prg) -> any</code></a>
    108 <dd>Aborts the execution of <code>prg</code> if it takes longer than
    109 <code>cnt</code> seconds, and returns <code>NIL</code>. Otherwise, the result of
    110 <code>prg</code> is returned. <code><a href="refA.html#alarm">alarm</a></code>
    111 is used internally, so care must be taken not to interfer with other calls to
    112 <code>alarm</code>.
    113 
    114 <pre><code>
    115 : (abort 20 (in Sock (rd)))  # Wait maximally 20 seconds for socket data
    116 </code></pre>
    117 
    118 <dt><a name="abs"><code>(abs 'num) -> num</code></a>
    119 <dd>Returns the absolute value of the <code>num</code> argument.
    120 
    121 <pre><code>
    122 : (abs -7)
    123 -> 7
    124 : (abs 7)
    125 -> 7
    126 </code></pre>
    127 
    128 <dt><a name="accept"><code>(accept 'cnt) -> cnt | NIL</code></a>
    129 <dd>Accepts a connection on descriptor <code>cnt</code> (as received by <code><a
    130 href="refP.html#port">port</a></code>), and returns the new socket descriptor
    131 <code>cnt</code>. The global variable <code>*Adr</code> is set to the IP address
    132 of the client. See also <code><a href="refL.html#listen">listen</a></code>,
    133 <code><a href="refC.html#connect">connect</a></code> and <code><a
    134 href="refA.html#*Adr">*Adr</a></code>.
    135 
    136 <pre><code>
    137 : (setq *Socket
    138    (accept (port 6789)) )  # Accept connection at port 6789
    139 -> 4
    140 </code></pre>
    141 
    142 <dt><a name="accu"><code>(accu 'var 'any 'num)</code></a>
    143 <dd>Accumulates <code>num</code> into a sum, using the key <code>any</code> in
    144 an association list stored in <code>var</code>. See also <code><a
    145 href="refA.html#assoc">assoc</a></code>.
    146 
    147 <pre><code>
    148 : (off Sum)
    149 -> NIL
    150 : (accu 'Sum 'a 1)
    151 -> (a . 1)
    152 : (accu 'Sum 'a 5)
    153 -> 6
    154 : (accu 'Sum 22 100)
    155 -> (22 . 100)
    156 : Sum
    157 -> ((22 . 100) (a . 6))
    158 </code></pre>
    159 
    160 <dt><a name="acquire"><code>(acquire 'sym) -> flg</code></a>
    161 <dd>Tries to acquire the mutex represented by the file <code>sym</code>, by
    162 obtaining an exclusive lock on that file with <code><a
    163 href="refC.html#ctl">ctl</a></code>, and then trying to write the PID of the
    164 current process into that file. It fails if the file already holds the PID of
    165 some other existing process. See also <code><a
    166 href="refR.html#release">release</a></code>, <code><a
    167 href="refP.html#*Pid">*Pid</a></code> and <code><a
    168 href="refR.html#rc">rc</a></code>.
    169 
    170 <pre><code>
    171 : (acquire "sema1")
    172 -> 28255
    173 </code></pre>
    174 
    175 <dt><a name="alarm"><code>(alarm 'cnt . prg) -> cnt</code></a>
    176 <dd>Sets an alarm timer scheduling <code>prg</code> to be executed after
    177 <code>cnt</code> seconds, and returns the number of seconds remaining until any
    178 previously scheduled alarm was due to be delivered. Calling <code>(alarm
    179 0)</code> will cancel an alarm. See also <code><a
    180 href="refA.html#abort">abort</a></code>, <code><a
    181 href="refS.html#sigio">sigio</a></code>, <code><a
    182 href="refH.html#*Hup">*Hup</a></code> and <code><a
    183 href="refS.html#*Sig1">*Sig[12]</a></code>.
    184 
    185 <pre><code>
    186 : (prinl (tim$ (time) T)) (alarm 10 (prinl (tim$ (time) T)))
    187 16:36:14
    188 -> 0
    189 : 16:36:24
    190 
    191 : (alarm 10 (bye 0))
    192 -> 0
    193 $
    194 </code></pre>
    195 
    196 <dt><a name="align"><code>(align 'cnt 'any) -> sym</code></a>
    197 <dt><code>(align 'lst 'any ..) -> sym</code>
    198 <dd>Returns a transient symbol with all <code>any</code> arguments <code><a
    199 href="refP.html#pack">pack</a></code>ed in an aligned format. In the first form,
    200 <code>any</code> will be left-aligned if <code>cnt</code> ist negative,
    201 otherwise right-aligned. In the second form, all <code>any</code> arguments are
    202 packed according to the numbers in <code>lst</code>. See also <code><a
    203 href="refT.html#tab">tab</a></code>, <code><a
    204 href="refC.html#center">center</a></code> and <code><a
    205 href="refW.html#wrap">wrap</a></code>.
    206 
    207 <pre><code>
    208 : (align 4 "a")
    209 -> "   a"
    210 : (align -4 12)
    211 -> "12  "
    212 : (align (4 4 4) "a" 12 "b")
    213 -> "   a  12   b"
    214 </code></pre>
    215 
    216 <dt><a name="all"><code>(all ['T | '0]) -> lst</code></a>
    217 <dd>Returns a new list of all <a href="ref.html#internal">internal</a> symbols
    218 in the system (if called without arguments, or with <code>NIL</code>). Otherwise
    219 (if the argument is <code>T</code>), all current <a
    220 href="ref.html#transient">transient</a> symbols are returned. Else all current
    221 <a href="ref.html#external">external</a> symbols are returned.
    222 
    223 <pre><code>
    224 : (all)  # All internal symbols
    225 -> (inc> leaf nil inc! accept ...
    226 
    227 # Find all symbols starting with an underscore character
    228 : (filter '((X) (= "_" (car (chop X)))) (all))
    229 -> (_put _nacs _oct _lintq _lst _map _iter _dbg2 _getLine _led ...
    230 </code></pre>
    231 
    232 <dt><a name="allow"><code>(allow 'sym ['flg]) -> sym</code></a>
    233 <dd>Maintains an index structure of allowed access patterns in the global
    234 variable <code><a href="refA.html#*Allow">*Allow</a></code>. If the value of
    235 <code>*Allow</code> is non-<code>NIL</code>, <code>sym</code> is added to the
    236 <code><a href="refI.html#idx">idx</a></code> tree in the CAR of
    237 <code>*Allow</code> (if <code>flg</code> is <code>NIL</code>), or to the list of
    238 prefix strings (if <code>flg</code> is non-<code>NIL</code>). See also <code><a
    239 href="refA.html#allowed">allowed</a></code>.
    240 
    241 <pre><code>
    242 : *Allow
    243 -> (("!start" ("!psh") "!stop" NIL "lib.css") "app/")
    244 : (allow "!myFoo")  # additionally allowed item
    245 -> "!myFoo"
    246 : (allow "myDir/" T)  # additionally allowed prefix
    247 -> "myDir/"
    248 </code></pre>
    249 
    250 <dt><a name="allowed"><code>(allowed lst [sym ..])</code></a>
    251 <dd>Creates an index structure of allowed access patterns in the global variable
    252 <code><a href="refA.html#*Allow">*Allow</a></code>. <code>lst</code> should
    253 consist of prefix strings (to be checked at runtime with <code><a
    254 href="refP.html#pre?">pre?</a></code>), and the <code>sym</code> arguments
    255 should specify the initially allowed items. See also <code><a
    256 href="refA.html#allow">allow</a></code>.
    257 
    258 <pre><code>
    259 : (allowed ("app/")  # allowed prefixes
    260    "!start" "!stop" "lib.css" "!psh" )  # allowed items
    261 -> NIL
    262 </code></pre>
    263 
    264 <dt><a name="and"><code>(and 'any ..) -> any</code></a>
    265 <dd>Logical AND. The expressions <code>any</code> are evaluated from left to
    266 right. If <code>NIL</code> is encountered, <code>NIL</code> is returned
    267 immediately. Else the result of the last expression is returned.
    268 
    269 <pre><code>
    270 : (and (= 3 3) (read))
    271 abc  # User input
    272 -> abc
    273 : (and (= 3 4) (read))
    274 -> NIL
    275 </code></pre>
    276 
    277 <dt><a name="any"><code>(any 'sym) -> any</code></a>
    278 <dd>Parses <code>any</code> from the name of <code>sym</code>. This is the
    279 reverse operation of <code><a href="refS.html#sym">sym</a></code>. See also
    280 <code><a href="refS.html#str">str</a></code>.
    281 
    282 <pre><code>
    283 : (any "(a b # Comment^Jc d)")
    284 -> (a b c d)
    285 : (any "\"A String\"")
    286 -> "A String"
    287 </code></pre>
    288 
    289 <dt><a name="append"><code>(append 'lst ..) -> lst</code></a>
    290 <dd>Appends all argument lists. See also <code><a
    291 href="refC.html#conc">conc</a></code>, <code><a
    292 href="refI.html#insert">insert</a></code>, <code><a
    293 href="refD.html#delete">delete</a></code> and <code><a
    294 href="refR.html#remove">remove</a></code>.
    295 
    296 <pre><code>
    297 : (append '(a b c) (1 2 3))
    298 -> (a b c 1 2 3)
    299 : (append (1) (2) (3) 4)
    300 -> (1 2 3 . 4)
    301 </code></pre>
    302 
    303 <dt><a name="append/3"><code>append/3</code></a>
    304 <dd><a href="ref.html#pilog">Pilog</a> predicate that succeeds if appending the
    305 first two list arguments is equal to the third argument. See also <code><a
    306 href="refA.html#append">append</a></code> and <code><a
    307 href="refM.html#member/2">member/2</a></code>.
    308 
    309 <pre><code>
    310 : (? (append @X @Y (a b c)))
    311  @X=NIL @Y=(a b c)
    312  @X=(a) @Y=(b c)
    313  @X=(a b) @Y=(c)
    314  @X=(a b c) @Y=NIL
    315 -> NIL
    316 </code></pre>
    317 
    318 <dt><a name="apply"><code>(apply 'fun 'lst ['any ..]) -> any</code></a>
    319 <dd>Applies <code>fun</code> to <code>lst</code>. If additional <code>any</code>
    320 arguments are given, they are applied as leading elements of <code>lst</code>.
    321 <code>(apply 'fun 'lst 'any1 'any2)</code> is equivalent to <code>(apply 'fun
    322 (cons 'any1 'any2 'lst))</code>.
    323 
    324 <pre><code>
    325 : (apply + (1 2 3))
    326 -> 6
    327 : (apply * (5 6) 3 4)
    328 -> 360
    329 : (apply '((X Y Z) (* X (+ Y Z))) (3 4 5))
    330 -> 27
    331 : (apply println (3 4) 1 2)
    332 1 2 3 4
    333 -> 4
    334 </code></pre>
    335 
    336 <dt><a name="arg"><code>(arg ['cnt]) -> any</code></a>
    337 <dd>Can only be used inside functions with a variable number of arguments (with
    338 <code>@</code>). If <code>cnt</code> is not given, the value that was returned
    339 from the last call to <code>next</code>) is returned. Otherwise, the
    340 <code>cnt</code>'th remaining argument is returned. See also <code><a
    341 href="refA.html#args">args</a></code>, <code><a
    342 href="refN.html#next">next</a></code>, <code><a
    343 href="refR.html#rest">rest</a></code> and <code><a
    344 href="refP.html#pass">pass</a></code>.
    345 
    346 <pre><code>
    347 : (de foo @ (println (next) (arg)))    # Print argument twice
    348 -> foo
    349 : (foo 123)
    350 123 123
    351 -> 123
    352 : (de foo @
    353    (println (arg 1) (arg 2))
    354    (println (next))
    355    (println (arg 1) (arg 2)) )
    356 -> foo
    357 : (foo 'a 'b 'c)
    358 a b
    359 a
    360 b c
    361 -> c
    362 </code></pre>
    363 
    364 <dt><a name="args"><code>(args) -> flg</code></a>
    365 <dd>Can only be used inside functions with a variable number of arguments (with
    366 <code>@</code>). Returns <code>T</code> when there are more arguments to be
    367 fetched from the internal list. See also <code><a
    368 href="refN.html#next">next</a></code>, <code><a
    369 href="refA.html#arg">arg</a></code>, <code><a
    370 href="refR.html#rest">rest</a></code> and <code><a
    371 href="refP.html#pass">pass</a></code>.
    372 
    373 <pre><code>
    374 : (de foo @ (println (args)))       # Test for arguments
    375 -> foo
    376 : (foo)                             # No arguments
    377 NIL
    378 -> NIL
    379 : (foo NIL)                         # One argument
    380 T
    381 -> T
    382 : (foo 123)                         # One argument
    383 T
    384 -> T
    385 </code></pre>
    386 
    387 <dt><a name="argv"><code>(argv [var ..] [. sym]) -> lst|sym</code></a>
    388 <dd>If called without arguments, <code>argv</code> returns a list of strings
    389 containing all remaining command line arguments. Otherwise, the
    390 <code>var/sym</code> arguments are subsequently bound to the command line
    391 arguments. A hyphen "<code>-</code>" can be used to inhibit the automatic
    392 <code>load</code>ing further arguments. See also <code><a
    393 href="refC.html#cmd">cmd</a></code>, <a href="ref.html#invoc">Invocation</a> and
    394 <code><a href="refO.html#opt">opt</a></code>.
    395 
    396 <pre><code>
    397 $ pil -"println 'OK" - abc 123 +
    398 OK
    399 : (argv)
    400 -> ("abc" "123")
    401 : (argv A B)
    402 -> "123"
    403 : A
    404 -> "abc"
    405 : B
    406 -> "123"
    407 : (argv . Lst)
    408 -> ("abc" "123")
    409 : Lst
    410 -> ("abc" "123")
    411 </code></pre>
    412 
    413 <dt><a name="as"><code>(as 'any1 . any2) -> any2 | NIL</code></a>
    414 <dd>Returns <code>any2</code> unevaluated when <code>any1</code> evaluates to
    415 non-<code>NIL</code>. Otherwise <code>NIL</code> is returned. <code>(as Flg A B
    416 C)</code> is equivalent to <code>(and Flg '(A B C))</code>. See also <code><a
    417 href="refQ.html#quote">quote</a></code>.
    418 
    419 <pre><code>
    420 : (as (= 3 3) A B C)
    421 -> (A B C)
    422 </code></pre>
    423 
    424 <dt><a name="asoq"><code>(asoq 'any 'lst) -> lst</code></a>
    425 <dd>Searches an association list. Returns the first element from
    426 <code>lst</code> with <code>any</code> as its CAR, or <code>NIL</code> if no
    427 match is found. <code><a href="ref_.html#==">==</a></code> is used for
    428 comparison (pointer equality). See also <code><a
    429 href="refA.html#assoc">assoc</a></code>, <code><a
    430 href="refD.html#delq">delq</a></code>, <code><a
    431 href="refM.html#memq">memq</a></code>, <code><a
    432 href="refM.html#mmeq">mmeq</a></code> and <a href="ref.html#cmp">Comparing</a>.
    433 
    434 <pre><code>
    435 : (asoq 999 '((999 1 2 3) (b . 7) ("ok" "Hello")))
    436 -> NIL
    437 : (asoq 'b '((999 1 2 3) (b . 7) ("ok" "Hello")))
    438 -> (b . 7)
    439 </code></pre>
    440 
    441 <dt><a name="assert"><code>(assert exe ..) -> prg | NIL</code></a>
    442 <dd>When in debug mode (<code><a href="refD.html#*Dbg">*Dbg</a></code> is
    443 non-<code>NIL</code>), <code>assert</code> returns a <code>prg</code> list which
    444 tests all <code>exe</code> conditions, and issues an error via <code><a
    445 href="refQ.html#quit">quit</a></code> if one of the results evaluates to
    446 <code>NIL</code>. Otherwise, <code>NIL</code> is returned. Used typically in
    447 combination with the <code>~</code> tilde <code><a
    448 href="ref.html#macro-io">read-macro</a></code> to insert the test code only when
    449 in debug mode. See also <code><a href="refT.html#test">test</a></code>.
    450 
    451 <pre><code>
    452 # Start in debug mode
    453 $ pil +
    454 : (de foo (N)
    455    ~(assert (>= 90 N 10))
    456    (bar N) )
    457 -> foo
    458 : (pp 'foo)                      # Pretty-print 'foo'
    459 (de foo (N)
    460    (unless (>= 90 N 10)          # Assertion code exists
    461       (quit "'assert' failed" '(>= 90 N 10)) )
    462    (bar N) )
    463 -> foo
    464 : (foo 7)                        # Try it
    465 (>= 90 N 10) -- Assertion failed
    466 ?
    467 
    468 # Start in non-debug mode
    469 $ pil
    470 : (de foo (N)
    471    ~(assert (>= 90 N 10))
    472    (bar N) )
    473 -> foo
    474 : (pp 'foo)                      # Pretty-print 'foo'
    475 (de foo (N)
    476    (bar N) )                     # Assertion code does not exist
    477 -> foo
    478 </code></pre>
    479 
    480 <dt><a name="asserta"><code>(asserta 'lst) -> lst</code></a>
    481 <dd>Inserts a new <a href="ref.html#pilog">Pilog</a> fact or rule before all
    482 other rules. See also <code><a href="refB.html#be">be</a></code>, <code><a
    483 href="refC.html#clause">clause</a></code>, <code><a
    484 href="refA.html#assertz">assertz</a></code> and <code><a
    485 href="refR.html#retract">retract</a></code>.
    486 
    487 <pre><code>
    488 : (be a (2))            # Define two facts
    489 -> a
    490 : (be a (3))
    491 -> a
    492 
    493 : (asserta '(a (1)))    # Insert new fact in front
    494 -> ((1))
    495 
    496 : (? (a @N))            # Query
    497  @N=1
    498  @N=2
    499  @N=3
    500 -> NIL
    501 </code></pre>
    502 
    503 <dt><a name="asserta/1"><code>asserta/1</code></a>
    504 <dd><a href="ref.html#pilog">Pilog</a> predicate that inserts a new fact or rule
    505 before all other rules. See also <code><a
    506 href="refA.html#asserta">asserta</a></code>, <code><a
    507 href="refA.html#assertz/1">assertz/1</a></code> and <code><a
    508 href="refR.html#retract/1">retract/1</a></code>.
    509 
    510 <pre><code>
    511 : (? (asserta (a (2))))
    512 -> T
    513 : (? (asserta (a (1))))
    514 -> T
    515 : (rules 'a)
    516 1 (be a (1))
    517 2 (be a (2))
    518 -> a
    519 </code></pre>
    520 
    521 <dt><a name="assertz"><code>(assertz 'lst) -> lst</code></a>
    522 <dd>Appends a new <a href="ref.html#pilog">Pilog</a> fact or rule behind all
    523 other rules. See also <code><a href="refB.html#be">be</a></code>, <code><a
    524 href="refC.html#clause">clause</a></code>, <code><a
    525 href="refA.html#asserta">asserta</a></code> and <code><a
    526 href="refR.html#retract">retract</a></code>.
    527 
    528 <pre><code>
    529 : (be a (1))            # Define two facts
    530 -> a
    531 : (be a (2))
    532 -> a
    533 
    534 : (assertz '(a (3)))    # Append new fact at the end
    535 -> ((3))
    536 
    537 : (? (a @N))            # Query
    538  @N=1
    539  @N=2
    540  @N=3
    541 -> NIL
    542 </code></pre>
    543 
    544 <dt><a name="assertz/1"><code>assertz/1</code></a>
    545 <dd><a href="ref.html#pilog">Pilog</a> predicate that appends a new fact or rule
    546 behind all other rules. See also <code><a
    547 href="refA.html#assertz">assertz</a></code>, <code><a
    548 href="refA.html#asserta/1">asserta/1</a></code> and <code><a
    549 href="refR.html#retract/1">retract/1</a></code>.
    550 
    551 <pre><code>
    552 : (? (assertz (a (1))))
    553 -> T
    554 : (? (assertz (a (2))))
    555 -> T
    556 : (rules 'a)
    557 1 (be a (1))
    558 2 (be a (2))
    559 -> a
    560 </code></pre>
    561 
    562 <dt><a name="assoc"><code>(assoc 'any 'lst) -> lst</code></a> <dd>Searches an
    563 association list. Returns the first element from <code>lst</code> with its CAR
    564 equal to <code>any</code>, or <code>NIL</code> if no match is found. See also
    565 <code><a href="refA.html#asoq">asoq</a></code>.
    566 
    567 <pre><code>
    568 : (assoc "b" '((999 1 2 3) ("b" . 7) ("ok" "Hello")))
    569 -> ("b" . 7)
    570 : (assoc 999 '((999 1 2 3) ("b" . 7) ("ok" "Hello")))
    571 -> (999 1 2 3)
    572 : (assoc 'u '((999 1 2 3) ("b" . 7) ("ok" "Hello")))
    573 -> NIL
    574 </code></pre>
    575 
    576 <dt><a name="at"><code>(at '(cnt1 . cnt2|NIL) . prg) -> any</code></a>
    577 <dd>Increments <code>cnt1</code> (destructively), and returns <code>NIL</code>
    578 when it is less than <code>cnt2</code>. Otherwise, <code>cnt1</code> is reset to
    579 zero and <code>prg</code> is executed. Returns the result of <code>prg</code>.
    580 If <code>cnt2</code> is <code>NIL</code>, nothing is done, and <code>NIL</code>
    581 is returned immediately.
    582 
    583 <pre><code>
    584 : (do 11 (prin ".") (at (0 . 3) (prin "!")))
    585 ...!...!...!..-> NIL
    586 </code></pre>
    587 
    588 <dt><a name="atom"><code>(atom 'any) -> flg</code></a>
    589 <dd>Returns <code>T</code> when the argument <code>any</code> is an atom (a
    590 number or a symbol). See also <code><a href="refP.html#pair">pair</a></code>.
    591 
    592 <pre><code>
    593 : (atom 123)
    594 -> T
    595 : (atom 'a)
    596 -> T
    597 : (atom NIL)
    598 -> T
    599 : (atom (123))
    600 -> NIL
    601 </code></pre>
    602 
    603 <dt><a name="aux"><code>(aux 'var 'cls ['hook] 'any ..) -> sym</code></a>
    604 <dd>Returns a database object of class <code>cls</code>, where the value for
    605 <code>var</code> corresponds to <code>any</code> and the following arguments.
    606 <code>var</code>, <code>cls</code> and <code>hook</code> should specify a
    607 <code><a href="refT.html#tree">tree</a></code> for <code>cls</code> or one of
    608 its superclasses, for a relation with auxiliary keys. For multi-key accesses,
    609 <code>aux</code> is simlar to - but faster than - <code>db</code>, because it
    610 can use a single tree access. See also <code><a
    611 href="refD.html#db">db</a></code>, <code><a
    612 href="refC.html#collect">collect</a></code>, <code><a
    613 href="refF.html#fetch">fetch</a></code>, <code><a
    614 href="refI.html#init">init</a></code>, <code><a
    615 href="refS.html#step">step</a></code> and <code><a
    616 href="refA.html#+Aux">+Aux</a></code>.
    617 
    618 <pre><code>
    619 (class +PS +Entity)
    620 (rel par (+Dep +Joint) (sup) ps (+Part))        # Part
    621 (rel sup (+Aux +Ref +Link) (par) NIL (+Supp))   # Supplier
    622 ...
    623    (aux 'sup '+PS                               # Access PS object
    624       (db 'nr '+Supp 1234)
    625       (db 'nr '+Part 5678) )
    626 </code></pre>
    627 
    628 </dl>
    629 
    630 </body>
    631 </html>