File: refI.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 (410 lines) | stat: -rw-r--r-- 14,905 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
410
<!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>I</title>
<link rel="stylesheet" href="doc.css" type="text/css">
</head>
<body>

<h1>I</h1>

<dl>

<dt><a name="+Idx"><code>+Idx</code></a>
<dd>Prefix class for maintaining non-unique full-text indexes to <code><a
href="refS.html#+String">+String</a></code> relations, a subclass of <code><a
href="refR.html#+Ref">+Ref</a></code>. Accepts optional arguments for the
minimally indexed substring length (defaults to 3), and a <code><a
href="refH.html#+Hook">+Hook</a></code> attribute. Often used in combination
with the <code><a href="refS.html#+Sn">+Sn</a></code> soundex index, or the
<code><a href="refF.html#+Fold">+Fold</a></code> index prefix classes. See also
<code><a href="ref.html#dbase">Database</a></code>.

<pre><code>
(rel nm (+Sn +Idx +String))  # Name
</code></pre>

<dt><a name="+index"><code>+index</code></a>
<dd>Abstract base class of all database B-Tree index relations (prefix classes
for <code><a href="refR.html#+relation">+relation</a></code>s). The class
hierarchy includes <code><a href="refK.html#+Key">+Key</a></code>, <code><a
href="refR.html#+Ref">+Ref</a></code> and <code><a
href="refI.html#+Idx">+Idx</a></code>. See also <code><a
href="ref.html#dbase">Database</a></code>.

