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

📄 reff.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>F</title><link rel="stylesheet" href="doc.css" type="text/css"></head><body><h1>F</h1><dl><dt><a name="*Fork"><code>*Fork</code></a><dd>A global variable holding a (possibly empty) <code>prg</code> body, to beexecuted after a call to <code><a href="refF.html#fork">fork</a></code> in thechild process.<p><pre><code>: (push '*Fork '(off *Tmp))   # Clear '*Tmp' in child process-> (off *Tmp)</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="refT.html#tree">tree</a></code> and <code><ahref="refS.html#store">store</a></code>.<p><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 calledwith <code>any</code> arguments, they will be concatenated to end of thestructure. Otherwise, the first element is removed from the structure andreturned. See also <code><a href="refQ.html#queue">queue</a></code>, <code><ahref="refP.html#push">push</a></code>, <code><ahref="refP.html#pop">pop</a></code>, <code><ahref="refR.html#rot">rot</a></code> and <code><ahref="refC.html#circ">circ</a></code>.<p><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="fill"><code>(fill 'any ['sym|lst]) -> any</code></a><dd>Fills a pattern <code>any</code>, by substituting <code>sym</code>, or allsymbols in <code>lst</code>, or - if no second argument is given - each patternsymbol in <code>any</code> (see <code><a href="refP.html#pat?">pat?</a></code>),with its current value. In that case, <code>@</code> itself is not considered apattern symbol. See also <code><a href="refM.html#match">match</a></code>.<p><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)</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>. Whenadditional <code>lst</code> arguments are given, their elements are also passedto <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><ahref="refF.html#fish">fish</a></code>.<p><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 <code>CDR</code> ofits last cell. See also <code><a href="refL.html#last">last</a></code> and<code><a href="refT.html#tail">tail</a></code>.<p><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 theresult of <code>prg</code> is returned. <code>exe</code> will also be evaluatedif <code>prg</code> does not terminate normally due to a runtime error or a callto <code><a href="refT.html#throw">throw</a></code>. See also <code><ahref="refB.html#bye">bye</a></code>, <code><ahref="refC.html#catch">catch</a></code>, <code><ahref="refQ.html#quit">quit</a></code> and <code><a href="ref.html#errors">ErrorHandling</a></code>.<p><pre><code>: (finally (prinl "Done!")   (println 123)   (quit)   (println 456) )123Done!: (catch 'A   (finally (prinl "Done!")      (println 1)      (throw 'A 123)      (println 2) ) )1Done!-> 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> untilnon-<code>NIL</code> is returned. Returns that element, 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, theirelements are also passed to <code>fun</code>. See also <code><ahref="refS.html#seek">seek</a></code>, <code><ahref="refP.html#pick">pick</a></code>.<p><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>lst</code>. Returns a list of all items where <code>fun</code> returnednon-<code>NIL</code>. See also <code><ahref="refF.html#filter">filter</a></code>.<p><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><ahref="refB.html#bool">bool</a></code>. <code>(flg? X)</code> is equivalent to<code>(or (not X) (=T X))</code>.<p><pre><code>: (flg? (= 3 3))-> T: (flg? (= 3 4))-> T: (flg? (+ 3 4))-> NIL</code></pre><dt><a name="flip"><code>(flip 'lst) -> lst</code></a><dd>Returns <code>lst</code> (destructively) reversed. See also <code><ahref="refR.html#reverse">reverse</a></code>.<p><pre><code>: (flip (1 2 3 4))-> (4 3 2 1)</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="refK.html#key">key</a></code>. Returns <code>T</code> whensuccessful. See also <code><a href="refR.html#rewind">rewind</a></code>.<p><pre><code>: (flush)-> T</code></pre><dt><a name="fmt64"><code>(fmt64 'num) ->sym<br>(fmt64 'sym) -> num</code></a><dd>Converts a number <code>num</code> to a string in base-64, or a base-64formatted 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 isused internally for the names of <code><a href="ref.html#external-io">externalsymbols</a></code>. See also <code><a href="refH.html#hex">hex</a></code> and<code><a href="refO.html#oct">oct</a></code>.<p><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,<code>NIL</code> is returned. Otherwise, a new transient symbol with all digitsand all letters of <code>any</code>, converted to lower case, is returned. Ifthe <code>cnt</code> argument is given, the result is truncated to that length(or not truncated if <code>cnt</code> is zero). Otherwise <code>cnt</code>defaults to 24. See also <code><a href="refL.html#lowc">lowc</a></code>.<p><pre><code>: (fold " 1A 2-b/3")-> "1a2b3": (fold " 1A 2-B/3" 3)-> "1a2"</code></pre><dt><a name="for"><code>(for sym|(sym2 . sym) 'lst ['any | (NIL 'any . prg) | (T 'any . prg) ..]) -> any<br>(for (sym|(sym2 . sym) 'any1 'any2 [. prg]) ['any | (NIL 'any . prg) | (T 'any . prg) ..]) -> any</code></a><dd>Conditional loop with local variable(s) and multiple conditional exits: Inthe first form, the value of <code>sym</code> is saved, <code>sym</code> issubsequently bound to the elements of <code>lst</code>, and the body is executedeach time. In the second 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 foreach execution of the body. While the condition <code>any2</code> evaluates tonon-<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. If aclause has <code>NIL</code> or <code>T</code> as its <code>CAR</code>, theclause'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> isexecuted and the result returned. If the body is never executed,<code>NIL</code> is returned. See also <code><ahref="refD.html#do">do</a></code> and <code><ahref="refL.html#loop">loop</a></code>.<p><pre><code>: (for (N 1 (>= 8 N) (inc N)) (printsp N))1 2 3 4 5 6 7 8 -> 8: (for (L (1 2 3 4 5 6 7 8) L) (printsp (pop 'L)))1 2 3 4 5 6 7 8 -> 8: (for X (1 a 2 b) (printsp X))1 a 2 b -> b: (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): (for (I . X) '(a b c d e f) (println I X))1 a2 b3 c4 d5 e6 f-> f</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 thechild's process ID <code>pid</code> in the parent. In the child, the<code>VAL</code> of the global variable <code><ahref="refF.html#*Fork">*Fork</a></code> (should be a <code>prg</code>) isexecuted. See also <code><a href="refP.html#pipe">pipe</a></code> and <code><ahref="refT.html#tell">tell</a></code>.<p><pre><code>: (unless (fork) (do 5 (println 'Ok) (wait 1000)) (bye))-> NILOk                                              # Child's output: OkOkOkOk</code></pre><dt><a name="format"><code>(format 'num ['cnt ['sym1 ['sym2]]]) -> sym<br>(format 'sym ['cnt ['sym1 ['sym2]]]) -> num</code></a><dd>Converts a number <code>num</code> to a string, or a string <code>sym</code>to a number. In both cases, optionally a precision <code>cnt</code>, adecimal-separator <code>sym1</code> and a thousands-separator <code>sym2</code>can be supplied. Returns <code>NIL</code> if the conversion is unsuccessful. Seealso <code><a href="ref.html#num-io">Numbers</a></code>.<p><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 "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 availablesymbol <code>sym</code> (i.e. the first symbol greater than any symbol in thedatabase), and the list <code>lst</code> of free symbols. See also <code><ahref="refS.html#seq">seq</a></code>, <code><ahref="refZ.html#zap">zap</a></code> and <code><ahref="refD.html#dbck">dbck</a></code>.<p><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> isfound, 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><ahref="refT.html#till">till</a></code> and <code><ahref="refE.html#echo">echo</a></code>.<p><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 atleast one <code>NIL</code> element, otherwise <code>T</code>. <code>(fullX)</code> is equivalent to <code>(not (memq NIL X))</code>.<p><pre><code>: (full (1 2 3))-> T: (full (1 NIL 3))-> NIL: (full 123)-> T</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 anumber 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 offormal parameters for a function. See also <code><ahref="refG.html#getd">getd</a></code>.<p><pre><code>: (fun? 1000000000)              # Might be a code pointer-> 1000000000: (fun? 100000000000000)         # Too big for a code pointer-> NIL: (fun? 1000000001)              # Cannot be a code pointer (odd)-> 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></body></html>

⌨️ 快捷键说明

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