*Uni
- A global variable holding an
idx
tree, with all unique data that were collected with the comma (,
)
read-macro. Typically used for localization. See also Read-Macros
and locale
.
: (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
+Aux
to maintain
an UB-Tree index instead of the direct values. This allows efficient range
access to multidimensional data. Only numeric keys are supported. See also
Database
.
(class +Pos +Entity)
(rel x (+UB +Aux +Ref +Number) (y z))
(rel y (+Number))
(rel z (+Number))
: (scan (tree 'x '+Pos))
...
(664594005183881683 . {B}) {B}
(899018453307525604 . {C}) {C} # UBKEY of (516516 690628 706223)
(943014863198293414 . {2}) {2}
(988682500781514058 . {A}) {A}
(994667870851824704 . {8}) {8}
(1016631364991047263 . {:}) {:}
...
: (show '{C})
{C} (+Pos)
z 706223
y 690628
x 516516
-> {C}
# Discrete queries work the same way as without the +UB prefix
: (db 'x '+Pos 516516 'y 690628 'z 706223)
-> {C}
: (aux 'x '+Pos 516516 690628 706223)
-> {C}
: (? (db x +Pos (516516 690628 706223) @Pos))
@Pos={C}
-> NIL
# Efficient range queries are are possible now
: (?
@X (416511 . 616519)
@Y (590621 . 890629)
@Z (606221 . 906229)
(select (@@)
((x +Pos (@X @Y @Z))) # Range query
(range @X @@ x) # Filter
(range @Y @@ y)
(range @Z @@ z) ) )
@X=(416511 . 616519) @Y=(590621 . 890629) @Z=(606221 . 906229) @@={C}
@X=(416511 . 616519) @Y=(590621 . 890629) @Z=(606221 . 906229) @@={8}
(u) -> T
- Removes
!
all breakpoints in all
subexpressions of the current breakpoint. Typically used when single-stepping a
function or method with debug
. See
also d
and unbug
.
! (u) # Unbug subexpression(s) at breakpoint
-> T
(udp 'any1 'any2 'any3) -> any
(udp 'cnt) -> any
- Simple unidirectional sending/receiving of UDP packets. In the first form,
any3
is sent to a UDP server listening at host any1
,
port any2
. In the second form, one item is received from a UDP
socket cnt
, established with port
. See also listen
and connect
.
# 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
date
of the last day
of the month m
in the year y
. See also day
and week
.
: (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
- Removes all
!
breakpoints in the
function or method body of sym, as inserted with debug
or d
, or directly with edit
. See also u
.
: (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 also de
, dm
, def
and redef
.
: (de hello () "Hello world!")
-> hello
: hello
-> (NIL "Hello world!")
: (undef 'hello)
-> (NIL "Hello world!")
: hello
-> NIL
(unify 'any) -> lst
- Unifies
any
with the current Pilog
environment at the current level and with a value of NIL
, and
returns the new environment or NIL
if not successful. See also
prove
and ->
.
: (? (@A unify '(@B @C)))
@A=(((NIL . @C) 0 . @C) ((NIL . @B) 0 . @B) T)
(uniq 'lst) -> lst
- Returns a unique list, by eleminating all duplicate elements from
lst
. See also Comparing, sort
and group
.
: (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 first
argument is not yet stored in the second argument's index structure.
idx
is used internally storing for the values
and checking for uniqueness. See also member/2
.
: (? (uniq a @Z)) # Remember 'a'
@Z=NIL # Succeeded
: (? (uniq b @Z)) # Remember 'b'
@Z=NIL # Succeeded
: (? (uniq a @Z)) # Remembered 'a'?
-> NIL # Yes: Not unique
(unless 'any . prg) -> any
- Conditional execution: When the condition
any
evaluates to
non-NIL
, NIL
is returned. Otherwise prg
is executed and the result returned. See also when
.
: (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
any
evaluates to
NIL
, prg
is repeatedly executed. If prg
is never executed, NIL
is returned. Otherwise the result of
prg
is returned. See also while
.
: (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
- Removes the
$
trace function call at
the beginning of the function or method body of sym
, so that no
more trace information will be printed before and after execution. Built-in
functions (C-function pointer) are automatically converted to their original
form (see subr
). See also trace
and traceAll
.
: (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 of
sym
in the corresponding enclosing environment. If cnt
is not given, 1 is used. See also eval
, run
and env
.
: (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
(upd sym ..) -> lst
- Synchronizes the internal state of all passed (external) symbols by passing
them to
wipe
. upd
is the
standard function passed to commit
during database transactions
.
(commit 'upd) # Commit changes, informing all sister processes
(update 'obj ['var]) -> obj
- Interactive database function for modifying external symbols. When called
only with an
obj
argument, update
steps through the
value and all properties of that object (and recursively also through
substructures) and allows to edit them with the console line editor. When the
var
argument is given, only that single property is handed to the
editor. To delete a propery, NIL
must be explicitly entered.
update
will correctly handle all entity/relation mechanisms. See also select
, edit
and Database
.
: (show '{3-1}) # Show item 1
{3-1} (+Item)
nr 1
pr 29900
inv 100
sup {2-1}
nm "Main Part"
-> {3-1}
: (update '{3-1} 'pr) # Update the prices of that item
{3-1} pr 299.00 # The cursor is right behind "299.00"
-> {3-1}
(upp? 'any) -> sym | NIL
- Returns
any
when the argument is a string (symbol) that starts with an
uppercase character. See also uppc
and
low?
: (upp? "A")
-> T
: (upp? "a")
-> NIL
: (upp? 123)
-> NIL
: (upp? ".")
-> NIL
(uppc 'any) -> any
- Upper case conversion: If
any
is not a symbol, it is returned
as it is. Otherwise, a new transient symbol with all characters of
any
, converted to upper case, is returned. See also lowc
, fold
and upp?
.
: (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 symbols sym
in the list of the second form - are
saved, 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 bind
, job
and let
.
: (setq X 123 Y 456)
-> 456
: (use (X Y) (setq X 3 Y 4) (* X Y))
-> 12
: X
-> 123
: Y
-> 456
(useKey 'var '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) -> num
- Returns the number the microseconds since interpreter startup. See also
time
and tick
.
: (usec)
-> 1154702479219050