File: ref_.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 (548 lines) | stat: -rw-r--r-- 17,886 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
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
<!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>Other</title>
<link rel="stylesheet" href="doc.css" type="text/css">
</head>
<body>

<h1>Other</h1>

<dl>

<dt><a name="!"><code>(! . exe) -> any</code></a>
<dd>Low level breakpoint function: The current execution environment is saved
and the I/O channels are redirected to the console. Then <code>exe</code> is
displayed, and a read-eval-print-loop is entered (with <code>!</code> as its
prompt character), to evaluate expressions and examine the current program
environment. An empty input line terminates the read-eval-print-loop, the
environment and I/O channels are restored, and the result of <code>exe</code> is
returned. <code>!</code> is normally inserted into existing programs with the
<code><a href="refD.html#debug">debug</a></code> function. See also <code><a
href="refE.html#e">e</a></code>, <code><a href="ref_.html#^">^</a></code> and
<code><a href="refD.html#*Dbg">*Dbg</a></code>.

<pre><code>
: (de foo (N) (and (println 1) (! println N) (println 2)))
-> foo
: (foo 7)
1                 # Executed '(println 1)'
(println N)       # Entered breakpoint
! N               # Examine the value of 'N'
-> 7
! (e)             # Evaluate '^', i.e. (println N)
7
-> 7
! (e @)           # Evaluate '@' -> the result of '(println 1)'
-> 1
!                 # Empty line: continue
7                 # Executed '(println N)'
2                 # Executed '(println 2)'
-> 2
</code></pre>

<dt><a name="$"><code>($ sym|lst lst . prg) -> any</code></a>
<dd>Low level trace function: The first argument <code>sym|lst</code> is printed
to the console with a proper indentation, followed by a colon <code>:</code>. If
a function is traced, the first argument is the function symbol, else if a
method is traced, it is a cons pair of message and class. The second argument
<code>lst</code> should be a list of symbols, identical to the function's
argument list. The current values of these symbols are printed, followed by a
newline. Then <code>prg</code> is executed, and its return value printed in a
similar way (this time with an equals sign <code>=</code> instead of a colon)
and returned. <code>$</code> is normally inserted into existing programs with
the <code><a href="refT.html#trace">trace</a></code> function.

<pre><code>
: (de foo (A B) ($ foo (A B) (* A B)))
-> foo
: (foo 3 4)
 foo : 3 4        # Function entry, arguments 3 and 4
 foo = 12         # Function exit, return value 12
-> 12
</code></pre>

<dt><a name="$dat"><code>($dat 'sym1 ['sym2]) -> dat</code></a>
<dd>Converts a string <code>sym1</code> in ISO format to a <code><a
href="refD.html#date">date</a></code>, optionally using a delimiter character
<code>sym2</code>. See also <code><a href="refD.html#dat$">dat$</a></code>,
<code><a href="ref_.html#$tim">$tim</a></code>, <code><a
href="refS.html#strDat">strDat</a></code> and <code><a
href="refE.html#expDat">expDat</a></code>.

<pre><code>
: ($dat "20070601")
-> 733134
: ($dat "2007-06-01" "-")
-> 733134
</code></pre>

