1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351
|
<!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>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. See
also <code><a href="refB.html#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="refB.html#bye">bye</a></code> and <code><a
href="refT.html#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="refR.html#+relation">+relation</a></code>. Objects of that class maintain
a list of heterogeneous relations. Typically used in combination with the
<code><a href="refL.html#+List">+List</a></code> prefix class, to maintain small
two-dimensional tables within oubjects. See also <code><a
href="ref.html#dbase">Database</a></code>.
<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="refR.html#+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="refB.html#*Blob">*Blob</a></code> variable. See also <code><a
href="ref.html#dbase">Database</a></code>.
<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="refR.html#+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 <code><a
href="ref.html#dbase">Database</a></code>.
<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="refI.html#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="ref.html#cmp">Comparing</a></code> and
<code><a href="refS.html#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
# 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="refD.html#dirname">dirname</a></code> and <code><a
href="refP.html#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="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><a
href="refC.html#clause">clause</a></code>, <code><a
href="refA.html#asserta">asserta</a></code>, <code><a
href="refA.html#assertz">assertz</a></code>, <code><a
href="refR.html#retract">retract</a></code>, <code><a
href="refG.html#goal">goal</a></code> and <code><a
href="refP.html#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)))
: (? (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="refP.html#prin">prin</a></code> and <code><a
href="refC.html#char">char</a></code>.
<pre><code>
: (beep)
-> "^G"
</code></pre>
<dt><a name="bench"><code>(bench . prg) -> any</code></a>
<dd>Benchmarks <code>prg</code>, by printing the time it took to execute, and
returns the result. See also <code><a href="refU.html#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="refO.html#oct">oct</a></code>, <code><a
href="refH.html#hex">hex</a></code>, <code><a
href="refF.html#fmt64">fmt64</a></code>, <code><a
href="refH.html#hax">hax</a></code> and <code><a
href="refF.html#format">format</a></code>.
<pre><code>
: (bin 73)
-> "1001001"
: (bin "1001001")
-> 73
: (bin 1234567 4)
-> "100 1011 0101 1010 0001 11"
</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="refL.html#let">let</a></code>, <code><a
href="refJ.html#job">job</a></code> and <code><a
href="refU.html#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="ref_.html#&">&</a></code>,
<code><a href="ref_.html#|">|</a></code> and <code><a
href="refX.html#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="refB.html#*Blob">*Blob</a></code>, <code><a
href="refB.html#blob!">blob!</a></code> and <code><a
href="refP.html#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="refB.html#blob">blob</a></code>. See also <code><a
href="refE.html#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="refF.html#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="ref.html#pilog">Pilog</a> predicate that succeeds if the first
argument has the same truth value as the result of applying the <code><a
href="refG.html#get">get</a></code> algorithm to the following arguments.
Typically used as filter predicate in <code><a
href="refS.html#select/3">select/3</a></code> database queries. See also
<code><a href="refB.html#bool">bool</a></code>, <code><a
href="refI.html#isa/2">isa/2</a></code>, <code><a
href="refS.html#same/3">same/3</a></code>, <code><a
href="refR.html#range/3">range/3</a></code>, <code><a
href="refH.html#head/3">head/3</a></code>, <code><a
href="refF.html#fold/3">fold/3</a></code>, <code><a
href="refP.html#part/3">part/3</a></code> and <code><a
href="refT.html#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="refN.html#new">new</a></code>
and <code><a href="refB.html#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="refB.html#box">box</a></code>, <code><a
href="refS.html#str?">str?</a></code> and <code><a
href="refE.html#ext?">ext?</a></code>.
<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>. 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.
<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, closes all open files, executes the <code>VAL</code> of the global
variable <code><a href="refB.html#*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>
</dl>
</body>
</html>
|