File: refU.html

package info (click to toggle)
picolisp 3.1.0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,100 kB
  • sloc: ansic: 14,205; lisp: 795; makefile: 290; sh: 13
file content (409 lines) | stat: -rw-r--r-- 13,123 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/1998/REC-html40-19980424/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>U</title>
<link rel="stylesheet" href="doc.css" type="text/css">
</head>
<body>

<h1>U</h1>

<dl>

<dt><a name="*Uni"><code>*Uni</code></a>
<dd>A global variable holding an <code><a href="refI.html#idx">idx</a></code>
tree, with all unique data that were collected with the comma (<code>,</code>)
read-macro. Typically used for localization. See also <code><a
href="ref.html#macro-io">Read-Macros</a></code> and <code><a
href="refL.html#locale">locale</a></code>.

<pre><code>
: (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))
</code></pre>

<dt><a name="+UB"><code>+UB</code></a>
<dd>Prefix class for <code><a href="refA.html#+Aux">+Aux</a></code> 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
<code><a href="ref.html#dbase">Database</a></code>.

<pre><code>
(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}
</code></pre>

<dt><a name="u"><code>(u) -> T</code></a>
<dd>Removes <code><a href="ref_.html#!">!</a></code> all breakpoints in all
subexpressions of the current breakpoint. Typically used when single-stepping a
function or method with <code><a href="refD.html#debug">debug</a></code>. See
also <code><a href="refD.html#d">d</a></code> and <code><a
href="refU.html#unbug">unbug</a></code>.

<pre><code>
! (u)                         # Unbug subexpression(s) at breakpoint
-> T
</code></pre>

