- *Uni
- A global variable holding an idxtree, with all unique data that were collected with the comma (,)
read-macro. Typically used for localization. Setting*UnitoTdisables this mechanism. See alsoRead-Macrosandlocale.
: (off *Uni)            # Clear
-> NIL
: ,"abc"                # Collect a transient symbol
-> "abc"
: ,(1 2 3)              # Collect a list
-> (1 2 3)
: *Uni
-> ("abc" NIL (1 2 3))
- +UB
- Prefix class for +Auxto maintain
an UB-Tree index instead of the direct values. This allows efficient range
access to multi-dimensional data. Only positive numeric keys are supported. See
alsoubIterand Database.
(class +Pos +Entity)
(rel x (+UB +Aux +Ref +Number) (y z))
(rel y (+Number))
(rel z (+Number))
: (scan (tree 'x '+Pos))
(288362200753438306 . {13}) {13}
(348187139486943716 . {16}) {16}
(605261596962573238 . {11}) {11}
(638523558602802506 . {7}) {7}   # UBKEY of (453062 450921 613956)
(654697989157410399 . {12}) {12}
...
: (show '{7})
{7} (+Pos)
   x 453062
   y 450921
   z 613956
-> {7}
# Discrete queries work the same way as without the +UB prefix
: (db 'x '+Pos 453062 'y 450921 'z 613956)
-> {7}
: (aux 'x '+Pos 453062 450921 613956)
-> {7}
: (? (db x +Pos (453062 450921 613956) @Pos))
 @Pos={7}
-> NIL
# Range queries work efficiently with 'collect'. Note that though also Pilog
queries can handle UB-trees, they may do so sub-optimally for certain ranges.
: (collect 'x '+Pos (200000 200000 200000) (899999 899999 899999))
-> ({7} {14} {17} {15})
- (u) -> T
- (Debug mode only) Removes !all
breakpoints in all subexpressions of the current breakpoint. Typically used when
single-stepping a function or method withdebug. See alsodandunbug.
! (u)                         # Unbug subexpression(s) at breakpoint
-> T
 
- (ubIter 'tree 'dim 'fun 'lst1 'lst2)
- Efficiently iterates through a database +UBtree, by applyingfunto all
values.dimis the number of the key dimensions,lst1andlst2specify a range of keys.collectusesubIterinternally
for UB-tree queries. See alsoiter.
: (ubIter (tree 'x '+Pos) 3 show (200000 200000 200000) (899999 899999 899999))
{7} (+Pos)
   z 613956
   y 450921
   x 453062
{14} (+Pos)
   z 771372
   y 262217
   x 862358
{17} (+Pos)
   z 676836
   y 529576
   x 398229
{15} (+Pos)
   z 889332
   y 691799
   x 265381
-> NIL
- (udp 'any1 'any2 'any3) -> any
- (udp 'cnt) -> any
- Simple unidirectional sending/receiving of UDP packets. In the first form,
any3is sent to a UDP server listening at hostany1,
portany2. In the second form, one item is received from a UDP
socketcnt, established withport. See alsolistenandconnect.
# First session
: (port T 6666)
-> 3
: (udp 3)  # Receive a datagram
# Second session (on the same machine)
: (udp "localhost" 6666 '(a b c))
-> (a b c)
# First session
-> (a b c)
 
- (ultimo 'y 'm) -> cnt
- Returns the dateof the last day
of the monthmin the yeary. See alsodayandweek.
: (date (ultimo 2007 1))
-> (2007 1 31)
: (date (ultimo 2007 2))
-> (2007 2 28)
: (date (ultimo 2004 2))
-> (2004 2 29)
: (date (ultimo 2000 2))
-> (2000 2 29)
: (date (ultimo 1900 2))
-> (1900 2 28)
 
- (unbug 'sym) -> T
- (unbug 'sym 'cls) -> T
- (unbug '(sym . cls)) -> T
- (Debug mode only) Removes all !breakpoints in the function or method body of sym, as inserted withdebugord, or directly withvi. See alsou.
: (pp 'tst)
(de tst (N)
   (! println (+ 3 N)) )         # 'tst' has a breakpoint '!'
-> tst
: (unbug 'tst)                   # Unbug it
-> T
: (pp 'tst)                      # Restore
(de tst (N)
   (println (+ 3 N)) )
 
- (undef 'sym) -> fun
- (undef 'sym 'cls) -> fun
- (undef '(sym . cls)) -> fun
- Undefines the function or method sym. Returns the previous
definition. See alsode,dm,defandredef.
: (de hello () "Hello world!")
-> hello
: hello
-> (NIL "Hello world!")
: (undef 'hello)
-> (NIL "Hello world!")
: hello
-> NIL
 
- (unify 'any) -> lst
- (unify 'cnt) -> cnt
- The first form unifies anywith the current Pilog environment at the current level and with a
value ofNIL, and returns the new environment orNILif not successful. The second form unifies all variables at the given level with
the current one. See alsoproveand->.
: (? (^ @A (unify '(@B @C))))
 @A=(((NIL . @C) 0 . @C) ((NIL . @B) 0 . @B) T)
 
- (uniq 'lst) -> lst
- Returns a unique list, by eliminating all duplicate elements from
lst. See also Comparing,sortandgroup.
: (uniq (2 4 6 1 2 3 4 5 6 1 3 5))
-> (2 4 6 1 3 5)
 
- uniq/2
- Pilog predicate that succeeds if the second
argument is not yet stored in the first argument's index structure. idxis used internally storing for the values
and checking for uniqueness. See alsomember/2.
: (let U NIL
   (? (lst @X (a b c b c d)) (uniq U @X)) )
 @X=a
 @X=b
 @X=c
 @X=d
-> NIL
: (solve '((^ @B (box)) (lst @X (a b c b c d)) (uniq @B @X)) @X)
-> (a b c d)
 
- (unless 'any . prg) -> any
- Conditional execution: When the condition anyevaluates to
non-NIL,NILis returned. Otherwiseprgis executed and the result returned. See alsowhen,ifn,nor,nandandnond.
: (unless (= 3 3) (println 'Strange 'result))
-> NIL
: (unless (= 3 4) (println 'Strange 'result))
Strange result
-> result
 
- (until 'any . prg) -> any
- Conditional loop: While the condition anyevaluates toNIL,prgis repeatedly executed. Ifprgis never executed,NILis returned. Otherwise the result ofprgis returned. See alsowhile,for,loopanddo.
: (until (=T (setq N (read)))
   (println 'square (* N N)) )
4
square 16
9
square 81
T
-> 81
 
- (untrace 'sym) -> sym
- (untrace 'sym 'cls) -> sym
- (untrace '(sym . cls)) -> sym
- (Debug mode only) Removes the $trace
function call at the beginning of the function or method body ofsym, so that no more trace information will be printed before and
after execution. Built-in functions (SUBRs) are automatically converted to their
original form (seesubr). See alsotraceandtraceAll.
: (trace '+)                           # Trace the '+' function
-> +
: +
-> (@ ($ + @ (pass $385455126)))       # Modified for tracing
: (untrace '+)                         # Untrace '+'
-> +
: +
-> 67319120                            # Back to original form
 
- (up [cnt] sym ['val]) -> any
- Looks up (or modifies) the cnt'th previously saved value ofsymin the corresponding enclosing environment. Ifcntis not given, 1 is used. It is allowed to omit thesymargument,
then the corresponding expression (function or method call) is returned. See
alsoeval,run,trailandenv.
: (let N 1 ((quote (N) (println N (up N))) 2))
2 1
-> 1
: (let N 1 ((quote (N) (println N (up N) (up N 7))) 2) N)
2 1 7
-> 7
: (de foo (N)
   (println (up))
   (inc N) )
-> foo
: (foo 7)
(foo 7)
-> 8
 
- (upd sym ..) -> lst
- Synchronizes the internal state of all passed (external) symbols by passing
them to wipe.updis the
standard function passed tocommitduring databasetransactions.
(commit 'upd)  # Commit changes, informing all sister processes
 
- (upp? 'any) -> sym | NIL
- Returns anywhen the argument is a string (symbol) that starts
with an uppercase character. See alsouppcandlow?
: (upp? "A")
-> "A"
: (upp? "a")
-> NIL
: (upp? 123)
-> NIL
: (upp? ".")
-> NIL
 
- (uppc 'any) -> any
- Upper case conversion: If anyis not a symbol, it is returned
as it is. Otherwise, a new transient symbol with all characters ofany, converted to upper case, is returned. See alsolowc,foldandupp?.
: (uppc 123)
-> 123
: (uppc "abc")
-> "ABC"
: (uppc 'car)
-> "CAR"
 
- (use sym . prg) -> any
- (use (sym ..) . prg) -> any
- Defines local variables. The value of the symbol sym- or the
values of the symbolssymin the list of the second form - are
saved,prgis executed, then the symbols are restored to their
original values. During execution ofprg, the values of the symbols
can be temporarily modified. The return value is the result ofprg.
See alsobind,jobandlet.
: (setq  X 123  Y 456)
-> 456
: (use (X Y) (setq  X 3  Y 4) (* X Y))
-> 12
: X
-> 123
: Y
-> 456
 
- (useKey 'sym 'cls ['hook]) -> num
- Generates or reuses a key for a database tree, by randomly trying to locate
a free number. See also genKey.
: (maxKey (tree 'nr '+Item))
-> 8
: (useKey 'nr '+Item)
-> 12
 
- (usec ['flg]) -> num
- Returns a number of microseconds. If flgis
non-NIL, the microsecond fraction of the last call totimeis returned, otherwise the number of
microseconds since interpreter startup. See alsodate.
: (usec)
-> 1154702479219050
: (list (date (date)) (time (time T)) (usec T))
-> ((2013 1 4) (10 12 39) 483321)