RHS Functions

Procedural Functions

String Functions

    (str-cat "use" "ful" "ness")
    (sym-cat use ful ness)
    (str-index "def" "abcdefghi")
    (sub-string 4 6 "abcdefghijkl")
    (upcase "This is a test of upcase")
    (lowcase A_Word_Test_for_Lowcase)

Multifield Functions

create$
    (create$)                           ;()
    (create$ a b c d e f)               ;(a b c d e f)

first$
    (first$ (create$ a b c d) )         ;(a)

rest$
    (rest$ (create$ a b c d) )          ;(b c d)

length$
    (length$ (create$ a b c d) )        ;4

nth$
    (nth$ 3 (create$ a b c d e f g))    ;c

member$
    (member$ blue (create$ red 3 "text" 8.7 blue))         ;5
    (member$ 4 (create$ red 3 "text" 8.7 blue))            ;FALSE

subsetp
    (subsetp (create$ hammer saw drill)
                    (create$ hammer drill wrench pliers saw))   ;TRUE

subseq$
    (subseq$ (create$ hammer drill wrench pliers) 3 4)      ;(wrench pliers)

explode$
    (explode$ "a b c d")       ;(a b c d)

implode$
    (implode$ (create$ a b c d e))                 ;"a b c d e"

expand$
    (printout t (expand$ (create$ a b c)))         ;abc
    (printout t (create$ a b c))                   ;(a b c)

insert$
    (insert$ (create$ a e f) 2 (create$ b c d))    ;(a b c d e f)

delete$
    (delete$ (create$ a b c d e f) 3 4)            ;(a b e f)

replace$
    (replace$ (create$ a b c d) 2 3 x y (create$ q r s))    ;(a x y q r s d)

Extended Math Functions

    Trigonometric
    Hyperbolic
    Conversion
        (deg-rad 180)
        (rad-deg 3.141592653589793)
    (exp 1)
    (log 2.718281828459045)

Predicate Functions

Numerical

    =, <>, >, <, >=, <=
    numberp
    floatp
    integerp
    oddp
    evenp

Non-numerical

    and, or, not
    eq, neq
    stringp
    symbolp
    lexemep
    multifieldp

Miscellaneous Functions

    (gensym*)   ;return a unique word gen<number> each time it's called.
    (setgen 5)  ;to set starting number used by gensym

I/O Functions

read

(defrule player-select
   (phase choose-player)
   =>
   (printout t "Who moves first (Computer: c "
               "Human: h)? ")
   (assert (player-select (read))))

open

(open "input.dat" data "r")     ;"r" for read only
                                ;"r+" for read/write
                                ;"a" for append only
                                ;"w" for write only

close

    (open "example.dat" xmp "w")
    (printout xmp "green" crlf)
    (printout xmp 7 crlf)
    (close xmp)

    (open "example.dat" xmp "r")
    (read xmp)
    (read xmp)
    (close xmp)

format

    (format t "Name: %-15s Age: %3d"
             "Bob Green" 35)

    (bind ?name (format nil "Name: %-15s Age: %3d"
                 "Bob Green" 35))
    (printout t ?name)
    

readline

    (readline xmp)

remove

rename

Previous Advanced Pattern Matching   Up TOC   Next Procedural Programming