📄 refb.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>B</title><link rel="stylesheet" href="doc.css" type="text/css"></head><body><h1>B</h1><dl><dt><a name="*Blob"><code>*Blob</code></a><dd>A global variable holding the pathname of the database blob directory. Seealso <code><a href="refB.html#blob">blob</a></code>.<p><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 beexecuted just before the termination of the Pico Lisp interpreter. See also<code><a href="refB.html#bye">bye</a></code> and <code><ahref="refT.html#tmp">tmp</a></code>.<p><pre><code>: (push1 '*Bye '(call 'rm "myfile.tmp")) # Remove a temporary file-> (call 'rm "myfile.tmp")</code></pre><dt><a name="balance"><code>(balance 'var 'lst ['flg])</code></a><dd>Builds a balanced binary <code><a href="refI.html#idx">idx</a></code> treein <code>var</code>, from the sorted list in <code>lst</code>. Normally (ifrandom 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 anoptimally balanced way. If <code>flg</code> is non-<code>NIL</code>, the indextree will be augmented instead of being overwritten. See also <code><ahref="ref.html#cmp">Comparing</a></code> and <code><ahref="refS.html#sort">sort</a></code>.<p><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# 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="be"><code>(be sym . any) -> sym</code></a><dd>Declares a <a href="ref.html#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><ahref="refG.html#goal">goal</a></code> and <code><ahref="refP.html#prove">prove</a></code>.<p><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))): (? (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><ahref="refP.html#prin">prin</a></code> and <code><ahref="refC.html#char">char</a></code>.<p><pre><code>: (beep)-> "^G"</code></pre><dt><a name="begin"><code>(begin) -> T</code></a><dd>Opens a nested transaction. Not needed for normal single-level transactionprocessing with <code><a href="refC.html#commit">commit</a></code> and <code><ahref="refR.html#rollback">rollback</a></code>.<p><pre><code>: (pool "db")-> T: (put '{1} 'str "Hello") # Set property in first level-> "Hello": (begin) # Start second level-> T: (put '{1} 'str "abc") # Set another value-> "abc": (get '{1} 'str)-> "abc": (rollback) # Rollback second level-> NIL: (get '{1} 'str) # Value is restored-> "Hello": (rollback) # Rollback top level-> T: (get '{1} 'str) # Value is cleared-> NIL</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, alist of symbols, or to a list of symbol-value pairs. The values of these symbolsare saved (and the symbols bound to the values in the last case),<code>prg</code> is executed, then the symbols are restored to their originalvalues. During execution of <code>prg</code>, the values of the symbols can betemporarily modified. The return value is the result of <code>prg</code>. Seealso <code><a href="refL.html#let">let</a></code>, <code><ahref="refJ.html#job">job</a></code> and <code><ahref="refU.html#use">use</a></code>.<p><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 thefirst argument are also 1 in all following arguments. See also <code><ahref="ref_.html#&">&</a></code>, <code><a href="ref_.html#|">|</a></code> and<code><a href="refX.html#x|">x|</a></code>.<p><pre><code>: (bit? 7 15 255)-> 7: (bit? 1 3)-> 1: (bit? 1 2)-> NIL</code></pre><dt><a name="blob"><code>(blob 'obj 'var) -> sym</code></a><dd>Returns the blob file name for <code>var</code> in <code>obj</code>. Seealso <code><a href="refB.html#*Blob">*Blob</a></code> and <code><ahref="refP.html#pack">pack</a></code>.<p><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="bool"><code>(bool 'any) -> flg</code></a><dd>Returns <code>T</code> when the argument <code>any</code> isnon-<code>NIL</code>. This function is only needed when <code>T</code> isstrictly required for a "true" condition (Usually, any non-<code>NIL</code>value is considered to be "true"). See also <code><ahref="refF.html#flg?">flg?</a></code>.<p><pre><code>: (and 3 4)-> 4: (bool (and 3 4))-> T</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="refN.html#new">new</a></code>and <code><a href="refB.html#box?">box?</a></code>.<p><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><ahref="refB.html#box">box</a></code>, <code><ahref="refS.html#str?">str?</a></code> and <code><ahref="refE.html#ext?">ext?</a></code>.<p><pre><code>: (box? (new))-> $134563468: (box? 123)-> NIL: (box? 'a)-> NIL: (box? NIL)-> 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>. Whenadditional <code>lst</code> arguments are given, their elements are also passedto <code>fun1</code>. Each result of <code>fun1</code> is CONSed with itscorresponding argument form the original <code>lst</code>, and collected into alist 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.<p><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="refF.html#finally">finally</a></code>expressions, then the <code>VAL</code> of the global variable <code><ahref="refB.html#*Bye">*Bye</a></code> (should be a <code>prg</code>), closes allopen files, and exits the Pico Lisp interpreter. The process return value is<code>cnt</code>, or 0 if the argument is missing or <code>NIL</code>.<p><pre><code>: (setq *Bye '((println 'Ok) (println 'bye)))-> ((println 'Ok) (println 'bye)): (bye)Okbye$</code></pre></dl></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -