(! . prg) -> any
- Low level breakpoint function: The current execution environment is saved
and the I/O channels are redirected to the console. Then
prg
is
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 of prg
is
returned. !
is normally inserted into existing programs with the
debug
function. See also e
, ^
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|lst
is 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 argument
lst
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 prg
is 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
the trace
function.
: (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
sym1
in ISO format to a date
, optionally using a delimiter character
sym2
. See also dat$
,
$tim
, strDat
and expDat
.
: ($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 also tim$
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
num
arguments. The sign of the result is that of the first argument.
: (% 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
(& 'num ..) -> num
- Returns the bitwise
AND
of all num
arguments. See
also |
, x|
and bit?
.
: (& 6 3)
-> 2
: (& 7 3 1)
-> 1
(* 'num ..) -> num
- Returns the product of all
num
arguments.
: (* 1 2 3)
-> 6
: (* 5 3 2 2)
-> 60
(** 'num1 'num2) -> num
- Returns
num1
to the power of num2
.
: (** 2 3)
-> 8
: (** 100 100)
-> 10000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000
(*/ 'num1 ['num2 ..] 'num3) -> num
- Returns the product of
num1
and all following num2
arguments, divided by the num3
argument. The result is rounded to
the nearest integer value.
: (*/ 3 4 2)
-> 6
: (*/ 1234 2 10)
-> 247
: (*/ 100 6)
-> 17
(+ 'num ..) -> num
- Returns the sum of all
num
arguments.
: (+ 1 2 3)
-> 6
(- 'num ..) -> num
- Returns the difference of the first
num
argument and all
following arguments. If only a single argument is given, it is negated.
: (- 7)
-> -7
: (- 7 2 1)
-> 4
(-> sym [num]) -> any
- Searches for the current value of the pattern variable
sym
at
top level (or level num
) in the current Pilog environment. See also prove
and unify
.
: (? (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
num
argument successively divided by all
following arguments.
: (/ 12 3)
-> 4
: (/ 60 -3 2 2)
-> -5
(: sym|0 [sym1|cnt ..]) -> any
- Fetches a value
any
from the properties of a symbol, or from a
list, by applying the get
algorithm to
This
and the following arguments. Used typically in methods or
with
bodies. See also get
, =:
and ::
.
: (put 'X 'a 1)
-> 1
: (with 'X (: a))
-> 1
(:: sym [sym1|cnt .. sym2]) -> lst|sym
- Fetches a property for a property key
sym
or sym2
from a symbol. That symbol is This
(if no other arguments are
given), or a symbol found by applying the get
algorithm to This
and the
following arguments. The property (the cell, not just its value) is returned,
suitable for direct (destructive) manipulations. Used typically in methods or
with
bodies. See also =:
and :
.
: (with 'X (=: cnt 0) (inc (:: cnt)) (: cnt))
-> 1
(< 'any ..) -> flg
- Returns
T
when all arguments any
are in strictly
increasing order. See also Comparing.
: (< 3 4)
-> T
: (< 'a 'b 'c)
-> T
: (< 999 'a)
-> T
(<= 'any ..) -> flg
- Returns
T
when all arguments any
are in strictly
non-decreasing order. See also Comparing.
: (<= 3 3)
-> T
: (<= 1 2 3)
-> T
: (<= "abc" "abc" "def")
-> T
(<> 'any ..) -> flg
- Returns
T
when not all any
arguments 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
T
when all any
arguments 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) -> num | NIL
- Returns
0
when any
is a number with value zero.
See also n0
, lt0
, ge0
and gt0
.
: (=0 (- 6 3 2 1))
-> 0
: (=0 'a)
-> NIL
(=: sym [sym1|cnt .. sym2] 'any)
- Stores a new value
any
for a property key sym
or
sym2
in a symbol. That symbol is This
(if no other
arguments are given), or a symbol found by applying the get
algorithm to This
and the
following arguments. Used typically in methods or with
bodies. See also put
, :
and ::
.
: (with 'X (=: a 1) (=: b 2))
-> 2
: (get 'X 'a)
-> 1
: (get 'X 'b)
-> 2
(== 'any ..) -> flg
- Returns
T
when all any
arguments are the same
(pointer equality). See also n==
.
: (== 'a 'a)
-> T
: (== 'NIL NIL (val NIL) (car NIL) (cdr NIL))
-> T
: (== (1 2 3) (1 2 3))
-> NIL
(==== ['sym ..]) -> NIL
- Close the current transient scope by clearing the transient hash table. All
transient symbols become hidden and inaccessible by the reader. Then any
optional
sym
arguments are (re-)inserted into the transient hash
table. See also extern
and intern
.
: (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
(=T 'any) -> flg
- Returns
T
when any
is the symbol T
.
(=T X)
is equivalent to (== T X)
. See also nT.
: (=T 0)
-> NIL
: (=T "T")
-> NIL
: (=T T)
-> T
(> 'any ..) -> flg
- Returns
T
when all arguments any
are in strictly
decreasing order. See also Comparing.
: (> 4 3)
-> T
: (> 'A 999)
-> T
(>= 'any ..) -> flg
- Returns
T
when all arguments any
are in strictly
non-increasing order. See also Comparing.
: (>= 'A 999)
-> T
: (>= 3 2 2 1)
-> T
(>> 'cnt 'num) -> num
- Shifts right the
num
argument by cnt
bit-positions. If cnt
is negative, a corresponding left shift is
performed.
: (>> 1 8)
-> 4
: (>> 3 16)
-> 2
: (>> -3 16)
-> 128
: (>> -1 -16)
-> -32
(? [sym 'any ..] . lst) -> flg
- Top-level function for interactive Pilog
queries. It displays each result, waits for console input, and terminates when a
non-empty line is entered.
: (? (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
@
- 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
).
@@@
- 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
, !
, e
and
*Dbg
.
: (* (+ 3 4) (/ 7 0))
!? (/ 7 0)
Div/0
? ^
-> (/ 7 0)
(| 'num ..) -> num
- Returns the bitwise
OR
of all num
arguments. See
also x|
, &
and bit?
.
: (| 1 2)
-> 3
: (| 1 2 4 8)
-> 15