⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 refa.html

📁 A very small LISP implementation with several packages and demo programs.
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>A</title><link rel="stylesheet" href="doc.css" type="text/css"></head><body><h1>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="refL.html#listen">listen</a></code> and <code><ahref="refA.html#accept">accept</a></code>.<p><pre><code>: *Adr-> "127.0.0.1"</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 anypreviously scheduled alarm was due to be delivered. Calling <code>(alarm0)</code> will cancel an alarm.<p><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="*Allow"><code>*Allow</code></a><dd>A global variable holding allowed access patterns. If its value isnon-<code>NIL</code>, it should contain a list where the CAR is an <code><ahref="refI.html#idx">idx</a></code> tree of allowed items, and the CDR a list ofprefix strings. See also <code><a href="refA.html#allow">allow</a></code>,<code><a href="refA.html#allowed">allowed</a></code> and <code><ahref="refP.html#pre?">pre?</a></code>.<p><pre><code>: (allowed ("app/" "img/")                               # Initialize   "@start" "@stop" "favicon.ico" "lib.css" "@psh" )-> NIL: (allow "@myFoo")                                       # additional item-> "@myFoo": (allow "myDir/" T)                                     # additional prefix-> "myDir/": *Allow-> (("@stop" ("@psh" ("@myFoo") "@start") "favicon.ico" NIL "lib.css") "app/" "img/" "myDir/"): (idx *Allow)                                                # items-> ("@myFoo" "@psh" "@start" "@stop" "favicon.ico" "lib.css"): (cdr *Allow)                                                # prefixes-> ("app/" "img/" "myDir/")</code></pre><dt><a name="abs"><code>(abs 'num) -> num</code></a><dd>Returns the absolute value of the <code>num</code> argument.<p><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><ahref="refP.html#port">port</a></code>), and returns the new socket descriptor<code>cnt</code>. The global variable <code>*Adr</code> is set to the IP addressof the client. See also <code><a href="refL.html#listen">listen</a></code>,<code><a href="refC.html#connect">connect</a></code> and <code><ahref="refA.html#*Adr">*Adr</a></code>.<p><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> inan association list stored in <code>var</code>. See also <code><ahref="refA.html#assoc">assoc</a></code>.<p><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="align"><code>(align 'cnt 'any) -> sym<br>(align 'lst 'any ..) -> sym</code></a><dd>Returns a transient symbol with all <code>any</code> arguments <code><ahref="refP.html#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 arepacked according to the numbers in <code>lst</code>. See also <code><ahref="refT.html#tab">tab</a></code>, <code><ahref="refC.html#center">center</a></code> and <code><ahref="refW.html#wrap">wrap</a></code>.<p><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 list of all <a href="ref.html#internal">internal</a> symbols inthe system (if called without arguments, or with <code>NIL</code>). Otherwise(if the argument is <code>T</code>), all current <ahref="ref.html#transient">transient</a> symbols are returned. Else all current<a href="ref.html#external">external</a> symbols are returned.<p><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 globalvariable <code><a href="refA.html#*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="refI.html#idx">idx</a></code> tree in the CAR of<code>*Allow</code> (if <code>flg</code> is <code>NIL</code>), or to the list ofprefix strings (if <code>flg</code> is non-<code>NIL</code>). See also <code><ahref="refA.html#allowed">allowed</a></code>.<p><pre><code>: *Allow-> (("@stop" ("@psh" NIL "@start") "favicon.ico" NIL "lib.css") "app/" "img/"): (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="refA.html#*Allow">*Allow</a></code>. <code>lst</code> shouldconsist of prefix strings (to be checked at runtime with <code><ahref="refP.html#pre?">pre?</a></code>), and the <code>sym</code> argumentsshould specify the initially allowed items. See also <code><ahref="refA.html#allow">allow</a></code>.<p><pre><code>: (allowed ("app/" "img/")                               # allowed prefixes   "@start" "@stop" "favicon.ico" "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 toright. If <code>NIL</code> is encountered, <code>NIL</code> is returnedimmediately. Else the result of the last expression is returned.<p><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>. See also <code><ahref="refS.html#sym">sym</a></code> and <code><ahref="refS.html#str">str</a></code>.<p><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><ahref="refC.html#conc">conc</a></code>, <code><ahref="refI.html#insert">insert</a></code>, <code><ahref="refD.html#delete">delete</a></code> and <code><ahref="refR.html#remove">remove</a></code>.<p><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="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>.<p><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 returnedfrom the last call to <code>next</code>) is returned. Otherwise, the<code>cnt</code>'th remaining argument is returned. See also <code><ahref="refA.html#args">args</a></code>, <code><ahref="refN.html#next">next</a></code>, <code><ahref="refR.html#rest">rest</a></code> and <code><ahref="refP.html#pass">pass</a></code>.<p><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 bab 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 befetched from the internal list. See also <code><ahref="refN.html#next">next</a></code>, <code><ahref="refA.html#arg">arg</a></code>, <code><ahref="refR.html#rest">rest</a></code> and <code><ahref="refP.html#pass">pass</a></code>.<p><pre><code>: (de foo @ (println (args)))       # Test for arguments-> foo: (foo)                             # No argumentsNIL-> NIL: (foo NIL)                         # One argumentT-> T: (foo 123)                         # One argumentT-> T</code></pre><dt><a name="argv"><code>(argv [sym ..] [. sym]) -> lst|sym</code></a><dd>If called without arguments, <code>argv</code> returns a list of stringscontaining all remaining command line arguments. Otherwise, the <code>sym</code>arguments are subsequently bound to the command line arguments. A hyphen"<code>-</code>" can be used to stop <code>load</code>ing further arguments. Seealso <code><a href="ref.html#invoc">Invocation</a></code> and <code><ahref="refO.html#opt">opt</a></code>.<p><pre><code>$ ./p -"println 'Ok" - abc 123Ok: (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 tonon-<code>NIL</code>. Otherwise <code>NIL</code> is returned. <code>(as Flg A BC)</code> is equivalent to <code>(and Flg '(A B C))</code>. See also <code><ahref="refQ.html#quote">quote</a></code>.<p><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 <code>CAR</code>, or<code>NIL</code> if no match is found. <code><ahref="ref_.html#==">==</a></code> is used for comparison (pointer equality). Seealso <code><a href="refA.html#assoc">assoc</a></code>, <code><ahref="refD.html#delq">delq</a></code>, <code><ahref="refM.html#memq">memq</a></code> and <code><ahref="refM.html#mmeq">mmeq</a></code>.<p><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="assoc"><code>(assoc 'any 'lst) -> lst</code></a><dd>Searches an association list. Returns the first element from<code>lst</code> with its <code>CAR</code> equal to <code>any</code>, or<code>NIL</code> if no match is found.<p><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) . prg) -> any</code></a><dd>Increments <code>cnt1</code> (destructively), and returns <code>NIL</code>when it is less than <code>cnt2</code>. Otherwise, <code>prg</code> is executedand <code>cnt1</code> is reset to zero. Returns the result of <code>prg</code>.<p><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 (anumber or a symbol). See also <code><a href="refP.html#pair">pair</a></code>.<p><pre><code>: (atom 123)-> T: (atom 'a)-> T: (atom NIL)-> T: (atom (123))-> NIL</code></pre><dt><a name="aux"><code>(aux 'var 'cls ['hook] 'any ..) -> sym</code></a><dd>Returns a database object of class <code>cls</code>, where the value for<code>var</code> corresponds to <code>any</code> and the following arguments.<code>var</code>, <code>cls</code> and <code>hook</code> should specify a<code><a href="refT.html#tree">tree</a></code> for <code>cls</code> or one ofits superclasses, for a relation with auxiliary keys. <code>aux</code> is simlarto - but faster than - <code>db</code>, because it can use a single tree access.See also <code><a href="refD.html#db">db</a></code>, <code><ahref="refC.html#collect">collect</a></code>, <code><ahref="refF.html#fetch">fetch</a></code>, <code><ahref="refI.html#init">init</a></code> and <code><ahref="refS.html#step">step</a></code>.<p><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></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -