- (! . exe) -> any
- Low level breakpoint function: The current execution environment is saved
and the I/O channels are redirected to the console. Then exeis
displayed, and a read-eval-print-loop is entered (with!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 ofexeis
returned.!is normally inserted into existing programs with thedebugfunction. See alsoe,^and*Dbg.
: (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
 
- ($ sym|lst lst . prg) -> any
- Low level trace function: The first argument sym|lstis printed
to the console with a proper indentation, followed by a colon:. 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 argumentlstshould be a list of symbols, identical to the function's
argument list. The current values of these symbols are printed, followed by a
newline. Thenprgis executed, and its return value printed in a
similar way (this time with an equals sign=instead of a colon)
and returned.$is normally inserted into existing programs with
thetracefunction.
: (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
 
- ($dat 'sym1 ['sym2]) -> dat
- Converts a string sym1in ISO format to adate, optionally using a delimiter charactersym2. See alsodat$,$tim,strDatandexpDat.
: ($dat "20070601")
-> 733134
: ($dat "2007-06-01" "-")
-> 733134
 
- ($tim 'sym) -> tim
- Converts a string to a time. The
minutes and seconds are optional and default to zero. See alsotim$and$dat.
: (time ($tim "10:57:56"))
-> (10 57 56)
: (time ($tim "10:57"))
-> (10 57 0)
: (time ($tim "10"))
-> (10 0 0)
 
- (% 'num ..) -> num
- Returns the remainder from the divisions of successive numarguments. The sign of the result is that of the first argument. When one of the
arguments evaluates toNIL, it is returned immediately. See also/and*/.
: (% 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
 
- (%@ 'cnt|sym 'any 'any ..) -> any
- Convenience function for a common use case of native.(%@ "fun" ...)is
equivalent to(native "@" "fun" ...).
: (%@ "getenv" 'S "TERM")  # Same as (sys "TERM")
-> "xterm"
: (%@ "symlink" 'I "file" "link")
-> 0
: (%@ "isatty" 'I 0)
-> 1
: (round (%@ "cos" 1.0  3.1415926535897932))
-> "1.000"
: (use Tim
   (%@ "time" NIL '(Tim (8 B . 8)))  # time_t 8   # Get time_t structure
   (%@ "localtime" '(I . 9) (cons NIL (8) Tim)) ) # Read local time
-> (43 19 14 6 10 120 5 310 0)  # 14:19:43, Nov 6th, 2020
 
- (& 'num ..) -> num
- Returns the bitwise ANDof allnumarguments. When
one of the arguments evaluates toNIL, it is returned immediately.
See also|,x|andbit?.
: (& 6 3)
-> 2
: (& 7 3 1)
-> 1
 
- (* 'num ..) -> num
- Returns the product of all numarguments. When one of the
arguments evaluates toNIL, it is returned immediately. See also/,*/,+and-.
: (* 1 2 3)
-> 6
: (* 5 3 2 2)
-> 60
 
- (** 'num1 'num2) -> num
- Integer exponentiation: Returns num1to the power ofnum2.
: (** 2 3)
-> 8
: (** 100 100)
-> 10000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000
 
- (*/ 'num1 ['num2 ..] 'num3) -> num
- Returns the product of num1and all followingnum2arguments, divided by thenum3argument. The result is rounded to
the nearest integer value. When one of the arguments evaluates toNIL, it is returned immediately. Note that*/is
especially useful for fixed point arithmetic, by multiplying with (or dividing
by) the scale factor. See also*,/,+,-andsqrt.
: (*/ 3 4 2)
-> 6
: (*/ 1234 2 10)
-> 247
: (*/ 100 6)
-> 17
: (scl 2)
-> 2
: (format (*/ 3.0 1.5 1.0) *Scl)
-> "4.50"
: (scl 20)
-> 20
: (format (*/ 9.9 9.789 9.56789 `(* 1.0 1.0)) *Scl)
-> "927.23474457900000000000"
 
- (+ 'num ..) -> num
- Returns the sum of all numarguments. When one of the arguments
evaluates toNIL, it is returned immediately. See alsoinc,-,*,/and*/.
: (+ 1 2 3)
-> 6
 
- (++ var) -> any
- Pops the first element (CAR) from the stack in var.(++
Lst)is equivalent to(pop 'Lst). See alsopop.
 
- (- 'num ..) -> num
- Returns the difference of the first numargument and all
following arguments. If only a single argument is given, it is negated. When one
of the arguments evaluates toNIL, it is returned immediately. See
alsodec,+,*,/and*/.
: (- 7)
-> -7
: (- 7 2 1)
-> 4
 
- (-> any [cnt]) -> any
- Searches for the value of any(typically a Pilog variable, or an expression of variables) at top
level (or levelcnt) in the current environment. See alsoproveandunify.
: (? (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
 
- (/ 'num ..) -> num
- Returns the first numargument successively divided by all
following arguments. When one of the arguments evaluates toNIL, it
is returned immediately. See also*,*/,%,+and-.
: (/ 12 3)
-> 4
: (/ 60 -3 2 2)
-> -5
 
- (: sym|0 [sym1|cnt ..]) -> any
- Fetches a value anyfrom the properties of a symbol, or from a
list, by applying thegetalgorithm toThisand the following arguments. Used typically in methods orwithbodies.(: ..)is
equivalent to(; This ..). See also;,=:and::.
: (put 'X 'a 1)
-> 1
: (with 'X (: a))
-> 1
 
- (:: sym [sym1|cnt .. sym2]) -> var
- Fetches a property for a property key symorsym2from a symbol. That symbol isThis(if no other arguments are
given), or a symbol found by applying thegetalgorithm toThisand the
following arguments. The property (the cons pair, not just its value) is
returned, suitable for direct (destructive) manipulations with functions
expecting avarargument. Used typically in methods orwithbodies. See also=:,propand:.
: (with 'X (=: cnt 0) (inc (:: cnt)) (: cnt))
-> 1
 
- (; 'sym1|lst [sym2|cnt ..]) -> any
- Fetches a value anyfrom the properties of a symbol, or from a
list, by applying thegetalgorithm tosym1|lstand the following arguments. See also:,=:and::.
: (put 'A 'a 1)
-> 1
: (put 'A 'b 'B)
-> B
: (put 'B 'c 7)
-> 7
: (; 'A a)
-> 1
: (; 'A b c)
-> 7
 
- (< 'any ..) -> flg
- Returns Twhen all argumentsanyare in strictly
increasing order. See also Comparing.
: (< 3 4)
-> T
: (< 'a 'b 'c)
-> T
: (< 999 'a)
-> T
 
- (<= 'any ..) -> flg
- Returns Twhen all argumentsanyare in strictly
non-decreasing order. See also Comparing.
: (<= 3 3)
-> T
: (<= 1 2 3)
-> T
: (<= "abc" "abc" "def")
-> T
 
- (<> 'any ..) -> flg
- Returns Twhen not allanyarguments are equal
(structure equality).(<> 'any ..)is equivalent to(not (=
'any ..)). See also Comparing.
: (<> 'a 'b)
-> T
: (<> 'a 'b 'b)
-> T
: (<> 'a 'a 'a)
-> NIL
 
- (= 'any ..) -> flg
- Returns Twhen allanyarguments are equal
(structure equality). See also Comparing.
: (= 6 (* 1 2 3))
-> T
: (= "a" "a")
-> T
: (== "a" "a")
-> T
: (= (1 (2) 3) (1 (2) 3))
-> T
 
- (=0 'any) -> 0 | NIL
- Returns 0whenanyis a number with value zero.
See alson0,lt0,le0,ge0,gt0and=1.
: (=0 (- 6 3 2 1))
-> 0
: (=0 'a)
-> NIL
 
- (=1 'any) -> 1 | NIL
- Returns 1whenanyis a number with value one.
See also=0.
: (=1 (- 6 3 2))
-> 1
: (=1 'a)
-> NIL
 
- (=: sym|0 [sym1|cnt ..] 'any) -> any
- Stores a new value anyfor a property key (or in the symbol
value for zero) in a symbol, or in a list. That symbol isThis(if
no other arguments are given), or a symbol found by applying thegetalgorithm toThisand the
following arguments. If the final destination is a list, the value is stored in
the CDR of anasoqed element (if the
key argument is a symbol), or the n'th element (if the key is a number). Used
typically in methods orwithbodies.
See alsoput,:and::.
: (with 'X (=: a 1) (=: b 2))
-> 2
: (get 'X 'a)
-> 1
: (get 'X 'b)
-> 2
 
- (== 'any ..) -> flg
- Returns Twhen allanyarguments are the same
(pointer equality). See alson==and Comparing.
: (== 'a 'a)
-> T
: (== 'NIL NIL (val NIL) (car NIL) (cdr NIL))
-> T
: (== (1 2 3) (1 2 3))
-> NIL
 
- (=T 'any) -> flg
- Returns Twhenanyis the symbolT.(=T X)is equivalent to(== T X). See also nT.
: (=T 0)
-> NIL
: (=T "T")
-> NIL
: (=T T)
-> T
 
- (> 'any ..) -> flg
- Returns Twhen all argumentsanyare in strictly
decreasing order. See also Comparing.
: (> 4 3)
-> T
: (> 'A 999)
-> T
 
- (>= 'any ..) -> flg
- Returns Twhen all argumentsanyare in strictly
non-increasing order. See also Comparing.
: (>= 'A 999)
-> T
: (>= 3 2 2 1)
-> T
 
- (>> 'cnt 'num) -> num
- Shifts right the numargument bycntbit-positions. Ifcntis negative, a corresponding left shift is
performed.
: (>> 1 8)
-> 4
: (>> 3 16)
-> 2
: (>> -3 16)
-> 128
: (>> -1 -16)
-> -32
 
- (? [sym ..] [pat 'any ..] . lst) -> flg
- Top-level function for interactive Pilog
queries. ?is a non-evaluating front-end to thequeryfunction. 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 byprove. The list of
variable/value pairs is passed togoalfor an initial Pilog environment. See alsopilogandsolve.
: (? (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
 
- @
- 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 @
Result). When@is used as a formal parameter in lambda expressions, it denotes a variable number of
evaluated arguments.
- @@
- Holds the result of the second last top level expression in the current
read-eval-print loop (see @ Result).
Some functions store a secondary return value in@@.
- @@@
- Holds the result of the third last top level expression in the current
read-eval-print loop (see @ Result).
- ^
- Holds the currently executed expression during a breakpoint or an error. See
also debug,!,eand*Dbg.
: (* (+ 3 4) (/ 7 0))
!? (/ 7 0)
Div/0
? ^
-> (/ 7 0)
 
- (| 'num ..) -> num
- Returns the bitwise ORof allnumarguments. When
one of the arguments evaluates toNIL, it is returned immediately.
See alsox|,&andbit?.
: (| 1 2)
-> 3
: (| 1 2 4 8)
-> 15