refB.html (12280B)
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>B</title> 6 <link rel="stylesheet" href="doc.css" type="text/css"> 7 </head> 8 <body> 9 10 <h1>B</h1> 11 12 <dl> 13 14 <dt><a name="*Blob"><code>*Blob</code></a> 15 <dd>A global variable holding the pathname of the database blob directory. See 16 also <code><a href="refB.html#blob">blob</a></code>. 17 18 <pre><code> 19 : *Blob 20 -> "blob/app/" 21 </code></pre> 22 23 <dt><a name="*Bye"><code>*Bye</code></a> 24 <dd>A global variable holding a (possibly empty) <code>prg</code> body, to be 25 executed just before the termination of the PicoLisp interpreter. See also 26 <code><a href="refB.html#bye">bye</a></code> and <code><a 27 href="refT.html#tmp">tmp</a></code>. 28 29 <pre><code> 30 : (push1 '*Bye '(call 'rm "myfile.tmp")) # Remove a temporary file 31 -> (call 'rm "myfile.tmp") 32 </code></pre> 33 34 <dt><a name="+Bag"><code>+Bag</code></a> 35 <dd>Class for a list of arbitrary relations, a subclass of <code><a 36 href="refR.html#+relation">+relation</a></code>. Objects of that class maintain 37 a list of heterogeneous relations. Typically used in combination with the 38 <code><a href="refL.html#+List">+List</a></code> prefix class, to maintain small 39 two-dimensional tables within objects. See also <a 40 href="ref.html#dbase">Database</a>. 41 42 <pre><code> 43 (rel pos (+List +Bag) # Positions 44 ((+Ref +Link) NIL (+Item)) # Item 45 ((+Number) 2) # Price 46 ((+Number)) # Quantity 47 ((+String)) # Memo text 48 ((+Number) 2) ) # Total amount 49 </code></pre> 50 51 <dt><a name="+Blob"><code>+Blob</code></a> 52 <dd>Class for blob relations, a subclass of <code><a 53 href="refR.html#+relation">+relation</a></code>. Objects of that class maintain 54 blobs, as stubs in database objects pointing to actual files for arbitrary 55 (often binary) data. The files themselves reside below the path specified by the 56 <code><a href="refB.html#*Blob">*Blob</a></code> variable. See also <a 57 href="ref.html#dbase">Database</a>. 58 59 <pre><code> 60 (rel jpg (+Blob)) # Picture 61 </code></pre> 62 63 <dt><a name="+Bool">+Bool<code></code></a> 64 <dd>Class for boolean relations, a subclass of <code><a 65 href="refR.html#+relation">+relation</a></code>. Objects of that class expect 66 either <code>T</code> or <code>NIL</code> as value (though, as always, only 67 non-<code>NIL</code> will be physically stored in objects). See also <a 68 href="ref.html#dbase">Database</a>. 69 70 <pre><code> 71 (rel ok (+Ref +Bool)) # Indexed flag 72 </code></pre> 73 74 <dt><a name="balance"><code>(balance 'var 'lst ['flg])</code></a> 75 <dd>Builds a balanced binary <code><a href="refI.html#idx">idx</a></code> tree 76 in <code>var</code>, from the sorted list in <code>lst</code>. Normally (if 77 random or, in the worst case, ordered data) are inserted with <code>idx</code>, 78 the tree will not be balanced. But if <code>lst</code> is properly sorted, its 79 contents will be inserted in an optimally balanced way. If <code>flg</code> is 80 non-<code>NIL</code>, the index tree will be augmented instead of being 81 overwritten. See also <code><a href="ref.html#cmp">Comparing</a></code> and 82 <code><a href="refS.html#sort">sort</a></code>. 83 84 <pre><code> 85 # Normal idx insert 86 : (off I) 87 -> NIL 88 : (for X (1 4 2 5 3 6 7 9 8) (idx 'I X T)) 89 -> NIL 90 : (depth I) 91 -> 7 92 93 # Balanced insert 94 : (balance 'I (sort (1 4 2 5 3 6 7 9 8))) 95 -> NIL 96 : (depth I) 97 -> 4 98 99 # Augment 100 : (balance 'I (sort (10 40 20 50 30 60 70 90 80)) T) 101 -> NIL 102 : (idx 'I) 103 -> (1 2 3 4 5 6 7 8 9 10 20 30 40 50 60 70 80 90) 104 </code></pre> 105 106 <dt><a name="basename"><code>(basename 'any) -> sym</code></a> 107 <dd>Returns the filename part of a path name <code>any</code>. See also <code><a 108 href="refD.html#dirname">dirname</a></code> and <code><a 109 href="refP.html#path">path</a></code>. 110 111 <pre><code> 112 : (basename "a/b/c/d") 113 -> "d" 114 </code></pre> 115 116 <dt><a name="be"><code>(be sym . any) -> sym</code></a> 117 <dd>Declares a <a href="ref.html#pilog">Pilog</a> fact or rule for the 118 <code>sym</code> argument, by concatenating the <code>any</code> argument to the 119 <code>T</code> property of <code>sym</code>. See also <code><a 120 href="refC.html#clause">clause</a></code>, <code><a 121 href="refA.html#asserta">asserta</a></code>, <code><a 122 href="refA.html#assertz">assertz</a></code>, <code><a 123 href="refR.html#retract">retract</a></code>, <code><a 124 href="refG.html#goal">goal</a></code> and <code><a 125 href="refP.html#prove">prove</a></code>. 126 127 <pre><code> 128 : (be likes (John Mary)) 129 -> likes 130 : (be likes (John @X) (likes @X wine) (likes @X food)) 131 -> likes 132 : (get 'likes T) 133 -> (((John Mary)) ((John @X) (likes @X wine) (likes @X food))) 134 : (? (likes John @X)) 135 @X=Mary 136 -> NIL 137 </code></pre> 138 139 <dt><a name="beep"><code>(beep) -> any</code></a> 140 <dd>Send the bell character to the console. See also <code><a 141 href="refP.html#prin">prin</a></code> and <code><a 142 href="refC.html#char">char</a></code>. 143 144 <pre><code> 145 : (beep) 146 -> "^G" 147 </code></pre> 148 149 <dt><a name="bench"><code>(bench . prg) -> any</code></a> 150 <dd>(Debug mode only) Benchmarks <code>prg</code>, by printing the time it took 151 to execute, and returns the result. See also <code><a 152 href="refU.html#usec">usec</a></code>. 153 154 <pre><code> 155 : (bench (wait 2000)) 156 1.996 sec 157 -> NIL 158 </code></pre> 159 160 <dt><a name="bin"><code>(bin 'num ['num]) -> sym</code></a> 161 <dt><code>(bin 'sym) -> num</code> 162 <dd>Converts a number <code>num</code> to a binary string, or a binary string 163 <code>sym</code> to a number. In the first case, if the second argument is 164 given, the result is separated by spaces into groups of such many digits. See 165 also <code><a href="refO.html#oct">oct</a></code>, <code><a 166 href="refH.html#hex">hex</a></code>, <code><a 167 href="refF.html#fmt64">fmt64</a></code>, <code><a 168 href="refH.html#hax">hax</a></code> and <code><a 169 href="refF.html#format">format</a></code>. 170 171 <pre><code> 172 : (bin 73) 173 -> "1001001" 174 : (bin "1001001") 175 -> 73 176 : (bin 1234567 4) 177 -> "100 1011 0101 1010 0001 11" 178 </code></pre> 179 180 <dt><a name="bind"><code>(bind 'sym|lst . prg) -> any</code></a> 181 <dd>Binds value(s) to symbol(s). The first argument must evaluate to a symbol, 182 or a list of symbols or symbol-value pairs. The values of these symbols are 183 saved (and the symbols bound to the values in the case of pairs), 184 <code>prg</code> is executed, then the symbols are restored to their original 185 values. During execution of <code>prg</code>, the values of the symbols can be 186 temporarily modified. The return value is the result of <code>prg</code>. See 187 also <code><a href="refL.html#let">let</a></code>, <code><a 188 href="refJ.html#job">job</a></code> and <code><a 189 href="refU.html#use">use</a></code>. 190 191 <pre><code> 192 : (setq X 123) # X is 123 193 -> 123 194 : (bind 'X (setq X "Hello") (println X)) # Set X to "Hello", print it 195 "Hello" 196 -> "Hello" 197 : (bind '((X . 3) (Y . 4)) (println X Y) (* X Y)) 198 3 4 199 -> 12 200 : X 201 -> 123 # X is restored to 123 202 </code></pre> 203 204 <dt><a name="bit?"><code>(bit? 'num ..) -> num | NIL</code></a> 205 <dd>Returns the first <code>num</code> argument when all bits which are 1 in the 206 first argument are also 1 in all following arguments, otherwise 207 <code>NIL</code>. When one of those arguments evaluates to <code>NIL</code>, it 208 is returned immediately. See also <code><a href="ref_.html#&">&</a></code>, 209 <code><a href="ref_.html#|">|</a></code> and <code><a 210 href="refX.html#x|">x|</a></code>. 211 212 <pre><code> 213 : (bit? 7 15 255) 214 -> 7 215 : (bit? 1 3) 216 -> 1 217 : (bit? 1 2) 218 -> NIL 219 </code></pre> 220 221 <dt><a name="blob"><code>(blob 'obj 'sym) -> sym</code></a> 222 <dd>Returns the blob file name for <code>var</code> in <code>obj</code>. See 223 also <code><a href="refB.html#*Blob">*Blob</a></code>, <code><a 224 href="refB.html#blob!">blob!</a></code> and <code><a 225 href="refP.html#pack">pack</a></code>. 226 227 <pre><code> 228 : (show (db 'nr '+Item 1)) 229 {3-1} (+Item) 230 jpg 231 pr 29900 232 inv 100 233 sup {2-1} 234 nm "Main Part" 235 nr 1 236 -> {3-1} 237 : (blob '{3-1} 'jpg) 238 -> "blob/app/3/-/1.jpg" 239 </code></pre> 240 241 <dt><a name="blob!"><code>(blob! 'obj 'sym 'file)</code></a> 242 <dd>Stores the contents of <code>file</code> in a <code><a 243 href="refB.html#blob">blob</a></code>. See also <code><a 244 href="refE.html#entityMesssages">put!></a></code>. 245 246 <pre><code> 247 (blob! *ID 'jpg "picture.jpg") 248 </code></pre> 249 250 <dt><a name="bool"><code>(bool 'any) -> flg</code></a> 251 <dd>Returns <code>T</code> when the argument <code>any</code> is 252 non-<code>NIL</code>. This function is only needed when <code>T</code> is 253 strictly required for a "true" condition (Usually, any non-<code>NIL</code> 254 value is considered to be "true"). See also <code><a 255 href="refF.html#flg?">flg?</a></code>. 256 257 <pre><code> 258 : (and 3 4) 259 -> 4 260 : (bool (and 3 4)) 261 -> T 262 </code></pre> 263 264 <dt><a name="bool/3"><code>bool/3</code></a> 265 <dd><a href="ref.html#pilog">Pilog</a> predicate that succeeds if the first 266 argument has the same truth value as the result of applying the <code><a 267 href="refG.html#get">get</a></code> algorithm to the following arguments. 268 Typically used as filter predicate in <code><a 269 href="refS.html#select/3">select/3</a></code> database queries. See also 270 <code><a href="refB.html#bool">bool</a></code>, <code><a 271 href="refI.html#isa/2">isa/2</a></code>, <code><a 272 href="refS.html#same/3">same/3</a></code>, <code><a 273 href="refR.html#range/3">range/3</a></code>, <code><a 274 href="refH.html#head/3">head/3</a></code>, <code><a 275 href="refF.html#fold/3">fold/3</a></code>, <code><a 276 href="refP.html#part/3">part/3</a></code> and <code><a 277 href="refT.html#tolr/3">tolr/3</a></code>. 278 279 <pre><code> 280 : (? @OK NIL # Find orders where the 'ok' flag is not set 281 (db nr +Ord @Ord) 282 (bool @OK @Ord ok) ) 283 @OK=NIL @Ord={3-7} 284 -> NIL 285 </code></pre> 286 287 <dt><a name="box"><code>(box 'any) -> sym</code></a> 288 <dd>Creates and returns a new anonymous symbol. The initial value is set to the 289 <code>any</code> argument. See also <code><a href="refN.html#new">new</a></code> 290 and <code><a href="refB.html#box?">box?</a></code>. 291 292 <pre><code> 293 : (show (box '(A B C))) 294 $134425627 (A B C) 295 -> $134425627 296 </code></pre> 297 298 <dt><a name="box?"><code>(box? 'any) -> sym | NIL</code></a> 299 <dd>Returns the argument <code>any</code> when it is an anonymous symbol, 300 otherwise <code>NIL</code>. See also <code><a 301 href="refB.html#box">box</a></code>, <code><a 302 href="refS.html#str?">str?</a></code> and <code><a 303 href="refE.html#ext?">ext?</a></code>. 304 305 <pre><code> 306 : (box? (new)) 307 -> $134563468 308 : (box? 123) 309 -> NIL 310 : (box? 'a) 311 -> NIL 312 : (box? NIL) 313 -> NIL 314 </code></pre> 315 316 <dt><a name="by"><code>(by 'fun1 'fun2 'lst ..) -> lst</code></a> 317 <dd>Applies <code>fun1</code> to each element of <code>lst</code>. When 318 additional <code>lst</code> arguments are given, their elements are also passed 319 to <code>fun1</code>. Each result of <code>fun1</code> is CONSed with its 320 corresponding argument form the original <code>lst</code>, and collected into a 321 list which is passed to <code>fun2</code>. For the list returned from 322 <code>fun2</code>, the CAR elements returned by <code>fun1</code> are 323 (destructively) removed from each element. 324 325 <pre><code> 326 : (let (A 1 B 2 C 3) (by val sort '(C A B))) 327 -> (A B C) 328 : (by '((N) (bit? 1 N)) group (3 11 6 2 9 5 4 10 12 7 8 1)) 329 -> ((3 11 9 5 7 1) (6 2 4 10 12 8)) 330 </code></pre> 331 332 <dt><a name="bye"><code>(bye 'cnt|NIL)</code></a> 333 <dd>Executes all pending <code><a href="refF.html#finally">finally</a></code> 334 expressions, closes all open files, executes the <code>VAL</code> of the global 335 variable <code><a href="refB.html#*Bye">*Bye</a></code> (should be a 336 <code>prg</code>), flushes standard output, and then exits the PicoLisp 337 interpreter. The process return value is <code>cnt</code>, or 0 if the argument 338 is missing or <code>NIL</code>. 339 340 <pre><code> 341 : (setq *Bye '((println 'OK) (println 'bye))) 342 -> ((println 'OK) (println 'bye)) 343 : (bye) 344 OK 345 bye 346 $ 347 </code></pre> 348 349 <dt><a name="bytes"><code>(bytes 'any) -> cnt</code></a> 350 <dd>Returns the number of bytes <code>any</code> would occupy in encoded binary 351 format (as generated by <code><a href="refP.html#pr">pr</a></code>). See also 352 <code><a href="refS.html#size">size</a></code> and <code><a 353 href="refL.html#length">length</a></code>. 354 355 <pre><code> 356 : (bytes "abc") 357 -> 4 358 : (bytes "äbc") 359 -> 5 360 : (bytes 127) 361 -> 2 362 : (bytes 128) 363 -> 3 364 : (bytes (101 (102) 103)) 365 -> 10 366 : (bytes (101 102 103 .)) 367 -> 9 368 </code></pre> 369 370 </dl> 371 372 </body> 373 </html>