- *Fork
- A global variable holding a (possibly empty) prgbody, to be
executed after a call toforkin the
child process.
: (push '*Fork '(off *Tmp))   # Clear '*Tmp' in child process
-> (off *Tmp)
 
- +Fold
- Prefix class for maintaining folded indexes to+Stringrelations. Typically used in
combination with the+Refor+Idxprefix classes. See also+IdxFoldand Database.
(rel nm (+Fold +Idx +String))   # Item Description
...
(rel tel (+Fold +Ref +String))  # Phone number
 
- (fail) -> lst
- Constructs an empty Pilog query, i.e. a query
that will always fail. See also goal.
(dm clr> ()                # Clear query chart in search dialogs
   (query> This (fail)) )
 
- fail/0
- Pilog predicate that always fails. See also
true/0.
: (? (fail))
-> NIL
 
- (fd) -> cnt
- Return the current file descriptor, typically of the closes inoroutchannel. See alsoipidandopid.
: (in "@lib.l" (fd))
-> 3
 
- (fetch 'tree 'any) -> any
- Fetches a value for the key anyfrom a database tree. See alsotreeandstore.
: (fetch (tree 'nr '+Item) 2)
-> {3-2}
 
- (fifo 'var ['any ..]) -> any
- Implements a first-in-first-out structure using a circular list. When called
with anyarguments, they will be concatenated to end of the
structure. Otherwise, the first element is removed from the structure and
returned. See alsoqueue,push,pop,rotandcirc.
: (fifo 'X 1)
-> 1
: (fifo 'X 2 3)
-> 3
: X
-> (3 1 2 .)
: (fifo 'X)
-> 1
: (fifo 'X)
-> 2
: X
-> (3 .)
 
- (file) -> (sym1 sym2 . num) | NIL
- Returns for the current input channel the path name sym1, the
file namesym2, and the current line numbernum. If
the current input channel is not a file,NILis returned. See alsoinfo,inandload.
: (load (pack (car (file)) "localFile.l"))  # Load a file in same directory
 
- (fill 'any ['sym|lst]) -> any
- Non-destructively fills a pattern any, by substitutingsym, or all symbols inlst, or - if no second argument
is given - each pattern symbol inany(seepat?), with its current value.@itself is not considered a pattern symbol here. Unmodified subexpressions are
shared. In any case, expressions following the symbol^should
evaluate to lists which are then (destructively) spliced into the result. See
alsomatch.
: (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)
 
- (filter 'fun 'lst ..) -> lst
- Applies funto each element oflst. When
additionallstarguments are given, their elements are also passed
tofun. Returns a list of all elements oflstwherefunreturned non-NIL. See alsofish,find,pickandextract.
: (filter num? (1 A 2 (B) 3 CDE))
-> (1 2 3)
: (filter < (2 9 3 8 4 7) (5 4 3 9 9 5))
-> (2 8 4)
: (filter and (1 NIL 3 NIL 5) (2 3 4 5 6) (7 8 NIL 1 1))
-> (1 5)
: (filter and (range 1 22) '(NIL NIL T .))
-> (3 6 9 12 15 18 21)
 
- (fin 'any) -> num|sym
- Returns anyif it is an atom, otherwise the CDR of its last
cell. See alsolastandtail.
: (fin 'a)
-> a
: (fin '(a . b))
-> b
: (fin '(a b . c))
-> c
: (fin '(a b c))
-> NIL
 
- (finally exe . prg) -> any
- prgis executed, then- exeis evaluated, and the
result of- prgis returned.- exewill also be evaluated
if- prgdoes not terminate normally due to a runtime error or a call
to- throw. See also- bye,- catch,- quitand- Error
Handling.- 
: (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
 
- (find 'fun 'lst ..) -> any
- Applies funto successive elements oflstuntil
non-NILis returned. Returns that element (and stores the
non-NILvalue in the global variable@@), orNILiffundid
not return non-NILfor any element oflst. When
additionallstarguments are given, their elements are also passed
tofun. See alsoseek,pick,fullyandfilter.
: (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
 
- (fish 'fun 'any) -> lst
- Applies funto each element - and recursively to all sublists -
ofany. Returns a list of all items wherefunreturned
non-NIL. See alsofilter.
: (fish atom '((a b) c (d e)))
-> (a b c d e)
: (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)
 
- (flg? 'any) -> flg
- Returns Twhen the argumentanyis eitherNILorT. See alsobool.(flg? X)is equivalent to(or (not X) (=T X)).
: (flg? (= 3 3))
-> T
: (flg? (= 3 4))
-> T
: (flg? (+ 3 4))
-> NIL
 
- (flip 'lst ['cnt]) -> lst
- Returns lst(destructively) reversed. Without the optionalcntargument, the whole list is flipped, otherwise only the firstcntelements. See alsoreverseandrot.
: (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)
 
- (flood 'lst1 'fun 'lst2) -> lst
- Implements a flooding algorithm, returning a list of flooded nodes of a
graph. lst1is a list of relevant nodes,funa
function accepting a node and returning a list of connected nodes, andlst2a list of seed nodes.
: (setq *Graph (1 2 3 4 5))         # For simplicity, a one-dimensional "graph"
-> (1 2 3 4 5)
: (flood
   (maplist prog *Graph)            # List of relevant cells
   '((X)                            # Flood the three central cells (2 3 4)
      (when (member (car X) (2 3))  # 2 -> 3 and 3 -> 4
         (list (cdr X)) ) )
   (list (cddr *Graph)) )           # Seed third (middle) cell
-> ((3 4 5) (2 3 4 5) (4 5))        # -> Cells (3 ..) (2 ..) (4 ..)
 
- (flush) -> flg
- Flushes the current output stream by writing all buffered data. A call to
flushfor standard output is done automatically before a call tokey. ReturnsTwhen
successful. See alsorewind.
: (flush)
-> T
 
- (fmt64 'num) -> sym
- (fmt64 'sym) -> num
- Converts a number numto a string in base-64 notation, or a
base-64 formatted string to a number. The digits are represented with the
characters0-9,:,;,A-Zanda-z. This format
is used internally for the names ofexternal symbolsin the 32-bit version.
See alsohax,hex,binandoct.
: (fmt64 9)
-> "9"
: (fmt64 10)
-> ":"
: (fmt64 11)
-> ";"
: (fmt64 12)
-> "A"
: (fmt64 "100")
-> 4096
 
- (fold 'any ['cnt]) -> sym
- Folding to a canonical form: If anyis not a symbol, it is
returned as it is. Otherwise, a new transient symbol with all digits and all
letters ofany, converted to lower case, is returned. If thecntargument is given and non-zero, the result is truncated to that
length. See alsolowc.
: (fold " 1A 2-b/3")
-> "1a2b3"
: (fold " 1A 2-B/3" 3)
-> "1a2"
 
- fold/3
- Pilog predicate that succeeds if the first
argument, after folding it to a
canonical form, is a prefix of the folded string representation of the
result of applying thegetalgorithm to
the following arguments. Typically used as filter predicate inselect/3database queries. See alsopre?,isa/2,same/3,bool/3,range/3,head/3,part/3andtolr/3.
: (?
   @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
 
- (for sym 'num ['any | (NIL 'any . prg) | (T 'any . prg) ..]) -> any
- (for sym|(sym2 . sym) 'lst ['any | (NIL 'any . prg) | (T 'any . prg) ..]) -> any
- (for (sym|(sym2 . sym) 'any1 'any2 [. prg]) ['any | (NIL 'any . prg) | (T 'any . prg) ..]) -> any
- Conditional loop with local variable(s) and multiple conditional exits:
 In the first form, the value ofsymis saved,symis
bound to1, and the body is executed with increasing values up to
(and including)num.
 In the second form, the value ofsymis saved,symis
subsequently bound to the elements oflst, and the body is executed
each time.
 In the third form, the value ofsymis saved, andsymis bound toany1. Ifsym2is given, it is treated as a
counter variable, first bound to 1 and then incremented for each execution of
the body. While the conditionany2evaluates to
non-NIL, the body is repeatedly executed and, ifprgis given,symis re-bound to the result of its evaluation.
 If a clause hasNILorTas its CAR, the clause's
second element is evaluated as a condition and - if the result isNILor non-NIL, respectively - theprgis
executed and the result returned. If the body is never executed,NILis returned.
 See alsodoandloop.
# First form:
: (for N 5 (printsp N))
1 2 3 4 5 -> 5
: (for N 5 (printsp N) (NIL (< N 3) (printsp 'enough)))
1 2 3 enough -> enough
: (for N 5 (T (> N 3) (printsp 'enough)) (printsp N))
1 2 3 enough -> enough
# Second form:
: (for X (1 a 2 b) (printsp X))
1 a 2 b -> b
: (for (I . X) '(a b c) (println I X))
1 a
2 b
3 c
-> c
# Third form:
: (for (L (1 2 3 4 5) L) (printsp (pop 'L)))
1 2 3 4 5 -> 5
: (for (N 1 (>= 5 N) (inc N)) (printsp N))
1 2 3 4 5 -> 5
: (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/2
- for/3
- for/4
- Pilog predicate that generates a sequence of
numbers. See also forandrange.
: (? (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
: (? (for @N T))
 @N=1
 @N=2
 @N=3
 ...
 
- (fork) -> pid | NIL
- Forks a child process. Returns NILin the child, and the
child's process IDpidin the parent. In the child, theVALof the global variable*Fork(should be aprg) is
executed. See alsoexec,detach,kids,pipeandtell.
: (unless (fork) (do 5 (println 'OK) (wait 1000)) (bye))
-> NIL
OK                                              # Child's output
: OK
OK
OK
OK
 
- (forked)
- Installs maintenance code in *Forkto close server sockets and clean up*Runcode in child processes. Should
only be called immediately aftertask.
: (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))
 
- (format 'num ['cnt ['sym1 ['sym2]]]) -> sym
- (format 'sym|lst ['cnt ['sym1 ['sym2]]]) -> num
- Converts a number numto a string, or a stringsym|lstto a number. In both cases, optionally a precisioncnt, a decimal-separatorsym1and a
thousands-separatorsym2can be supplied. ReturnsNILif the conversion is unsuccessful. See also Numbers,pad,hex,oct,binandround.
: (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
 
- (free 'cnt) -> (sym . lst)
- Returns, for the cnt'th database file, the next available
symbolsym(i.e. the first symbol greater than any symbol in the
database), and the listlstof free symbols. See alsoseq,zapanddbck.
: (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})
 
- (from 'any ..) -> sym
- Skips the current input channel until one of the strings anyis
found, and starts subsequent reading from that point. The foundanyargument (orNILif none is found) is returned. See alsotillandecho.
: (and (from "val='") (till "'" T))
test val='abc'
-> "abc"
 
- (full 'any) -> bool
- Returns NILifanyis a non-empty list with at
least oneNILelement, otherwiseT.(full
X)is equivalent to(not (memq NIL X)). See alsofully.
: (full (1 2 3))
-> T
: (full (1 NIL 3))
-> NIL
: (full 123)
-> T
 
- (fully 'fun 'lst ..) -> flg
- Applies funto successive elements oflst, and
returnsNILimmediately if one of the results isNIL.
Otherwise,Tis returned. When additionallstarguments are given, their elements are also passed tofun.(fully foo Lst)is equivalent to(not (find '((X) (not (foo
X))) Lst)). See alsofindandfull.
: (fully gt0 (1 2 3))
-> T
: (fully gt0 (1 -2 3))
-> NIL
 
- (fun? 'any) -> any
- Returns NILwhen the argumentanyis 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,Tfor a function without arguments, and a single formal parameter or a list of
formal parameters for a function. See alsogetd.
: (fun? 1000000000)              # Might be a code pointer
-> 1000000000
: (fun? 10000000000000000000)    # Too big for a code pointer
-> 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