- +Idx
- Prefix class for maintaining non-unique full-text indexes to +Stringrelations, a subclass of+Ref. Accepts optional arguments for the
minimally indexed substring length (defaults to 3), and a+Hookattribute. Often used in combination
with the+Snsoundex index, or the+Foldindex prefix classes. See also
Database.
(rel nm (+Sn +Idx +String))  # Name
 
- +IdxFold
- Prefix class for maintaining non-unique indexes to subsequent substrings of
the folded individual words of+Stringrelations. Accepts optional
arguments for the minimally indexed substring length (defaults to 3), and a+Hookattribute. See also+Idxand Database.
(rel nm (+IdxFold +String))            # Item Description
 
- +index
- Abstract base class of all database B-Tree index relations (prefix classes
for +relations). The class
hierarchy includes+Key,+Ref,+Idxand+IdxFold. See also Database.
(isa '+index Rel)  # Check for an index relation
 
- (id 'num ['num]) -> sym
- (id 'sym [NIL]) -> num
- (id 'sym T) -> (num . num)
- Converts one (the internal block number) or two (file and block) numbers to
an external symbol, or an external symbol to a number or a pair of numbers.
: (id 7)
-> {7}
: (id 1 2)
-> {2}
: (id '{A2})
-> 2
: (id '{A2} T)
-> (2 . 2)
 
- (idx 'var 'any 'flg) -> lst
 (idx 'var 'any) -> lst
 (idx 'var) -> lst
- Maintains an index tree in var, and checks for the existence ofany. Ifanyis contained invar, the
corresponding subtree is returned, otherwiseNIL. In the first
form,anyis destructively inserted into the tree ifflgis non-NIL(andanywas not already
there), or deleted from the tree ifflgisNIL. The
second form only checks for existence, but does not change the index tree. In
the third form (when called with a singlevarargument) the
contents of the tree are returned as a sorted list. If all elements are inserted
in sorted order, the tree degenerates into a linear list. See alsolup,enum,hash,rev,depth,sort,balanceandmember.
: (idx 'X 'd T)                              # Insert data
-> NIL
: (idx 'X 2 T)
-> NIL
: (idx 'X '(a b c) T)
-> NIL
: (idx 'X 17 T)
-> NIL
: (idx 'X 'A T)
-> NIL
: (idx 'X 'd T)
-> (d (2 NIL 17 NIL A) (a b c))              # 'd' already existed
: (idx 'X T T)
-> NIL
: X                                          # View the index tree
-> (d (2 NIL 17 NIL A) (a b c) NIL T)
: (idx 'X 'A)                                # Check for 'A'
-> (A)
: (idx 'X 'B)                                # Check for 'B'
-> NIL
: (idx 'X)
-> (2 17 A d (a b c) T)                      # Get list
: (idx 'X 17 NIL)                            # Delete '17'
-> (17 NIL A)
: X
-> (d (2 NIL A) (a b c) NIL T)               # View it again
: (idx 'X)
-> (2 A d (a b c) T)                         # '17' is deleted
 
- (if 'any1 any2 . prg) -> any
- Conditional execution: If the condition any1evaluates to
non-NIL,any2is evaluated and returned. Otherwise,prgis executed and the result returned. See alsoifn,cond,whenandif2.
: (if (> 4 3) (println 'OK) (println 'Bad))
OK
-> OK
: (if (> 3 4) (println 'OK) (println 'Bad))
Bad
-> Bad
 
- (if2 'any1 'any2 any3 any4 any5 . prg) -> any
- Four-way conditional execution for two conditions: If both conditions
any1andany2evaluate to non-NIL,any3is evaluated and returned. Otherwise,any4orany5is evaluated and returned ifany1orany2evaluate to non-NIL, respectively. If none of the
conditions evaluate to non-NIL,prgis executed and
the result returned. See alsoifandcond.
: (if2 T T 'both 'first 'second 'none)
-> both
: (if2 T NIL 'both 'first 'second 'none)
-> first
: (if2 NIL T 'both 'first 'second 'none)
-> second
: (if2 NIL NIL 'both 'first 'second 'none)
-> none
 
- (ifn 'any1 any2 . prg) -> any
- Conditional execution ("If not"): If the condition any1evaluates toNIL,any2is evaluated and returned.
Otherwise,prgis executed and the result returned. See alsoif,nor,nand,unlessandnond.
: (ifn (= 3 4) (println 'OK) (println 'Bad))
OK
-> OK
 
- (import . lst) -> lst
- Wrapper function for intern.
Typically used to import symbols from other namespaces, as created bysymbols.lstshould be a list
of symbols. See alsopico,privateandlocalandexport.
: (import libA~foo libB~bar)
-> (foo bar)
 
- (in 'any . prg) -> any
- Opens anyas input channel during the execution ofprg. The current input channel will be saved and restored
appropriately. If the argument isNIL, standard input is used. If
the argument is a symbol, it is used as a file name (opened for reading
and writing if the first character is "+"). If it is a
positive number, it is used as the descriptor of an open file. If it is a
negative number, the saved input channel such many levels above the current one
is used. Otherwise (if it is a list), it is taken as a command with arguments,
and a pipe is opened for input. The (system dependent) exit status code of the
child process is stored in the global variable@@. See alsoipid,call,load,file,out,err,poll,pipeandctl.
: (in "a" (list (read) (read) (read)))  # Read three items from file "a"
-> (123 (a b c) def)
: (in '(file "-b" "--mime" "bin/picolisp")  # Get the mime type
   (line T) )
-> "application/x-executable; charset=binary"
 
- (inc 'num) -> num
 (inc 'var ['num]) -> num
- The first form returns the value of numincremented by 1. The
second form increments theVALofvarby 1, or bynum. If the first argument isNIL, it is returned
immediately.(inc Num)is equivalent to(+ Num 1)and(inc 'Var)is equivalent to(set 'Var (+ Var 1)). See
alsodecand+.
: (inc 7)
-> 8
: (inc -1)
-> 0
: (zero N)
-> 0
: (inc 'N)
-> 1
: (inc 'N 7)
-> 8
: N
-> 8
: (setq L (1 2 3 4))
-> (1 2 3 4)
: (inc (cdr L))
-> 3
: L
-> (1 3 3 4)
 
- (inc! 'obj 'sym ['num]) -> num
- Transaction wrapper function for inc.numdefaults to 1. Note that
for incrementing a property value of an entity typically theinc!>message is used. See alsonew!,request!,set!andput!.
(inc! Obj 'cnt 0)  # Incrementing a property of a non-entity object
 
- (index 'any 'lst) -> cnt | NIL
- Returns the cntposition ofanyinlst, orNILif it is not found. See alsooffsetandsub?.
: (index 'c '(a b c d e f))
-> 3
: (index '(5 6) '((1 2) (3 4) (5 6) (7 8)))
-> 3
 
- (info 'any ['flg]) -> (cnt|flg dat . tim)
- Returns information about a file with the name any: The current
sizecntin bytes, and the modification date and time (UTC, or
local time ifflgis zero). For directories,Tis
returned instead of the size, andNILfor other non-regular files.
The file argument itself is stored in the global variable@@). Ifflgis non-NILandanyis the name of a symbolic link, then the link itself is
used, not the file that it refers to. See alsodir,dateandtime.
$ ls -l x.l
-rw-r--r--   1 abu      users         208 Jun 17 08:58 x.l
$ pil +
: (info "x.l")
-> (208 730594 . 32315)
: (stamp 730594 32315)
-> "2000-06-17 08:58:35"
 
- (init 'tree ['any1] ['any2]) -> lst
- Initializes a structure for stepping iteratively through a database tree.
any1andany2may specify a range of keys. Ifany2is greater thanany1, the traversal will be in
opposite direction. See alsotree,step,iterandscan.
: (init (tree 'nr '+Item) 3 5)
-> (((3 . 5) ((3 NIL . {B3}) (4 NIL . {B4}) (5 NIL . {B5}) (6 NIL . {B6}))))
 
- (input exe . prg) -> any
- Establishes an input stream, by redirecting the current input channel during
the execution of prg. The current input channel will be saved and
restored appropriately.exeis executed (in the context of the
original input channel) whenever a character is required by read calls inprg, and should return a single character upon each execution. See
alsooutput,inandpipe.
: (input "A" (char))
-> "A"
: (let S (chop "(+ 2 (* 3 4))") (input (++ S) (read)))
-> (+ 2 (* 3 4))
 
- (insert 'cnt 'lst 'any) -> lst
- Inserts anyintolstat positioncnt.
This is a non-destructive operation. See alsoremove,place,append,deleteandreplace.
: (insert 3 '(a b c d e) 777)
-> (a b 777 c d e)
: (insert 1 '(a b c d e) 777)
-> (777 a b c d e)
: (insert 9 '(a b c d e) 777)
-> (a b c d e 777)
 
- (intern 'sym ['nsp]) -> sym
- Creates or finds an internal symbol. If a symbol with the name
symis already intern, it is returned. Otherwise,symis interned in the current namespace and returned. Ifnspis
non-NIL,symis always interned in the current
namespace (ifnspisT) or in the given namespace,
even if it is found in other namespaces. See alsosymbols,zap,importandextern.
: (intern "abc")
-> abc
: (intern 'car)
-> car
: ((intern (pack "c" "a" "r")) (1 2 3))
-> 1
 
- (ipid) -> pid | NIL
- Returns the corresponding process ID when the current input channel is
reading from a pipe, otherwise NIL. See alsoopid,in,pipeandload.
: (in '(ls "-l") (println (line T)) (kill (ipid)))
"total 7364"
-> T
 
- (isa 'cls|typ 'obj) -> obj | NIL
- Returns objwhen it is an object that inherits fromclsortype. See also OO
Concepts,class,type,newandobject.
: (isa '+Address Obj)
-> {A17}
: (isa '(+Male +Person) Obj)
-> NIL
 
- isa/2
- Pilog predicate that succeeds if the second
argument is of the type or class given by the first argument, according to the
isafunction. Typically used indb/3orselect/3database queries. See alsosame/3,bool/3,range/3,head/3,fold/3,part/3andtolr/3.
: (? (db nm +Person @Prs) (isa +Woman @Prs) (val @Nm @Prs nm))
 @Prs={A44} @Nm="Alexandra of Denmark"
 @Prs={A124} @Nm="Alice Maud Mary"
 @Prs={A21} @Nm="Anne"
 @Prs={A57} @Nm="Augusta Victoria".  # Stop
 
- (iter 'tree ['fun] ['any1] ['any2] ['flg])
- Iterates through a database tree by applying funto all values.fundefaults toprintln.any1andany2may specify a range of keys. Ifany2is greater
thanany1, the traversal will be in opposite direction. Note that
the keys need not to be atomic, depending on the application's index structure.
Ifflgis non-NIL, partial keys are skipped. See alsotree,ubIter,scan,initandstep.
: (iter (tree 'nr '+Item))
{B1}
{B2}
{B3}
{B4}
{B5}
{B6}
-> NIL
: (iter (tree 'nr '+Item) '((This) (println (: nm))))
"Main Part"
"Spare Part"
"Auxiliary Construction"
"Enhancement Additive"
"Metal Fittings"
"Gadget Appliance"
"Testartikel"
-> NIL