<dt><a name="$tim"><code>($tim 'sym) -> tim</code></a>
<dd>Converts a string to a <code><a href="refT.html#time">time</a></code>. The
minutes and seconds are optional and default to zero. See also <code><a
href="refT.html#tim$">tim$</a></code> and <code><a
href="ref_.html#$dat">$dat</a></code>.

<pre><code>
: (time ($tim "10:57:56"))
-> (10 57 56)
: (time ($tim "10:57"))
-> (10 57 0)
: (time ($tim "10"))
-> (10 0 0)
</code></pre>

<dt><a name="%"><code>(% 'num ..) -> num</code></a>
<dd>Returns the remainder from the divisions of successive <code>num</code>
arguments. The sign of the result is that of the first argument. When one of the
arguments evaluates to <code>NIL</code>, it is returned immediately. See also
<code><a href="ref_.html#/">/</a></code> and <code><a
href="ref_.html#*/">*/</a></code> .

<pre><code>
: (% 17 5)
-> 2
: (% -17 5)  # Sign is that of the first argument
-> -2
: (% 5 2)
-> 1
: (% 15 10)
-> 5
: (% 15 10 2)  # (% 15 10) -> 5, then (% 5 2) -> 1
-> 1
</code></pre>

<dt><a name="&"><code>(& 'num ..) -> num</code></a>
<dd>Returns the bitwise <code>AND</code> of all <code>num</code> arguments. When
one of the arguments evaluates to <code>NIL</code>, it is returned immediately.
See also <code><a href="ref_.html#|">|</a></code>, <code><a
href="refX.html#x|">x|</a></code> and <code><a
href="refB.html#bit?">bit?</a></code>.

<pre><code>
: (& 6 3)
-> 2
: (& 7 3 1)
-> 1
</code></pre>

<dt><a name="*"><code>(* 'num ..) -> num</code></a>
<dd>Returns the product of all <code>num</code> arguments. When one of the
arguments evaluates to <code>NIL</code>, it is returned immediately. See also
<code><a href="ref_.html#/">/</a></code>, <code><a
href="ref_.html#*/">*/</a></code>, <code><a href="ref_.html#+">+</a></code> and
<code><a href="ref_.html#-">-</a></code>.

<pre><code>
: (* 1 2 3)
-> 6
: (* 5 3 2 2)
-> 60
</code></pre>

<dt><a name="**"><code>(** 'num1 'num2) -> num</code></a>
<dd>Returns <code>num1</code> to the power of <code>num2</code>.

<pre><code>
: (** 2 3)
-> 8
: (** 100 100)
-> 10000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000
</code></pre>

<dt><a name="*/"><code>(*/ 'num1 ['num2 ..] 'num3) -> num</code></a>
<dd>Returns the product of <code>num1</code> and all following <code>num2</code>
arguments, divided by the <code>num3</code> argument. The result is rounded to
the nearest integer value. When one of the arguments evaluates to
<code>NIL</code>, it is returned immediately. Note that <code>*/</code> is
especially useful for fixed point arithmetic, by multiplying with (or dividing
by) the scale factor. See also <code><a href="ref_.html#*">*</a></code>,
<code><a href="ref_.html#/">/</a></code>, <code><a
href="ref_.html#+">+</a></code> and <code><a href="ref_.html#-">-</a></code>.

<pre><code>
: (*/ 3 4 2)
-> 6
: (*/ 1234 2 10)
-> 247
: (*/ 100 6)
-> 17

: (setq *Scl 2)
-> 2
: (format (*/ 3.0 1.5 1.0) *Scl)
-> "4.50"
</code></pre>

<dt><a name="+"><code>(+ 'num ..) -> num</code></a>
<dd>Returns the sum of all <code>num</code> arguments. When one of the arguments
evaluates to <code>NIL</code>, it is returned immediately. See also <code><a
href="refI.html#inc">inc</a></code>, <code><a href="ref_.html#-">-</a></code>,
<code><a href="ref_.html#*">*</a></code>, <code><a
href="ref_.html#/">/</a></code> and <code><a href="ref_.html#*/">*/</a></code>.

<pre><code>
: (+ 1 2 3)
-> 6
</code></pre>

<dt><a name="-"><code>(- 'num ..) -> num</code></a>
<dd>Returns the difference of the first <code>num</code> argument and all
following arguments. If only a single argument is given, it is negated. When one
of the arguments evaluates to <code>NIL</code>, it is returned immediately. See
also <code><a href="refD.html#dec">dec</a></code>, <code><a
href="ref_.html#+">+</a></code>, <code><a href="ref_.html#*">*</a></code>,
<code><a href="ref_.html#/">/</a></code> and <code><a
href="ref_.html#*/">*/</a></code>.

<pre><code>
: (- 7)
-> -7
: (- 7 2 1)
-> 4
</code></pre>

<dt><a name="->"><code>(-&gt sym [num]) -> any</code></a>
<dd>Searches for the current value of the pattern variable <code>sym</code> at
top level (or level <code>num</code>) in the current <a
href="ref.html#pilog">Pilog</a> environment. See also <code><a
href="refP.html#prove">prove</a></code> and <code><a
href="refU.html#unify">unify</a></code>.

<pre><code>
: (? (append (1 2 3) (4 5 6) @X) (@ println 'X '= (-> @X)))
X = (1 2 3 4 5 6)
 @X=(1 2 3 4 5 6)
-> NIL
</code></pre>

<dt><a name="/"><code>(/ 'num ..) -> num</code></a>
<dd>Returns the first <code>num</code> argument successively divided by all
following arguments. When one of the arguments evaluates to <code>NIL</code>, it
is returned immediately. See also <code><a href="ref_.html#*">*</a></code>,
<code><a href="ref_.html#*/">*/</a></code>, <code><a
href="ref_.html#%">%</a></code>, <code><a href="ref_.html#+">+</a></code> and
<code><a href="ref_.html#-">-</a></code>.

<pre><code>
: (/ 12 3)
-> 4
: (/ 60 -3 2 2)
-> -5
</code></pre>

<dt><a name=":"><code>(: sym|0 [sym1|cnt ..]) -> any</code></a>
<dd>Fetches a value <code>any</code> from the properties of a symbol, or from a
list, by applying the <code><a href="refG.html#get">get</a></code> algorithm to
<code>This</code> and the following arguments. Used typically in methods or
<code><a href="refW.html#with">with</a></code> bodies. <code>(: ..)</code> is
equivalent to <code>(; This ..)</code>. See also <code><a
href="ref_.html#;">;</a></code>, <code><a href="ref_.html#=:">=:</a></code> and
<code><a href="ref_.html#::">::</a></code>.

<pre><code>
: (put 'X 'a 1)
-> 1
: (with 'X (: a))
-> 1
</code></pre>

<dt><a name="::"><code>(:: sym [sym1|cnt .. sym2]) -> var</code></a>
<dd>Fetches a property for a property key <code>sym</code> or <code>sym2</code>
from a symbol. That symbol is <code>This</code> (if no other arguments are
given), or a symbol found by applying the <code><a
href="refG.html#get">get</a></code> algorithm to <code>This</code> and the
following arguments. The property (the cons pair, not just its value) is
returned, suitable for direct (destructive) manipulations with functions
expecting a <code>var</code> argument. Used typically in methods or <code><a
href="refW.html#with">with</a></code> bodies. See also <code><a
href="ref_.html#=:">=:</a></code>, <code><a
href="refP.html#prop">prop</a></code> and <code><a
href="ref_.html#:">:</a></code>.

<pre><code>
: (with 'X (=: cnt 0) (inc (:: cnt)) (: cnt))
-> 1
</code></pre>

<dt><a name=";"><code>(; 'sym1|lst [sym2|cnt ..]) -> any</code></a>
<dd>Fetches a value <code>any</code> from the properties of a symbol, or from a
list, by applying the <code><a href="refG.html#get">get</a></code> algorithm to
<code>sym1|lst</code> and the following arguments. See also <code><a
href="ref_.html#:">:</a></code>, <code><a href="ref_.html#=:">=:</a></code> and
<code><a href="ref_.html#::">::</a></code>.

<pre><code>
: (put 'A 'a 1)
-> 1
: (put 'A 'b 'B)
-> B
: (put 'B 'c 7)
-> 7
: (; 'A a)
-> 1
: (; 'A b c)
-> 7
</code></pre>

<dt><a name="<"><code>(< 'any ..) -> flg</code></a>
<dd>Returns <code>T</code> when all arguments <code>any</code> are in strictly
increasing order. See also <a href="ref.html#cmp">Comparing</a>.

<pre><code>
: (< 3 4)
-> T
: (< 'a 'b 'c)
-> T
: (< 999 'a)
-> T
</code></pre>

<dt><a name="<="><code>(<= 'any ..) -> flg</code></a>
<dd>Returns <code>T</code> when all arguments <code>any</code> are in strictly
non-decreasing order. See also <a href="ref.html#cmp">Comparing</a>.

<pre><code>
: (<= 3 3)
-> T
: (<= 1 2 3)
-> T
: (<= "abc" "abc" "def")
-> T
</code></pre>

<dt><a name="<>"><code>(<&gt 'any ..) -> flg</code></a>
<dd>Returns <code>T</code> when not all <code>any</code> arguments are equal
(structure equality). <code>(<&gt 'any ..)</code> is equivalent to <code>(not (=
'any ..))</code>. See also <a href="ref.html#cmp">Comparing</a>.

<pre><code>
: (<&gt 'a 'b)
-> T
: (<&gt 'a 'b 'b)
-> T
: (<&gt 'a 'a 'a)
-> NIL
</code></pre>

<dt><a name="="><code>(= 'any ..) -> flg</code></a>
<dd>Returns <code>T</code> when all <code>any</code> arguments are equal
(structure equality). See also <a href="ref.html#cmp">Comparing</a>.

<pre><code>
: (= 6 (* 1 2 3))
-> T
: (= "a" "a")
-> T
: (== "a" "a")
-> T
: (= (1 (2) 3) (1 (2) 3))
-> T
</code></pre>

<dt><a name="=0"><code>(=0 'any) -> 0 | NIL</code></a>
<dd>Returns <code>0</code> when <code>any</code> is a number with value zero.
See also <code><a href="refN.html#n0">n0</a></code>, <code><a
href="refL.html#lt0">lt0</a></code>, <code><a
href="refL.html#le0">le0</a></code>, <code><a
href="refG.html#ge0">ge0</a></code> and <code><a
href="refG.html#gt0">gt0</a></code>.

<pre><code>
: (=0 (- 6 3 2 1))
-> 0
: (=0 'a)
-> NIL
</code></pre>

<dt><a name="=:"><code>(=: sym|0 [sym1|cnt .. sym2|0] 'any)</code></a>
<dd>Stores a new value <code>any</code> for a property key <code>sym</code> or
<code>sym2</code> (or in the symbol value for zero) in a symbol. That symbol is
<code>This</code> (if no other arguments are given), or a symbol found by
applying the <code><a href="refG.html#get">get</a></code> algorithm to
<code>This</code> and the following arguments. Used typically in methods or
<code><a href="refW.html#with">with</a></code> bodies. See also <code><a
href="refP.html#put">put</a></code>, <code><a href="ref_.html#:">:</a></code>
and <code><a href="ref_.html#::">::</a></code>.

<pre><code>
: (with 'X (=: a 1) (=: b 2))
-> 2
: (get 'X 'a)
-> 1
: (get 'X 'b)
-> 2
</code></pre>

<dt><a name="=="><code>(== 'any ..) -> flg</code></a>
<dd>Returns <code>T</code> when all <code>any</code> arguments are the same
(pointer equality). See also <code><a href="refN.html#n==">n==</a></code> and <a
href="ref.html#cmp">Comparing</a>.

<pre><code>
: (== 'a 'a)
-> T
: (== 'NIL NIL (val NIL) (car NIL) (cdr NIL))
-> T
: (== (1 2 3) (1 2 3))
-> NIL
</code></pre>

<dt><a name="===="><code>(==== ['sym ..]) -> NIL</code></a>
<dd>Close the current transient scope by clearing the transient index. All
transient symbols become hidden and inaccessible by the reader. Then any
optional <code>sym</code> arguments are (re-)inserted into the transient index.
See also <code><a href="refE.html#extern">extern</a></code> and <code><a
href="refI.html#intern">intern</a></code>.

<pre><code>
: (setq S "abc")           # Read "abc"
-> "abc"
: (== S "abc")             # Read again, get the same symbol
-> T
: (====)                   # Close scope
-> NIL
: (== S "abc")             # Read again, get another symbol
-> NIL
</code></pre>

<dt><a name="=T"><code>(=T 'any) -> flg</code></a>
<dd>Returns <code>T</code> when <code>any</code> is the symbol <code>T</code>.
<code>(=T X)</code> is equivalent to <code>(== T X)</code>. See also <a
href="refN.html#nT">nT</a>.

<pre><code>
: (=T 0)
-> NIL
: (=T "T")
-> NIL
: (=T T)
-> T
</code></pre>

<dt><a name=">"><code>(> 'any ..) -> flg</code></a>
<dd>Returns <code>T</code> when all arguments <code>any</code> are in strictly
decreasing order. See also <a href="ref.html#cmp">Comparing</a>.

<pre><code>
: (> 4 3)
-> T
: (> 'A 999)
-> T
</code></pre>

<dt><a name=">="><code>(>= 'any ..) -> flg</code></a>
<dd>Returns <code>T</code> when all arguments <code>any</code> are in strictly
non-increasing order. See also <a href="ref.html#cmp">Comparing</a>.

<pre><code>
: (>= 'A 999)
-> T
: (>= 3 2 2 1)
-> T
</code></pre>

<dt><a name=">>"><code>(>> 'cnt 'num) -> num</code></a>
<dd>Shifts right the <code>num</code> argument by <code>cnt</code>
bit-positions. If <code>cnt</code> is negative, a corresponding left shift is
performed.

<pre><code>
: (>> 1 8)
-> 4
: (>> 3 16)
-> 2
: (>> -3 16)
-> 128
: (>> -1 -16)
-> -32
</code></pre>

<dt><a name="?"><code>(? [sym ..] [pat 'any ..] . lst) -> flg</code></a>
<dd>Top-level function for interactive <a href="ref.html#pilog">Pilog</a>
queries. <code>?</code> is a non-evaluating front-end to the <code><a
href="refQ.html#query">query</a></code> function. It displays each result, waits
for console input, and terminates when a non-empty line is entered. If a
preceding list of (non-pattern-) symbols is given, they will be taken as rules
to be traced by <code><a href="refP.html#prove">prove</a></code>. The list of
variable/value pairs is passed to <code><a href="refG.html#goal">goal</a></code>
for an initial Pilog environment. See also <code><a
href="refP.html#pilog">pilog</a></code> and <code><a
href="refS.html#solve">solve</a></code>.

<pre><code>
: (? (append (a b c) (d e f) @X))
 @X=(a b c d e f)
-> NIL

: (? (append @X @Y (a b c)))
 @X=NIL @Y=(a b c)
 @X=(a) @Y=(b c)
 @X=(a b) @Y=(c)
 @X=(a b c) @Y=NIL
-> NIL

: (? (append @X @Y (a b c)))
 @X=NIL @Y=(a b c).                    # Stopped
-> NIL

: (? append (append @X @Y (a b c)))    # Trace 'append'
1 (append NIL (a b c) (a b c))
 @X=NIL @Y=(a b c)                                  
2 (append (a . @X) @Y (a b c))
1 (append NIL (b c) (b c))
 @X=(a) @Y=(b c).                      # Stopped                       
-> NIL
</code></pre>

<dt><a name="@"><code>@</code></a>
<dd>Holds the result of the last top level expression in the current
read-eval-print loop, or the result of the conditional expression during the
evaluation of flow functions (see <code><a href="ref.html#atres">@
Result</a></code>). When <code>@</code> is used as a formal parameter in <a
href="ref.html#lambda">lambda expressions</a>, it denotes a variable number of
evaluated arguments.

<dt><a name="@@"><code>@@</code></a>
<dd>Holds the result of the second last top level expression in the current
read-eval-print loop (see <code><a href="ref.html#atres">@ Result</a></code>).

<dt><a name="@@@"><code>@@@</code></a>
<dd>Holds the result of the third last top level expression in the current
read-eval-print loop (see <code><a href="ref.html#atres">@ Result</a></code>).

<dt><a name="^"><code>^</code></a>
<dd>Holds the currently executed expression during a breakpoint or an error. See
also <code><a href="refD.html#debug">debug</a></code>, <code><a
href="ref_.html#!">!</a></code>, <code><a href="refE.html#e">e</a></code> and
<code><a href="refD.html#*Dbg">*Dbg</a></code>.

<pre><code>
: (* (+ 3 4) (/ 7 0))
!? (/ 7 0)
Div/0
? ^
-> (/ 7 0)
</code></pre>

<dt><a name="|"><code>(| 'num ..) -> num</code></a>
<dd>Returns the bitwise <code>OR</code> of all <code>num</code> arguments. When
one of the arguments evaluates to <code>NIL</code>, it is returned immediately.
See also <code><a href="refX.html#x|">x|</a></code>, <code><a
href="ref_.html#&">&</a></code> and <code><a
href="refB.html#bit?">bit?</a></code>.

<pre><code>
: (| 1 2)
-> 3
: (| 1 2 4 8)
-> 15
</code></pre>

</dl>

</body>
</html>