<dt><a name="udp"><code>(udp 'any1 'any2 'any3) -> any</code></a>
<dt><code>(udp 'cnt) -> any</code>
<dd>Simple unidirectional sending/receiving of UDP packets. In the first form,
<code>any3</code> is sent to a UDP server listening at host <code>any1</code>,
port <code>any2</code>. In the second form, one item is received from a UDP
socket <code>cnt</code>, established with <code><a
href="refP.html#port">port</a></code>. See also <code><a
href="refL.html#listen">listen</a></code> and <code><a
href="refC.html#connect">connect</a></code>.

<pre><code>
# 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)
</code></pre>

<dt><a name="ultimo"><code>(ultimo 'y 'm) -> cnt</code></a>
<dd>Returns the <code><a href="refD.html#date">date</a></code> of the last day
of the month <code>m</code> in the year <code>y</code>. See also <code><a
href="refD.html#day">day</a></code> and <code><a
href="refW.html#week">week</a></code>.

<pre><code>
: (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)
</code></pre>

<dt><a name="unbug"><code>(unbug 'sym) -> T</code></a>
<dt><code>(unbug 'sym 'cls) -> T</code>
<dt><code>(unbug '(sym . cls)) -> T</code>
<dd>Removes all <code><a href="ref_.html#!">!</a></code> breakpoints in the
function or method body of sym, as inserted with <code><a
href="refD.html#debug">debug</a></code> or <code><a
href="refD.html#d">d</a></code>, or directly with <code><a
href="refE.html#edit">edit</a></code>. See also <code><a
href="refU.html#u">u</a></code>.

<pre><code>
: (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)) )
</code></pre>

<dt><a name="undef"><code>(undef 'sym) -> fun</code></a>
<dt><code>(undef 'sym 'cls) -> fun</code>
<dt><code>(undef '(sym . cls)) -> fun</code>
<dd>Undefines the function or method <code>sym</code>. Returns the previous
definition. See also <code><a href="refD.html#de">de</a></code>, <code><a
href="refD.html#dm">dm</a></code>, <code><a href="refD.html#def">def</a></code>
and <code><a href="refR.html#redef">redef</a></code>.

<pre><code>
: (de hello () "Hello world!")
-> hello
: hello
-> (NIL "Hello world!")
: (undef 'hello)
-> (NIL "Hello world!")
: hello
-> NIL
</code></pre>

<dt><a name="unify"><code>(unify 'any) -> lst</code></a>
<dd>Unifies <code>any</code> with the current <a href="ref.html#pilog">Pilog</a>
environment at the current level and with a value of <code>NIL</code>, and
returns the new environment or <code>NIL</code> if not successful. See also
<code><a href="refP.html#prove">prove</a></code> and <code><a
href="ref_.html#->">-&gt</a></code>.

<pre><code>
: (? (@A unify '(@B @C)))
 @A=(((NIL . @C) 0 . @C) ((NIL . @B) 0 . @B) T)
</code></pre>

<dt><a name="uniq"><code>(uniq 'lst) -> lst</code></a>
<dd>Returns a unique list, by eleminating all duplicate elements from
<code>lst</code>. See also <a href="ref.html#cmp">Comparing</a>, <code><a
href="refS.html#sort">sort</a></code> and <code><a
href="refG.html#group">group</a></code>.

<pre><code>
: (uniq (2 4 6 1 2 3 4 5 6 1 3 5))
-> (2 4 6 1 3 5)
</code></pre>

<dt><a name="uniq/2"><code>uniq/2</code></a>
<dd><a href="ref.html#pilog">Pilog</a> predicate that succeeds if the first
argument is not yet stored in the second argument's index structure. <code><a
href="refI.html#idx">idx</a></code> is used internally storing for the values
and checking for uniqueness. See also <code><a
href="refM.html#member/2">member/2</a></code>.

<pre><code>
: (? (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
</code></pre>

<dt><a name="unless"><code>(unless 'any . prg) -> any</code></a>
<dd>Conditional execution: When the condition <code>any</code> evaluates to
non-<code>NIL</code>, <code>NIL</code> is returned. Otherwise <code>prg</code>
is executed and the result returned. See also <code><a
href="refW.html#when">when</a></code>.

<pre><code>
: (unless (= 3 3) (println 'Strange 'result))
-> NIL
: (unless (= 3 4) (println 'Strange 'result))
Strange result
-> result
</code></pre>

<dt><a name="until"><code>(until 'any . prg) -> any</code></a>
<dd>Conditional loop: While the condition <code>any</code> evaluates to
<code>NIL</code>, <code>prg</code> is repeatedly executed. If <code>prg</code>
is never executed, <code>NIL</code> is returned. Otherwise the result of
<code>prg</code> is returned. See also <code><a
href="refW.html#while">while</a></code>.

<pre><code>
: (until (=T (setq N (read)))
   (println 'square (* N N)) )
4
square 16
9
square 81
T
-> 81
</code></pre>

<dt><a name="untrace"><code>(untrace 'sym) -> sym</code></a>
<dt><code>(untrace 'sym 'cls) -> sym</code>
<dt><code>(untrace '(sym . cls)) -> sym</code>
<dd>Removes the <code><a href="ref_.html#$">$</a></code> trace function call at
the beginning of the function or method body of <code>sym</code>, 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 <code><a href="refS.html#subr">subr</a></code>). See also <code><a
href="refT.html#trace">trace</a></code> and <code><a
href="refT.html#traceAll">traceAll</a></code>.

<pre><code>
: (trace '+)                           # Trace the '+' function
-> +
: +
-> (@ ($ + @ (pass $385455126)))       # Modified for tracing
: (untrace '+)                         # Untrace '+'
-> +
: +
-> 67319120                            # Back to original form
</code></pre>

<dt><a name="up"><code>(up [cnt] sym ['val]) -> any</code></a>
<dd>Looks up (or modifies) the <code>cnt</code>'th previously saved value of
<code>sym</code> in the corresponding enclosing environment. If <code>cnt</code>
is not given, 1 is used. See also <code><a
href="refE.html#eval">eval</a></code>, <code><a
href="refR.html#run">run</a></code> and <code><a
href="refE.html#env">env</a></code>.

<pre><code>
: (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
</code></pre>

<dt><a name="upd"><code>(upd sym ..) -> lst</code></a>
<dd>Synchronizes the internal state of all passed (external) symbols by passing
them to <code><a href="refW.html#wipe">wipe</a></code>. <code>upd</code> is the
standard function passed to <code><a href="refC.html#commit">commit</a></code>
during database <code><a href="ref.html#trans">transactions</a></code>.

<pre><code>
(commit 'upd)  # Commit changes, informing all sister processes
</code></pre>

<dt><a name="update"><code>(update 'obj ['var]) -> obj</code></a>
<dd>Interactive database function for modifying external symbols. When called
only with an <code>obj</code> argument, <code>update</code> 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
<code>var</code> argument is given, only that single property is handed to the
editor. To delete a propery, <code>NIL</code> must be explicitly entered.
<code>update</code> will correctly handle all <a
href="ref.html#er">entity/relation</a> mechanisms. See also <code><a
href="refS.html#select">select</a></code>, <code><a
href="refE.html#edit">edit</a></code> and <code><a
href="ref.html#dbase">Database</a></code>.

<pre><code>
: (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}
</code></pre>

<dt><a name="upp?"><code>(upp? 'any) -> sym | NIL</code></a> <dd>Returns
<code>any</code> when the argument is a string (symbol) that starts with an
uppercase character. See also <code><a href="refU.html#uppc">uppc</a></code> and
<code><a href="refL.html#low?">low?</a></code>

<pre><code>
: (upp? "A")
-> T
: (upp? "a")
-> NIL
: (upp? 123)
-> NIL
: (upp? ".")
-> NIL
</code></pre>

<dt><a name="uppc"><code>(uppc 'any) -> any</code></a>
<dd>Upper case conversion: If <code>any</code> is not a symbol, it is returned
as it is. Otherwise, a new transient symbol with all characters of
<code>any</code>, converted to upper case, is returned. See also <code><a
href="refL.html#lowc">lowc</a></code>, <code><a
href="refF.html#fold">fold</a></code> and <code><a
href="refU.html#upp?">upp?</a></code>.

<pre><code>
: (uppc 123)
-> 123
: (uppc "abc")
-> "ABC"
: (uppc 'car)
-> "CAR"
</code></pre>

<dt><a name="use"><code>(use sym . prg) -> any</code></a>
<dt><code>(use (sym ..) . prg) -> any</code>
<dd>Defines local variables. The value of the symbol <code>sym</code> - or the
values of the symbols <code>sym</code> in the list of the second form - are
saved, <code>prg</code> is executed, then the symbols are restored to their
original values. During execution of <code>prg</code>, the values of the symbols
can be temporarily modified. The return value is the result of <code>prg</code>.
See also <code><a href="refB.html#bind">bind</a></code>, <code><a
href="refJ.html#job">job</a></code> and <code><a
href="refL.html#let">let</a></code>.

<pre><code>
: (setq  X 123  Y 456)
-> 456
: (use (X Y) (setq  X 3  Y 4) (* X Y))
-> 12
: X
-> 123
: Y
-> 456
</code></pre>

<dt><a name="useKey"><code>(useKey 'var 'cls ['hook]) -> num</code></a>
<dd>Generates or reuses a key for a database tree, by randomly trying to locate
a free number. See also <code><a href="refG.html#genKey">genKey</a></code>.

<pre><code>
: (maxKey (tree 'nr '+Item))
-> 8
: (useKey 'nr '+Item)
-> 12
</code></pre>

<dt><a name="usec"><code>(usec) -> num</code></a>
<dd>Returns the number the microseconds since interpreter startup. See also
<code><a href="refT.html#time">time</a></code> and <code><a
href="refT.html#tick">tick</a></code>.

<pre><code>
: (usec)
-> 1154702479219050
</code></pre>

</dl>

</body>
</html>