B

*Blob
A global variable holding the pathname of the database blob directory. See also blob.


: *Blob
-> "blob/app/"
*Bye
A global variable holding a (possibly empty) prg body, to be executed just before the termination of the Pico Lisp interpreter. See also bye and tmp.


: (push1 '*Bye '(call 'rm "myfile.tmp"))   # Remove a temporary file
-> (call 'rm "myfile.tmp")
(balance 'var 'lst ['flg])
Builds a balanced binary idx tree in var, from the sorted list in lst. Normally (if random or, in the worst case, ordered data) are inserted with idx, the tree will not be balanced. But if lst is properly sorted, its contents will be inserted in an optimally balanced way. If flg is non-NIL, the index tree will be augmented instead of being overwritten. See also Comparing and sort.


# 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)
(be sym . any) -> sym
Declares a Pilog fact or rule for the sym argument, by concatenating the any argument to the T property of sym. See also goal and prove.


: (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
(beep) -> any
Send the bell character to the console. See also prin and char.


: (beep)
-> "^G"
(bind 'sym|lst . prg) -> any
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), prg is executed, then the symbols are restored to their original values. During execution of prg, the values of the symbols can be temporarily modified. The return value is the result of prg. See also let, job and use.


: (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
(bit? 'num ..) -> num | NIL
Returns the first num argument when all bits which are 1 in the first argument are also 1 in all following arguments. When one of those arguments evaluates to NIL, it is returned immediately. See also &, | and x|.


: (bit? 7 15 255)
-> 7
: (bit? 1 3)
-> 1
: (bit? 1 2)
-> NIL
(blob 'obj 'var) -> sym
Returns the blob file name for var in obj. See also *Blob and pack.


: (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"
(bool 'any) -> flg
Returns T when the argument any is non-NIL. This function is only needed when T is strictly required for a "true" condition (Usually, any non-NIL value is considered to be "true"). See also flg?.


: (and 3 4)
-> 4
: (bool (and 3 4))
-> T
(box 'any) -> sym
Creates and returns a new anonymous symbol. The initial value is set to the any argument. See also new and box?.


: (show (box '(A B C)))
$134425627 (A B C)
-> $134425627
(box? 'any) -> sym | NIL
Returns the argument any when it is an anonymous symbol, otherwise NIL. See also box, str? and ext?.


: (box? (new))
-> $134563468
: (box? 123)
-> NIL
: (box? 'a)
-> NIL
: (box? NIL)
-> NIL
(by 'fun1 'fun2 'lst ..) -> lst
Applies fun1 to each element of lst. When additional lst arguments are given, their elements are also passed to fun1. Each result of fun1 is CONSed with its corresponding argument form the original lst, and collected into a list which is passed to fun2. For the list returned from fun2, the CAR elements returned by fun1 are (destructively) removed from each element.


: (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))
(bye 'cnt|NIL)
Executes all pending finally expressions, then the VAL of the global variable *Bye (should be a prg), closes all open files, and exits the Pico Lisp interpreter. The process return value is cnt, or 0 if the argument is missing or NIL.


: (setq *Bye '((println 'OK) (println 'bye)))
-> ((println 'OK) (println 'bye))
: (bye)
OK
bye
$