<pre><code>
(isa '+index Rel)  # Check for an index relation
</code></pre>

<dt><a name="id"><code>(id 'num ['num]) -> sym</code></a>
<dt><code>(id 'sym [NIL]) -> num</code>
<dt><code>(id 'sym T) -> (num . num)</code>
<dd>Converts one or two numbers to an external symbol, or an external symbol to
a number or a pair of numbers.

<pre><code>
: (id 7)
-> {7}
: (id 1 2)
-> {2}
: (id '{1-2})
-> 2
: (id '{1-2} T)
-> (1 . 2)
</code></pre>

<dt><a name="idx"><code>(idx 'var 'any 'flg) -> lst<br>
(idx 'var 'any) -> lst<br>
(idx 'var) -> lst</code></a>
<dd>Maintains an index tree in <code>var</code>, and checks for the existence of
<code>any</code>. If <code>any</code> is contained in <code>var</code>, the
corresponding subtree is returned, otherwise <code>NIL</code>. In the first
form, <code>any</code> is destructively inserted into the tree if
<code>flg</code> is non-<code>NIL</code> (and <code>any</code> was not already
there), or deleted from the tree if <code>flg</code> is <code>NIL</code>. The
second form only checks for existence, but does not change the index tree. In
the third form (when called with a single <code>var</code> argument) 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 also <code><a
href="refL.html#lup">lup</a></code>, <code><a
href="refH.html#hash">hash</a></code>, <code><a
href="refD.html#depth">depth</a></code>, <code><a
href="refS.html#sort">sort</a></code>, <code><a
href="refB.html#balance">balance</a></code> and <code><a
href="refM.html#member">member</a></code>.

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

<dt><a name="if"><code>(if 'any1 'any2 . prg) -> any</code></a>
<dd>Conditional execution: If the condition <code>any1</code> evaluates to
non-<code>NIL</code>, <code>any2</code> is evaluated and returned. Otherwise,
<code>prg</code> is executed and the result returned. See also <code><a
href="refC.html#cond">cond</a></code>, <code><a
href="refW.html#when">when</a></code> and <code><a
href="refI.html#if2">if2</a></code>.

<pre><code>
: (if (> 4 3) (println 'OK) (println 'Bad))
OK
-> OK
: (if (> 3 4) (println 'OK) (println 'Bad))
Bad
-> Bad
</code></pre>

<dt><a name="if2"><code>(if2 'any1 'any2 'any3 'any4 'any5 . prg) -> any</code></a>
<dd>Four-way conditional execution for two conditions: If both conditions
<code>any1</code> and <code>any2</code> evaluate to non-<code>NIL</code>,
<code>any3</code> is evaluated and returned. Otherwise, <code>any4</code> or
<code>any5</code> is evaluated and returned if <code>any1</code> or
<code>any2</code> evaluate to non-<code>NIL</code>, respectively. If none of the
conditions evaluate to non-<code>NIL</code>, <code>prg</code> is executed and
the result returned. See also <code><a href="refI.html#if">if</a></code> and
<code><a href="refC.html#cond">cond</a></code>.

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

<dt><a name="ifn"><code>(ifn 'any1 'any2 . prg) -> any</code></a>
<dd>Conditional execution ("If not"): If the condition <code>any1</code>
evaluates to <code>NIL</code>, <code>any2</code> is evaluated and returned.
Otherwise, <code>prg</code> is executed and the result returned.

<pre><code>
: (ifn (= 3 4) (println 'OK) (println 'Bad))
OK
-> OK
</code></pre>

<dt><a name="import"><code>(import lst) -> NIL</code></a>
<dd>Wrapper function for <code><a href="refI.html#intern">intern</a></code>.
Typically used to import symbols from other namespaces, as created by <code><a
href="refS.html#symbols">symbols</a></code>. <code>lst</code> should be a list
of symbols. An import conflict error is issued when a symbol with the same name
already exists in the current namespace. See also <code><a
href="refP.html#pico">pico</a></code> and <code><a
href="refL.html#local">local</a></code>.

<pre><code>
: (import libA~foo libB~bar)
-> NIL
</code></pre>

<dt><a name="in"><code>(in 'any . prg) -> any</code></a>
<dd>Opens <code>any</code> as input channel during the execution of
<code>prg</code>. The current input channel will be saved and restored
appropriately. If the argument is <code>NIL</code>, standard input is used. If
the argument is a symbol, it is used as a file name (opened for reading
<i>and</i> writing if the first character is "<code>+</code>"). 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. See also <code><a
href="refI.html#ipid">ipid</a></code>, <code><a
href="refC.html#call">call</a></code>, <code><a
href="refL.html#load">load</a></code>, <code><a
href="refF.html#file">file</a></code>, <code><a
href="refO.html#out">out</a></code>, <code><a
href="refE.html#err">err</a></code>, <code><a
href="refP.html#poll">poll</a></code>, <code><a
href="refP.html#pipe">pipe</a></code> and <code><a
href="refC.html#ctl">ctl</a></code>.

<pre><code>
: (in "a" (list (read) (read) (read)))  # Read three items from file "a"
-> (123 (a b c) def)
</code></pre>

<dt><a name="inc"><code>(inc 'num) -> num<br>
(inc 'var ['num]) -> num</code></a>
<dd>The first form returns the value of <code>num</code> incremented by 1. The
second form increments the <code>VAL</code> of <code>var</code> by 1, or by
<code>num</code>. If the first argument is <code>NIL</code>, it is returned
immediately. <code>(inc 'num)</code> is equivalent to <code>(+ 'num 1)</code>
and <code>(inc 'var)</code> is equivalent to <code>(set 'var (+ var 1))</code>.
See also <code><a href="refD.html#dec">dec</a></code> and <code><a
href="ref_.html#+">+</a></code>.

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

<dt><a name="inc!"><code>(inc! 'obj 'sym ['num]) -> num</code></a>
<dd><a href="ref.html#trans">Transaction</a> wrapper function for <code><a
href="refI.html#inc">inc</a></code>. <code>num</code> defaults to 1. Note that
for incrementing a property value of an entity typically the <code><a
href="refE.html#entityMesssages">inc!></a></code> message is used. See also
<code><a href="refN.html#new!">new!</a></code>, <code><a
href="refS.html#set!">set!</a></code> and <code><a
href="refP.html#put!">put!</a></code>.

<pre><code>
(inc! Obj 'cnt 0)  # Incrementing a property of a non-entity object
</code></pre>

<dt><a name="index"><code>(index 'any 'lst) -> cnt | NIL</code></a>
<dd>Returns the <code>cnt</code> position of <code>any</code> in
<code>lst</code>, or <code>NIL</code> if it is not found. See also <code><a
href="refO.html#offset">offset</a></code>.

<pre><code>
: (index 'c '(a b c d e f))
-> 3
: (index '(5 6) '((1 2) (3 4) (5 6) (7 8)))
-> 3
</code></pre>

<dt><a name="info"><code>(info 'any) -> (cnt|T dat . tim)</code></a>
<dd>Returns information about a file with the name <code>any</code>: The current
size <code>cnt</code> in bytes, and the modification date and time (UTC). For
directories, <code>T</code> is returned instead of the a size. See also <code><a
href="refD.html#dir">dir</a></code>, <code><a
href="refD.html#date">date</a></code>, <code><a
href="refT.html#time">time</a></code> and <code><a
href="refL.html#lines">lines</a></code>.

<pre><code>
$ 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"
</code></pre>

<dt><a name="init"><code>(init 'tree ['any1] ['any2]) -> lst</code></a>
<dd>Initializes a structure for stepping iteratively through a database tree.
<code>any1</code> and <code>any2</code> may specify a range of keys. If
<code>any2</code> is greater than <code>any1</code>, the traversal will be in
opposite direction. See also <code><a href="refT.html#tree">tree</a></code>,
<code><a href="refS.html#step">step</a></code>, <code><a
href="refI.html#iter">iter</a></code> and <code><a
href="refS.html#scan">scan</a></code>.

<pre><code>
: (init (tree 'nr '+Item) 3 5)
-> (((3 . 5) ((3 NIL . {3-3}) (4 NIL . {3-4}) (5 NIL . {3-5}) (6 NIL . {3-6}) (7 NIL . {3-8}))))
</code></pre>

<dt><a name="insert"><code>(insert 'cnt 'lst 'any) -> lst</code></a>
<dd>Inserts <code>any</code> into <code>lst</code> at position <code>cnt</code>.
This is a non-destructive operation. See also <code><a
href="refR.html#remove">remove</a></code>, <code><a
href="refP.html#place">place</a></code>, <code><a
href="refA.html#append">append</a></code>, <code><a
href="refD.html#delete">delete</a></code> and <code><a
href="refR.html#replace">replace</a></code>.

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

<dt><a name="intern"><code>(intern 'sym) -> sym</code></a>
<dd>Creates or finds an internal symbol. If a symbol with the name
<code>sym</code> is already intern, it is returned. Otherwise, <code>sym</code>
is interned and returned. See also <code><a
href="refS.html#symbols">symbols</a></code>, <code><a
href="refZ.html#zap">zap</a></code>, <code><a
href="refE.html#extern">extern</a></code> and <code><a
href="ref_.html#====">====</a></code>.

<pre><code>
: (intern "abc")
-> abc
: (intern 'car)
-> car
: ((intern (pack "c" "a" "r")) (1 2 3))
-> 1
</code></pre>

<dt><a name="ipid"><code>(ipid) -> pid | NIL</code></a>
<dd>Returns the corresponding process ID when the current input channel is
reading from a pipe, otherwise <code>NIL</code>. See also <code><a
href="refO.html#opid">opid</a></code>, <code><a
href="refI.html#in">in</a></code>, <code><a
href="refP.html#pipe">pipe</a></code> and <code><a
href="refL.html#load">load</a></code>.

<pre><code>
: (in '(ls "-l") (println (line T)) (kill (ipid)))
"total 7364"
-> T
</code></pre>

<dt><a name="isa"><code>(isa 'cls|typ 'obj) -> obj | NIL</code></a>
<dd>Returns <code>obj</code> when it is an object that inherits from
<code>cls</code> or <code>type</code>. See also <code><a href="ref.html#oop">OO
Concepts</a></code>, <code><a href="refC.html#class">class</a></code>, <code><a
href="refT.html#type">type</a></code>, <code><a
href="refN.html#new">new</a></code> and <code><a
href="refO.html#object">object</a></code>.

<pre><code>
: (isa '+Address Obj)
-> {1-17}
: (isa '(+Male +Person) Obj)
-> NIL
</code></pre>

<dt><a name="isa/2"><code>isa/2</code></a>
<dd><a href="ref.html#pilog">Pilog</a> predicate that succeeds if the second
argument is of the type or class given by the first argument, according to the
<code><a href="refI.html#isa">isa</a></code> function. Typically used in
<code><a href="refD.html#db/3">db/3</a></code> or <code><a
href="refS.html#select/3">select/3</a></code> database queries. See also
<code><a href="refS.html#same/3">same/3</a></code>, <code><a
href="refB.html#bool/3">bool/3</a></code>, <code><a
href="refR.html#range/3">range/3</a></code>, <code><a
href="refH.html#head/3">head/3</a></code>, <code><a
href="refF.html#fold/3">fold/3</a></code>, <code><a
href="refP.html#part/3">part/3</a></code> and <code><a
href="refT.html#tolr/3">tolr/3</a></code>.

<pre><code>
: (? (db nm +Person @Prs) (isa +Woman @Prs) (val @Nm @Prs nm))
 @Prs={2-Y} @Nm="Alexandra of Denmark"
 @Prs={2-1I} @Nm="Alice Maud Mary"
 @Prs={2-F} @Nm="Anne"
 @Prs={2-j} @Nm="Augusta Victoria".   # Stop
</code></pre>

<dt><a name="iter"><code>(iter 'tree ['fun] ['any1] ['any2] ['flg])</code></a>
<dd>Iterates through a database tree by applying <code>fun</code> to all values.
<code>fun</code> defaults to <code><a
href="refP.html#println">println</a></code>. <code>any1</code> and
<code>any2</code> may specify a range of keys. If <code>any2</code> is greater
than <code>any1</code>, the traversal will be in opposite direction. Note that
the keys need not to be atomic, depending on the application's index structure.
If <code>flg</code> is non-<code>NIL</code>, partial keys are skipped. See also
<code><a href="refT.html#tree">tree</a></code>, <code><a
href="refS.html#scan">scan</a></code>, <code><a
href="refI.html#init">init</a></code> and <code><a
href="refS.html#step">step</a></code>.

<pre><code>
: (iter (tree 'nr '+Item))
{3-1}
{3-2}
{3-3}
{3-4}
{3-5}
{3-6}
{3-8}
-> {7-1}
: (iter (tree 'nr '+Item) '((This) (println (: nm))))
"Main Part"
"Spare Part"
"Auxiliary Construction"
"Enhancement Additive"
"Metal Fittings"
"Gadget Appliance"
"Testartikel"
-> {7-1}
</code></pre>

</dl>

</body>
</html>