++ ++ JScheme Lib taken from ++ http://jscheme.sourceforge.net/jscheme/doc/R4RSprimitives.html ++ $Id: primitives.html,v 1.1 2004/06/15 16:57:57 bigbinc Exp $ ++ ------------------------------------------------------------------------------------------ (exact->inexact n ) -- converts an exact number n to an inexact number (inexact->exact x ) -- converts an inexact number x to an exact number (* x y ... z) multiplies a sequence of numbers (+ x y ... z ) adds a sequence of numbers (- x y ) subtracts two numbers (/ x y ) divides two numbers (< x y ) compares two numbers, returns #t if x is less than y (<=x y ) compares two numbers, returns #t if x is less than or equal to y (= x y) compares two numbers, returns #t if x is equal to y (> x y ) compares two numbers, returns #t if x is greater than y (>= x y ) compares two numbers, returns #t if x is greater than or equal to y (abs x ) the absolute value of x (acos x ) the arc cosine of x (append x y) appends two lists x y to get a new list (apply f arguments ) applies the function f to the list of arguments (asin x) the arc sine of x (assoc x alist) alist is a list of pairs (key value), if x is one of those keys, the value is returned. equal? is used to compare x and key. (assq x alist) Same as assoc, but eq? is used to compare x and key. (assv x alist) Same as assoc, but eqv? is used to compare x and key. (atan x) the arc tangent of x (boolean? b ) #t if b is a boolean value: #t or #f (caaaar ) (lambda (x) (car (car (car (car x))))) (caaadr ) (lambda (x) (car (car (car (cdr x))))) (caaar ) (lambda (x) (car (car (car x)))) (caadar ) (lambda (x) (car (car (cdr (car x))))) (caaddr ) (lambda (x) (car (car (cdr (cdr x))))) (caadr ) (lambda (x) (car (car (cdr x)))) (caar ) (lambda (x) (car (car x))) (cadaar ) (lambda (x) (car (cdr (car (car x))))) (cadadr ) (lambda (x) (car (cdr (car (cdr x))))) (cadar ) (lambda (x) (car (cdr (car x)))) (caddar ) (lambda (x) (car (cdr (cdr (car x))))) (cadddr ) (lambda (x) (car (cdr (cdr (cdr x))))) (caddr ) (lambda (x) (car (cdr (cdr x)))) (cadr ) (lambda (x) (car (cdr x))) (call-with-current-continuation ) ONLY PARTIALLY IMPLEMENTED (call-with-input-file ) (call-with-output-file ) (car L ) the first element in the list L (cdaaar ) (lambda (x) (cdr (car (car (car x))))) (cdaadr ) (lambda (x) (cdr (car (car (cdr x))))) (cdaar ) (lambda (x) (cdr (car (car x)))) (cdadar ) (lambda (x) (cdr (car (cdr (car x))))) (cdaddr ) (lambda (x) (cdr (car (cdr (cdr x))))) (cdadr ) (lambda (x) (cdr (car (cdr x)))) (cdar ) (lambda (x) (cdr (car x))) (cddaar ) (lambda (x) (cdr (cdr (car (car x))))) (cddadr ) (lambda (x) (cdr (cdr (car (cdr x))))) (cddar ) (lambda (x) (cdr (cdr (car x)))) (cdddar ) (lambda (x) (cdr (cdr (cdr (car x))))) (cddddr ) (lambda (x) (cdr (cdr (cdr (cdr x))))) (cdddr ) (lambda (x) (cdr (cdr (cdr x)))) (cddr ) (lambda (x) (cdr (cdr x))) (cdr L ) the list obtained by removing the first element from the list L (ceiling x ) return the smallest integer greater than or equal to x (char->integer ) (char-alphabetic? ) ((char-ci<=? C1 C2) ) case-insensitive comparison of characters C1,C2 (char-ci ) (char-ci=? ) (char-ci>=? ) (char-ci>? ) (char-downcase ) (char-lower-case? ) (char-numeric? ) (char-upcase ) (char-upper-case? ) (char-whitespace? ) ((char<=? C1 C2) ) case-sensitive comparison of characters (char ) (char=? ) (char>=? ) (char>? ) (char? ) (close-input-port ) (close-output-port ) (complex? ) NOT IMPLEMENTED (cons x L ) the list obtained by adding x to the beginning of the list L (cos x) the cosine of x in radians ((current-input-port) ) ((current-output-port) ) (display T ) print the term T on the Java console ((eof-object? X) ) returns true if X is the end of file object returned by read ((eq? A B) ) returns #t when A and B are both #null or when they are both the same object (equal? x y) returns #t if x and y are both #null or represent the same numbers, or are ".equals" as Java objects, or are lists whose corresponding elements are "equal?", or are arrays whose corresponding elements are "equal?". or are ((eqv? A B) ) returns #t if x and y are both #null or represent the same numbers, or are ".equals" as Java objects. ((eval T) ) this evaluates the expression T in the current toplevel environment. The expression T is an expression formed from symbols and objects cons'd together. (even? x) #t if x is an even number ((exact? x) ) #t if x is a byte, short, or int (exp x ) the exponential function applied to x (expt n e ) raise n to the power e (floor x) return the largest integer less than x (for-each P L ) apply the procedure P to every element of the list L (force ) (gcd x y ) find the greatest common divisor of x and y ((inexact? x) ) #t if x is a float or double ((input-port? x) ) ((integer->char i) ) converts i to 16 bit unicode character ((interaction-environment) ) (integer? x ) #t if x is an integer (lcm x y) return the least common multiple of x and y (length L) return the length of the list L (list x y ... z) make a list from the elements x, y, ... z ((list->string Cs) ) converts the list Cs of characters to a string ((list->vector Os) ) converts the list Os of objects to a vector ((list-ref L N ) returns the (N+1)st element of L. So (list-ref L 0) returns the first element of L. (list-tailL N ) returns the list obtained by removing the first N elements from L (list? L) returns #t if L is a list (load F) reads and interprets the Scheme expressions in the file F in the current toplevel environment (log x) the natural log function applied to x (macroexpand X) (make-string ) (make-vector ) (map F L) return the list obtained by applying the function F to every element of the list L (max a b c ... d) find the largest of the numbers a, b, ..., d (member x L) return #t if x is a member of the list L (memq ) (memv ) (min a b c ... d) find the smallest of the numbers a, b, ..., d (modulo n d) return the remainder of n divided by d (negative? x) return #t if x is a negative number (newline) write a newline on the Java console (not b) negates the truth value b (null-environment ) (null? L ) return #t if L is the empty list (number->string ) (number? x ) return #t if x is a number (odd? x) return #t if x is an odd number (open-input-file ) (open-output-file ) (output-port? ) (pair? L) return #t if L is a pair. (peek-char ) (positive? x) return #t if x is a positive number (procedure? p) return #t if p is a procedure (quotient x y ) return the integer quotient of x divided by y (rational? ) UNIMPLEMENTED (read ) (read-char ) (real? ) UNIMPLEMENTED (remainder x y) return the remainder of x divided by y (reverse L) reverse the list L (round x) return the nearest integer to the number x (scheme-report-environment ) (set-car! ) (set-cdr! ) (sin x) the sine of x (sqrt x) the square root of x (string ) (string->list ) (string->number ) (string->symbol ) (string-append a b c ... d) combine the strings a, b, ..., d into a single new string (string-ci<=? ) (string-ci ) (string-ci=? ) (string-ci>=? ) (string-ci>? ) (string-copy ) (string-fill! ) (string-length x) return the number of characters in the string x (string-ref ) (string-set! ) (string<=? ) (string ) (string=? ) (string>=? ) (string>? ) (string? ) (substring s i j ) return the substring of s that starts at position i and ends right before position j, where 0 is the first position in the string. (symbol->string ) (symbol? s) return #t if s is a symbol (tan x) tangent of x (truncate x) remove the fractional part of the decimal x to get an integer (vector ) (vector->list ) (vector-fill! ) (vector-length ) (vector-ref ) (vector-set! ) (vector? ) (write ) (write-char ) (zero? z) return #t if z equals 0 ------------------------------------------------------------------------------------------