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 549 550 551 552 553 554 555 556
|
<!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>F</title>
<link rel="stylesheet" href="doc.css" type="text/css">
</head>
<body>
<h1>F</h1>
<dl>
<dt><a name="*Fork"><code>*Fork</code></a>
<dd>A global variable holding a (possibly empty) <code>prg</code> body, to be
executed after a call to <code><a href="refF.html#fork">fork</a></code> in the
child process.
<pre><code>
: (push '*Fork '(off *Tmp)) # Clear '*Tmp' in child process
-> (off *Tmp)
</code></pre>
<dt><a name="+Fold"><code>+Fold</code></a>
<dd>Prefix class for maintaining <code><a
href="refF.html#fold">fold</a></code>ed indexes to <code><a
href="refS.html#+String">+String</a></code> relations. Typically used in
combination with the <code><a href="refR.html#+Ref">+Ref</a></code> or <code><a
href="refI.html#+Idx">+Idx</a></code> prefix classes. See also <code><a
href="ref.html#dbase">Database</a></code>.
<pre><code>
(rel nm (+Fold +Idx +String)) # Item Description
...
(rel tel (+Fold +Ref +String)) # Phone number
</code></pre>
<dt><a name="fail"><code>(fail) -> lst</code></a>
<dd>Constructs an empty <a href="ref.html#pilog">Pilog</a> query, i.e. a query
that will aways fail. See also <code><a href="refG.html#goal">goal</a></code>.
<pre><code>
(dm clr> () # Clear query chart in search dialogs
(query> This (fail)) )
</code></pre>
<dt><a name="fail/0"><code>fail/0</code></a>
<dd><a href="ref.html#pilog">Pilog</a> predicate that always fails. See also
<code><a href="refT.html#true/0">true/0</a></code>.
<pre><code>
: (? (fail))
-> NIL
</code></pre>
<dt><a name="fetch"><code>(fetch 'tree 'any) -> any</code></a>
<dd>Fetches a value for the key <code>any</code> from a database tree. See also
<code><a href="refT.html#tree">tree</a></code> and <code><a
href="refS.html#store">store</a></code>.
<pre><code>
: (fetch (tree 'nr '+Item) 2)
-> {3-2}
</code></pre>
<dt><a name="fifo"><code>(fifo 'var ['any ..]) -> any</code></a>
<dd>Implements a first-in-first-out structure using a circular list. When called
with <code>any</code> arguments, they will be concatenated to end of the
structure. Otherwise, the first element is removed from the structure and
returned. See also <code><a href="refQ.html#queue">queue</a></code>, <code><a
href="refP.html#push">push</a></code>, <code><a
href="refP.html#pop">pop</a></code>, <code><a
href="refR.html#rot">rot</a></code> and <code><a
href="refC.html#circ">circ</a></code>.
<pre><code>
: (fifo 'X 1)
-> 1
: (fifo 'X 2 3)
-> 3
: X
-> (3 1 2 .)
: (fifo 'X)
-> 1
: (fifo 'X)
-> 2
: X
-> (3 .)
</code></pre>
<dt><a name="file"><code>(file) -> (sym1 sym2 . num) | NIL</code></a>
<dd>Returns for the current input channel the path name <code>sym1</code>, the
file name <code>sym2</code>, and the current line number <code>num</code>. If
the current input channel is not a file, <code>NIL</code> is returned. See also
<code><a href="refI.html#info">info</a></code>, <code><a
href="refI.html#in">in</a></code> and <code><a
href="refL.html#load">load</a></code>.
<pre><code>
: (load (pack (car (file)) "localFile.l")) # Load a file in same directory
</code></pre>
<dt><a name="fill"><code>(fill 'any ['sym|lst]) -> any</code></a>
<dd>Fills a pattern <code>any</code>, by substituting <code>sym</code>, or all
symbols in <code>lst</code>, or - if no second argument is given - each pattern
symbol in <code>any</code> (see <code><a href="refP.html#pat?">pat?</a></code>),
with its current value. <code>@</code> itself is not considered a pattern symbol
here. In any case, expressions following the symbol <code>^</code> should
evaluate to lists which are then (destructively) spliced into the result. See
also <code><a href="refM.html#match">match</a></code>.
<pre><code>
: (setq @X 1234 @Y (1 2 3 4))
-> (1 2 3 4)
: (fill '@X)
-> 1234
: (fill '(a b (c @X) ((@Y . d) e)))
-> (a b (c 1234) (((1 2 3 4) . d) e))
: (let X 2 (fill (1 X 3) 'X))
-> (1 2 3)
: (fill (1 ^ (list 'a 'b 'c) 9))
-> (1 a b c 9)
: (match '(This is @X) '(This is a pen))
-> T
: (fill '(Got ^ @X))
-> (Got a pen)
</code></pre>
<dt><a name="filter"><code>(filter 'fun 'lst ..) -> lst</code></a>
<dd>Applies <code>fun</code> to each element of <code>lst</code>. When
additional <code>lst</code> arguments are given, their elements are also passed
to <code>fun</code>. Returns a list of all elements of <code>lst</code> where
<code>fun</code> returned non-<code>NIL</code>. See also <code><a
href="refF.html#fish">fish</a></code>, <code><a
href="refF.html#find">find</a></code>, <code><a
href="refP.html#pick">pick</a></code> and <code><a
href="refE.html#extract">extract</a></code>.
<pre><code>
: (filter num? (1 A 2 (B) 3 CDE))
-> (1 2 3)
</code></pre>
<dt><a name="fin"><code>(fin 'any) -> num|sym</code></a>
<dd>Returns <code>any</code> if it is an atom, otherwise the CDR of its last
cell. See also <code><a href="refL.html#last">last</a></code> and <code><a
href="refT.html#tail">tail</a></code>.
<pre><code>
: (fin 'a)
-> a
: (fin '(a . b))
-> b
: (fin '(a b . c))
-> c
: (fin '(a b c))
-> NIL
</code></pre>
<dt><a name="finally"><code>(finally exe . prg) -> any</code></a>
<dd><code>prg</code> is executed, then <code>exe</code> is evaluated, and the
result of <code>prg</code> is returned. <code>exe</code> will also be evaluated
if <code>prg</code> does not terminate normally due to a runtime error or a call
to <code><a href="refT.html#throw">throw</a></code>. See also <code><a
href="refB.html#bye">bye</a></code>, <code><a
href="refC.html#catch">catch</a></code>, <code><a
href="refQ.html#quit">quit</a></code> and <code><a href="ref.html#errors">Error
Handling</a></code>.
<pre><code>
: (finally (prinl "Done!")
(println 123)
(quit)
(println 456) )
123
Done!
: (catch 'A
(finally (prinl "Done!")
(println 1)
(throw 'A 123)
(println 2) ) )
1
Done!
-> 123
</code></pre>
<dt><a name="find"><code>(find 'fun 'lst ..) -> any</code></a>
<dd>Applies <code>fun</code> to successive elements of <code>lst</code> until
non-<code>NIL</code> is returned. Returns that element, or <code>NIL</code> if
<code>fun</code> did not return non-<code>NIL</code> for any element of
<code>lst</code>. When additional <code>lst</code> arguments are given, their
elements are also passed to <code>fun</code>. See also <code><a
href="refS.html#seek">seek</a></code>, <code><a
href="refP.html#pick">pick</a></code> and <code><a
href="refF.html#filter">filter</a></code>.
<pre><code>
: (find pair (1 A 2 (B) 3 CDE))
-> (B)
: (find '((A B) (> A B)) (1 2 3 4 5 6) (6 5 4 3 2 1))
-> 4
: (find > (1 2 3 4 5 6) (6 5 4 3 2 1)) # shorter
-> 4
</code></pre>
<dt><a name="fish"><code>(fish 'fun 'any) -> lst</code></a>
<dd>Applies <code>fun</code> to each element - and recursively to all sublists -
of <code>any</code>. Returns a list of all items where <code>fun</code> returned
non-<code>NIL</code>. See also <code><a
href="refF.html#filter">filter</a></code>.
<pre><code>
: (fish gt0 '(a -2 (1 b (-3 c 2)) 3 d -1))
-> (1 2 3)
: (fish sym? '(a -2 (1 b (-3 c 2)) 3 d -1))
-> (a b c d)
</code></pre>
<dt><a name="flg?"><code>(flg? 'any) -> flg</code></a>
<dd>Returns <code>T</code> when the argument <code>any</code> is either
<code>NIL</code> or <code>T</code>. See also <code><a
href="refB.html#bool">bool</a></code>. <code>(flg? X)</code> is equivalent to
<code>(or (not X) (=T X))</code>.
<pre><code>
: (flg? (= 3 3))
-> T
: (flg? (= 3 4))
-> T
: (flg? (+ 3 4))
-> NIL
</code></pre>
<dt><a name="flip"><code>(flip 'lst ['cnt]) -> lst</code></a>
<dd>Returns <code>lst</code> (destructively) reversed. Without the optional
<code>cnt</code> argument, the whole list is flipped, otherwise only the first
<code>cnt</code> elements. See also <code><a
href="refR.html#reverse">reverse</a></code> and <code><a
href="refR.html#rot">rot</a></code>.
<pre><code>
: (flip (1 2 3 4)) # Flip all four elements
-> (4 3 2 1)
: (flip (1 2 3 4 5 6) 3) # Flip only the first three elements
-> (3 2 1 4 5 6)
</code></pre>
<dt><a name="flush"><code>(flush) -> flg</code></a>
<dd>Flushes the current output stream by writing all buffered data. A call to
<code>flush</code> for standard output is done automatically before a call to
<code><a href="refK.html#key">key</a></code>. Returns <code>T</code> when
successful. See also <code><a href="refR.html#rewind">rewind</a></code>.
<pre><code>
: (flush)
-> T
</code></pre>
<dt><a name="fmt64"><code>(fmt64 'num) -> sym</code></a>
<dt><code>(fmt64 'sym) -> num</code>
<dd>Converts a number <code>num</code> to a string in base-64 notation, or a
base-64 formatted string to a number. The digits are represented with the
characters <code>0</code> - <code>9</code>, <code>:</code>, <code>;</code>,
<code>A</code> - <code>Z</code> and <code>a</code> - <code>z</code>. This format
is used internally for the names of <code><a
href="ref.html#external-io">external symbols</a></code> in the 32-bit version.
See also <code><a href="refH.html#hax">hax</a></code>, <code><a
href="refH.html#hex">hex</a></code>, <code><a
href="refB.html#bin">bin</a></code> and <code><a
href="refO.html#oct">oct</a></code>.
<pre><code>
: (fmt64 9)
-> "9"
: (fmt64 10)
-> ":"
: (fmt64 11)
-> ";"
: (fmt64 12)
-> "A"
: (fmt64 "100")
-> 4096
</code></pre>
<dt><a name="fold"><code>(fold 'any ['cnt]) -> sym</code></a>
<dd>Folding to a canonical form: If <code>any</code> is not a symbol,
<code>NIL</code> is returned. Otherwise, a new transient symbol with all digits
and all letters of <code>any</code>, converted to lower case, is returned. If
the <code>cnt</code> argument is given, the result is truncated to that length
(or not truncated if <code>cnt</code> is zero). Otherwise <code>cnt</code>
defaults to 24. See also <code><a href="refL.html#lowc">lowc</a></code>.
<pre><code>
: (fold " 1A 2-b/3")
-> "1a2b3"
: (fold " 1A 2-B/3" 3)
-> "1a2"
</code></pre>
<dt><a name="fold/3"><code>fold/3</code></a>
<dd><a href="ref.html#pilog">Pilog</a> predicate that succeeds if the first
argument, after <code><a href="refF.html#fold">fold</a></code>ing it to a
canonical form, is a <i>prefix</i> of the folded string representation of the
result of applying the <code><a href="refG.html#get">get</a></code> algorithm to
the following arguments. Typically used as filter predicate in <code><a
href="refS.html#select/3">select/3</a></code> database queries. See also
<code><a href="refP.html#pre?">pre?</a></code>, <code><a
href="refI.html#isa/2">isa/2</a></code>, <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="refP.html#part/3">part/3</a></code> and <code><a
href="refT.html#tolr/3">tolr/3</a></code>.
<pre><code>
: (?
@Nr (1 . 5)
@Nm "main"
(select (@Item)
((nr +Item @Nr) (nm +Item @Nm))
(range @Nr @Item nr)
(fold @Nm @Item nm) ) )
@Nr=(1 . 5) @Nm="main" @Item={3-1}
-> NIL
</code></pre>
<dt><a name="for"><code>(for sym 'num ['any | (NIL 'any . prg) | (T 'any . prg) ..]) -> any</code></a>
<dt><code>(for sym|(sym2 . sym) 'lst ['any | (NIL 'any . prg) | (T 'any . prg) ..]) -> any</code>
<dt><code>(for (sym|(sym2 . sym) 'any1 'any2 [. prg]) ['any | (NIL 'any . prg) | (T 'any . prg) ..]) -> any</code>
<dd>Conditional loop with local variable(s) and multiple conditional exits: In
the first form, the value of <code>sym</code> is saved, <code>sym</code> is
bound to <code>1</code>, and the body is executed with increasing values up to
(and including) <code>num</code>. In the second form, the value of
<code>sym</code> is saved, <code>sym</code> is subsequently bound to the
elements of <code>lst</code>, and the body is executed each time. In the third
form, the value of <code>sym</code> is saved, and <code>sym</code> is bound to
<code>any1</code>. If <code>sym2</code> is given, it is treated as a counter
variable, first bound to 1 and then incremented for each execution of the body.
While the condition <code>any2</code> evaluates to non-<code>NIL</code>, the
body is repeatedly executed and, if <code>prg</code> is given, <code>sym</code>
is re-bound to the result of its evaluation. If a clause has <code>NIL</code> or
<code>T</code> as its CAR, the clause's second element is evaluated as a
condition and - if the result is <code>NIL</code> or non-<code>NIL</code>,
respectively - the <code>prg</code> is executed and the result returned. If the
body is never executed, <code>NIL</code> is returned. See also <code><a
href="refD.html#do">do</a></code> and <code><a
href="refL.html#loop">loop</a></code>.
<pre><code>
: (for (N 1 (>= 8 N) (inc N)) (printsp N))
1 2 3 4 5 6 7 8 -> 8
: (for (L (1 2 3 4 5 6 7 8) L) (printsp (pop 'L)))
1 2 3 4 5 6 7 8 -> 8
: (for X (1 a 2 b) (printsp X))
1 a 2 b -> b
: (for ((I . L) '(a b c d e f) L (cddr L)) (println I L))
1 (a b c d e f)
2 (c d e f)
3 (e f)
-> (e f)
: (for (I . X) '(a b c d e f) (println I X))
1 a
2 b
3 c
4 d
5 e
6 f
-> f
</code></pre>
<dt><a name="for/2"><code>for/2</code></a>
<dt><a name="for/3"><code>for/3</code></a>
<dt><a name="for/4"><code>for/4</code></a>
<dd><a href="ref.html#pilog">Pilog</a> predicate that generates a sequence of
numbers. See also <code><a href="refF.html#for">for</a></code> and <code><a
href="refR.html#range">range</a></code>.
<pre><code>
: (? (for @I 3))
@I=1
@I=2
@I=3
-> NIL
: (? (for @I 3 7))
@I=3
@I=4
@I=5
@I=6
@I=7
-> NIL
: (? (for @I 7 3 2))
@I=7
@I=5
@I=3
-> NIL
</code></pre>
<dt><a name="fork"><code>(fork) -> pid | NIL</code></a>
<dd>Forks a child process. Returns <code>NIL</code> in the child, and the
child's process ID <code>pid</code> in the parent. In the child, the
<code>VAL</code> of the global variable <code><a
href="refF.html#*Fork">*Fork</a></code> (should be a <code>prg</code>) is
executed. See also <code><a href="refP.html#pipe">pipe</a></code> and <code><a
href="refT.html#tell">tell</a></code>.
<pre><code>
: (unless (fork) (do 5 (println 'OK) (wait 1000)) (bye))
-> NIL
OK # Child's output
: OK
OK
OK
OK
</code></pre>
<dt><a name="forked"><code>(forked)</code></a>
<dd>Installs maintenance code in <code><a
href="refF.html#*Fork">*Fork</a></code> to close server sockets and clean up
<code><a href="refR.html#*Run">*Run</a></code> code in child processes. Should
only be called immediately after <code><a href="refT.html#task">task</a></code>.
<pre><code>
: (task -60000 60000 (msg 'OK)) # Install timer task
-> (-60000 60000 (msg 'OK))
: (forked) # No timer in child processes
-> (task -60000)
: *Run
-> ((-60000 56432 (msg 'OK)))
: *Fork
-> ((task -60000) (del '(saveHistory) '*Bye))
</code></pre>
<dt><a name="format"><code>(format 'num ['cnt ['sym1 ['sym2]]]) -> sym</code></a>
<dt><code>(format 'sym|lst ['cnt ['sym1 ['sym2]]]) -> num</code>
<dd>Converts a number <code>num</code> to a string, or a string
<code>sym|lst</code> to a number. In both cases, optionally a precision
<code>cnt</code>, a decimal-separator <code>sym1</code> and a
thousands-separator <code>sym2</code> can be supplied. Returns <code>NIL</code>
if the conversion is unsuccessful. See also <a
href="ref.html#num-io">Numbers</a> and <code><a
href="refR.html#round">round</a></code>.
<pre><code>
: (format 123456789) # Integer conversion
-> "123456789"
: (format 123456789 2) # Fixed point
-> "1234567.89"
: (format 123456789 2 ",") # Comma as decimal-separator
-> "1234567,89"
: (format 123456789 2 "," ".") # and period as thousands-separator
-> "1.234.567,89"
: (format "123456789") # String to number
-> 123456789
: (format (1 "23" (4 5 6)))
-> 123456
: (format "1234567.89" 4) # scaled to four digits
-> 12345678900
: (format "1.234.567,89") # separators not recognized
-> NIL
: (format "1234567,89" 4 ",")
-> 12345678900
: (format "1.234.567,89" 4 ",") # thousands-separator not recognized
-> NIL
: (format "1.234.567,89" 4 "," ".")
-> 12345678900
</code></pre>
<dt><a name="free"><code>(free 'cnt) -> (sym . lst)</code></a>
<dd>Returns, for the <code>cnt</code>'th database file, the next available
symbol <code>sym</code> (i.e. the first symbol greater than any symbol in the
database), and the list <code>lst</code> of free symbols. See also <code><a
href="refS.html#seq">seq</a></code>, <code><a
href="refZ.html#zap">zap</a></code> and <code><a
href="refD.html#dbck">dbck</a></code>.
<pre><code>
: (pool "x") # A new database
-> T
: (new T) # Create a new symbol
-> {2}
: (new T) # Create another symbol
-> {3}
: (commit) # Commit changes
-> T
: (zap '{2}) # Delete the first symbol
-> {2}
: (free 1) # Show free list
-> ({4}) # {3} was the last symbol allocated
: (commit) # Commit the deletion of {2}
-> T
: (free 1) # Now {2} is in the free list
-> ({4} {2})
</code></pre>
<dt><a name="from"><code>(from 'any ..) -> sym</code></a>
<dd>Skips the current input channel until one of the strings <code>any</code> is
found, and starts subsequent reading from that point. The found <code>any</code>
argument, or <code>NIL</code> (if none is found) is returned. See also <code><a
href="refT.html#till">till</a></code> and <code><a
href="refE.html#echo">echo</a></code>.
<pre><code>
: (and (from "val='") (till "'" T))
test val='abc'
-> "abc"
</code></pre>
<dt><a name="full"><code>(full 'any) -> bool</code></a>
<dd>Returns <code>NIL</code> if <code>any</code> is a non-empty list with at
least one <code>NIL</code> element, otherwise <code>T</code>. <code>(full
X)</code> is equivalent to <code>(not (memq NIL X))</code>.
<pre><code>
: (full (1 2 3))
-> T
: (full (1 NIL 3))
-> NIL
: (full 123)
-> T
</code></pre>
<dt><a name="fun?"><code>(fun? 'any) -> any</code></a>
<dd>Returns <code>NIL</code> when the argument <code>any</code> is neither a
number suitable for a code-pointer, nor a list suitable for a lambda expression
(function). Otherwise a number is returned for a code-pointer, <code>T</code>
for a function without arguments, and a single formal parameter or a list of
formal parameters for a function. See also <code><a
href="refG.html#getd">getd</a></code>.
<pre><code>
: (fun? 1000000000) # Might be a code pointer
-> 1000000000
: (fun? 100000000000000) # Too big for a code pointer
-> NIL
: (fun? 1000000001) # Cannot be a code pointer (odd)
-> NIL
: (fun? '((A B) (* A B))) # Lambda expression
-> (A B)
: (fun? '((A B) (* A B) . C)) # Not a lambda expression
-> NIL
: (fun? '(1 2 3 4)) # Not a lambda expression
-> NIL
: (fun? '((A 2 B) (* A B))) # Not a lambda expression
-> NIL
</code></pre>
</dl>
</body>
</html>
|