1 Beginning Student
2 Beginning Student with List Abbreviations
3 Intermediate Student
4 Intermediate Student with Lambda
5 Advanced Student
Index
On this page:
*
+
-
/
<
<=
=
>
>=
abs
acos
add1
angle
asin
atan
ceiling
complex?
conjugate
cos
cosh
current-seconds
denominator
e
even?
exact->inexact
exact?
exp
expt
floor
gcd
imag-part
inexact->exact
inexact?
integer->char
integer?
lcm
log
magnitude
make-polar
max
min
modulo
negative?
number->string
number?
numerator
odd?
pi
positive?
quotient
random
rational?
real-part
real?
remainder
round
sgn
sin
sinh
sqr
sqrt
sub1
tan
zero?
boolean=?
boolean?
false?
not
symbol->string
symbol=?
symbol?
append
assq
caaar
caadr
caar
cadar
cadddr
caddr
cadr
car
cdaar
cdadr
cdar
cddar
cdddr
cddr
cdr
cons
cons?
eighth
empty?
fifth
first
fourth
length
list
list*
list-ref
member
memq
memv
null
null?
pair?
rest
reverse
second
seventh
sixth
third
make-posn
posn-x
posn-y
posn?
char->integer
char-alphabetic?
char-ci<=?
char-ci<?
char-ci=?
char-ci>=?
char-ci>?
char-downcase
char-lower-case?
char-numeric?
char-upcase
char-upper-case?
char-whitespace?
char<=?
char<?
char=?
char>=?
char>?
char?
format
list->string
make-string
string
string->list
string->number
string->symbol
string-append
string-ci<=?
string-ci<?
string-ci=?
string-ci>=?
string-ci>?
string-copy
string-length
string-ref
string<=?
string<?
string=?
string>=?
string>?
string?
substring
image=?
image?
=~
eof
eof-object?
eq?
equal?
equal~?
eqv?
error
exit
identity
struct?
andmap
apply
build-list
build-string
compose
filter
foldl
foldr
for-each
map
memf
ormap
procedure?
quicksort
sort
Version: 4.0.2

 

3.8 Primitive Operations

prim-op

The name of a primitive operation can be used as an expression. If it is passed to a function, then it can be used in a function call within the function’s body.

* : (num num num ... -> num)

Purpose: to compute the product of all of the input numbers

+ : (num num num ... -> num)

Purpose: to compute the sum of the input numbers

- : (num num ... -> num)

Purpose: to subtract the second (and following) number(s) from the first; negate the number if there is only one argument

/ : (num num num ... -> num)

Purpose: to divide the first by the second (and all following) number(s); only the first number can be zero.

< : (real real real ... -> boolean)

Purpose: to compare real numbers for less-than

<= : (real real real ... -> boolean)

Purpose: to compare real numbers for less-than or equality

= : (num num num ... -> boolean)

Purpose: to compare numbers for equality

> : (real real real ... -> boolean)

Purpose: to compare real numbers for greater-than

>= : (real real ... -> boolean)

Purpose: to compare real numbers for greater-than or equality

abs : (real -> real)

Purpose: to compute the absolute value of a real number

acos : (num -> num)

Purpose: to compute the arccosine (inverse of cos) of a number

add1 : (number -> number)

Purpose: to compute a number one larger than a given number

angle : (num -> real)

Purpose: to extract the angle from a complex number

asin : (num -> num)

Purpose: to compute the arcsine (inverse of sin) of a number

atan : (num -> num)

Purpose: to compute the arctan (inverse of tan) of a number

ceiling : (real -> int)

Purpose: to determine the closest integer above a real number

complex? : (any -> boolean)

Purpose: to determine whether some value is complex

conjugate : (num -> num)

Purpose: to compute the conjugate of a complex number

cos : (num -> num)

Purpose: to compute the cosine of a number (radians)

cosh : (num -> num)

Purpose: to compute the hyperbolic cosine of a number

current-seconds : (-> int)

Purpose: to compute the current time in seconds elapsed (since a platform-specific starting date)

denominator : (rat -> int)

Purpose: to compute the denominator of a rational

e : real

Purpose: Euler’s number

even? : (integer -> boolean)

Purpose: to determine if some value is even or not

exact->inexact : (num -> num)

Purpose: to convert an exact number to an inexact one

exact? : (num -> boolean)

Purpose: to determine whether some number is exact

exp : (num -> num)

Purpose: to compute e raised to a number

expt : (num num -> num)

Purpose: to compute the power of the first to the second number

floor : (real -> int)

Purpose: to determine the closest integer below a real number

gcd : (int int ... -> int)

Purpose: to compute the greatest common divisior

imag-part : (num -> real)

Purpose: to extract the imaginary part from a complex number

inexact->exact : (num -> num)

Purpose: to approximate an inexact number by an exact one

inexact? : (num -> boolean)

Purpose: to determine whether some number is inexact

integer->char : (int -> char)

Purpose: to lookup the character that corresponds to the given integer in the ASCII table (if any)

integer? : (any -> boolean)

Purpose: to determine whether some value is an integer (exact or inexact)

lcm : (int int ... -> int)

Purpose: to compute the least common multiple of two integers

log : (num -> num)

Purpose: to compute the base-e logarithm of a number

magnitude : (num -> real)

Purpose: to determine the magnitude of a complex number

make-polar : (real real -> num)

Purpose: to create a complex from a magnitude and angle

max : (real real ... -> real)

Purpose: to determine the largest number

min : (real real ... -> real)

Purpose: to determine the smallest number

modulo : (int int -> int)

Purpose: to compute first number modulo second number

negative? : (number -> boolean)

Purpose: to determine if some value is strictly smaller than zero

number->string : (num -> string)

Purpose: to convert a number to a string

number? : (any -> boolean)

Purpose: to determine whether some value is a number

numerator : (rat -> int)

Purpose: to compute the numerator of a rational

odd? : (integer -> boolean)

Purpose: to determine if some value is odd or not

pi : real

Purpose: the ratio of a circle’s circumference to its diameter

positive? : (number -> boolean)

Purpose: to determine if some value is strictly larger than zero

quotient : (int int -> int)

Purpose: to compute the quotient of two integers

random : (int -> int)

Purpose: to generate a random natural number less than some given integer

rational? : (any -> boolean)

Purpose: to determine whether some value is a rational number

real-part : (num -> real)

Purpose: to extract the real part from a complex number

real? : (any -> boolean)

Purpose: to determine whether some value is a real number

remainder : (int int -> int)

Purpose: to compute the remainder of dividing the first by the second integer

round : (real -> int)

Purpose: to round a real number to an integer (rounds to even to break ties)

sgn : (real -> (union 1 1.0 0 0.0 -1 -1.0))

Purpose: to compute the sign of a real number

sin : (num -> num)

Purpose: to compute the sine of a number (radians)

sinh : (num -> num)

Purpose: to compute the hyperbolic sine of a number

sqr : (num -> num)

Purpose: to compute the square of a number

sqrt : (num -> num)

Purpose: to compute the square root of a number

sub1 : (number -> number)

Purpose: to compute a number one smaller than a given number

tan : (num -> num)

Purpose: to compute the tangent of a number (radians)

zero? : (number -> boolean)

Purpose: to determine if some value is zero or not

boolean=? : (boolean boolean -> boolean)

Purpose: to determine whether two booleans are equal

boolean? : (any -> boolean)

Purpose: to determine whether some value is a boolean

false? : (any -> boolean)

Purpose: to determine whether a value is false

not : (boolean -> boolean)

Purpose: to compute the negation of a boolean value

symbol->string : (symbol -> string)

Purpose: to convert a symbol to a string

symbol=? : (symbol symbol -> boolean)

Purpose: to determine whether two symbols are equal

symbol? : (any -> boolean)

Purpose: to determine whether some value is a symbol

append : 

((listof any)

 (listof any)

 (listof any)

 ...

 ->

 (listof any))

Purpose: to create a single list from several, by juxtaposition of the items

assq : 

(X

 (listof (cons X Y))

 ->

 (union false (cons X Y)))

Purpose: to determine whether some item is the first item of a pair in a list of pairs

caaar : 

((cons

  (cons (cons W (listof Z)) (listof Y))

  (listof X))

 ->

 W)

Purpose: to select the first item of the first list in the first list of a list

caadr : 

((cons

  (cons (cons W (listof Z)) (listof Y))

  (listof X))

 ->

 (listof Z))

Purpose: to select the rest of the first list in the first list of a list

caar : ((cons (cons Z (listof Y)) (listof X)) -> Z)

Purpose: to select the first item of the first list in a list

cadar : 

((cons (cons W (cons Z (listof Y))) (listof X))

 ->

 Z)

Purpose: to select the second item of the first list of a list

cadddr : ((listof Y) -> Y)

Purpose: to select the fourth item of a non-empty list

caddr : ((cons W (cons Z (cons Y (listof X)))) -> Y)

Purpose: to select the third item of a non-empty list

cadr : ((cons Z (cons Y (listof X))) -> Y)

Purpose: to select the second item of a non-empty list

car : ((cons Y (listof X)) -> Y)

Purpose: to select the first item of a non-empty list

cdaar : 

((cons

  (cons (cons W (listof Z)) (listof Y))

  (listof X))

 ->

 (listof Z))

Purpose: to select the rest of the first list in the first list of a list

cdadr : 

((cons W (cons (cons Z (listof Y)) (listof X)))

 ->

 (listof Y))

Purpose: to select the rest of the first list in the rest of a list

cdar : 

((cons (cons Z (listof Y)) (listof X))

 ->

 (listof Y))

Purpose: to select the rest of a non-empty list in a list

cddar : 

((cons (cons W (cons Z (listof Y))) (listof X))

 ->

 (listof Y))

Purpose: to select the rest of the rest of the first list of a list

cdddr : 

((cons W (cons Z (cons Y (listof X))))

 ->

 (listof X))

Purpose: to select the rest of the rest of the rest of a list

cddr : ((cons Z (cons Y (listof X))) -> (listof X))

Purpose: to select the rest of the rest of a list

cdr : ((cons Y (listof X)) -> (listof X))

Purpose: to select the rest of a non-empty list

cons : (X (listof X) -> (listof X))

Purpose: to construct a list

cons? : (any -> boolean)

Purpose: to determine whether some value is a constructed list

eighth : ((listof Y) -> Y)

Purpose: to select the eighth item of a non-empty list

empty? : (any -> boolean)

Purpose: to determine whether some value is the empty list

fifth : ((listof Y) -> Y)

Purpose: to select the fifth item of a non-empty list

first : ((cons Y (listof X)) -> Y)

Purpose: to select the first item of a non-empty list

fourth : ((listof Y) -> Y)

Purpose: to select the fourth item of a non-empty list

length : (list -> number)

Purpose: to compute the number of items on a list

list : (any ... -> (listof any))

Purpose: to construct a list of its arguments

list* : (any ... (listof any) -> (listof any))

Purpose: to construct a list by adding multiple items to a list

list-ref : ((listof X) natural-number -> X)

Purpose: to extract the indexed item from the list

member : (any list -> boolean)

Purpose: to determine whether some value is on the list (comparing values with equal?)

memq : (any list -> (union false list))

Purpose: to determine whether some value is on some list (comparing values with eq?)

memv : (any list -> (union false list))

Purpose: to determine whether some value is on the list (comparing values with eqv?)

null : empty

Purpose: the empty list

null? : (any -> boolean)

Purpose: to determine whether some value is the empty list

pair? : (any -> boolean)

Purpose: to determine whether some value is a constructed list

rest : ((cons Y (listof X)) -> (listof X))

Purpose: to select the rest of a non-empty list

reverse : (list -> list)

Purpose: to create a reversed version of a list

second : ((cons Z (cons Y (listof X))) -> Y)

Purpose: to select the second item of a non-empty list

seventh : ((listof Y) -> Y)

Purpose: to select the seventh item of a non-empty list

sixth : ((listof Y) -> Y)

Purpose: to select the sixth item of a non-empty list

third : ((cons W (cons Z (cons Y (listof X)))) -> Y)

Purpose: to select the third item of a non-empty list

make-posn : (number number -> posn)

Purpose: to construct a posn

posn-x : (posn -> number)

Purpose: to extract the x component of a posn

posn-y : (posn -> number)

Purpose: to extract the y component of a posn

posn? : (anything -> boolean)

Purpose: to determine if its input is a posn

char->integer : (char -> integer)

Purpose: to lookup the number that corresponds to the given character in the ASCII table (if any)

char-alphabetic? : (char -> boolean)

Purpose: to determine whether a character represents an alphabetic character

char-ci<=? : (char char ... -> boolean)

Purpose: to determine whether a character precedes another (or is equal to it) in a case-insensitive manner

char-ci<? : (char char ... -> boolean)

Purpose: to determine whether a character precedes another in a case-insensitive manner

char-ci=? : (char char ... -> boolean)

Purpose: to determine whether two characters are equal in a case-insensitive manner

char-ci>=? : (char char ... -> boolean)

Purpose: to determine whether a character succeeds another (or is equal to it) in a case-insensitive manner

char-ci>? : (char char ... -> boolean)

Purpose: to determine whether a character succeeds another in a case-insensitive manner

char-downcase : (char -> char)

Purpose: to determine the equivalent lower-case character

char-lower-case? : (char -> boolean)

Purpose: to determine whether a character is a lower-case character

char-numeric? : (char -> boolean)

Purpose: to determine whether a character represents a digit

char-upcase : (char -> char)

Purpose: to determine the equivalent upper-case character

char-upper-case? : (char -> boolean)

Purpose: to determine whether a character is an upper-case character

char-whitespace? : (char -> boolean)

Purpose: to determine whether a character represents space

char<=? : (char char ... -> boolean)

Purpose: to determine whether a character precedes another (or is equal to it)

char<? : (char char ... -> boolean)

Purpose: to determine whether a character precedes another

char=? : (char char ... -> boolean)

Purpose: to determine whether two characters are equal

char>=? : (char char ... -> boolean)

Purpose: to determine whether a character succeeds another (or is equal to it)

char>? : (char char ... -> boolean)

Purpose: to determine whether a character succeeds another

char? : (any -> boolean)

Purpose: to determine whether a value is a character

format : (string any ... -> string)

Purpose: to format a string, possibly embedding values

list->string : ((listof char) -> string)

Purpose: to convert a s list of characters into a string

make-string : (nat char -> string)

Purpose: to produce a string of given length from a single given character

string : (char ... -> string)

Purpose: (string c1 c2 ...) builds a string

string->list : (string -> (listof char))

Purpose: to convert a string into a list of characters

string->number : (string -> (union number false))

Purpose: to convert a string into a number, produce false if impossible

string->symbol : (string -> symbol)

Purpose: to convert a string into a symbol

string-append : (string ... -> string)

Purpose: to juxtapose the characters of several strings

string-ci<=? : (string string ... -> boolean)

Purpose: to determine whether one string alphabetically precedes another (or is equal to it) in a case-insensitive manner

string-ci<? : (string string ... -> boolean)

Purpose: to determine whether one string alphabetically precedes another in a case-insensitive manner

string-ci=? : (string string ... -> boolean)

Purpose: to compare two strings character-wise in a case-insensitive manner

string-ci>=? : (string string ... -> boolean)

Purpose: to determine whether one string alphabetically succeeds another (or is equal to it) in a case-insensitive manner

string-ci>? : (string string ... -> boolean)

Purpose: to determine whether one string alphabetically succeeds another in a case-insensitive manner

string-copy : (string -> string)

Purpose: to copy a string

string-length : (string -> nat)

Purpose: to determine the length of a string

string-ref : (string nat -> char)

Purpose: to extract the i-the character from a string

string<=? : (string string ... -> boolean)

Purpose: to determine whether one string alphabetically precedes another (or is equal to it)

string<? : (string string ... -> boolean)

Purpose: to determine whether one string alphabetically precedes another

string=? : (string string ... -> boolean)

Purpose: to compare two strings character-wise

string>=? : (string string ... -> boolean)

Purpose: to determine whether one string alphabetically succeeds another (or is equal to it)

string>? : (string string ... -> boolean)

Purpose: to determine whether one string alphabetically succeeds another

string? : (any -> boolean)

Purpose: to determine whether a value is a string

substring : (string nat nat -> string)

Purpose: to extract the substring starting at a 0-based index up to the second 0-based index (exclusive)

image=? : (image image -> boolean)

Purpose: to determine whether two images are equal

image? : (any -> boolean)

Purpose: to determine whether a value is an image

=~ : (real real non-negative-real -> boolean)

Purpose: to check whether two real numbers are within some amount (the third argument) of either other

eof : eof

Purpose: the end-of-file value

eof-object? : (any -> boolean)

Purpose: to determine whether some value is the end-of-file value

eq? : (any any -> boolean)

Purpose: to compare two values

equal? : (any any -> boolean)

Purpose: to determine whether two values are structurally equal

equal~? : (any any non-negative-real -> boolean)

Purpose: to compare like equal? on the first two arguments, except using =~ in the case of real numbers

eqv? : (any any -> boolean)

Purpose: to compare two values

error : (symbol string -> void)

Purpose: to signal an error

exit : (-> void)

Purpose: to exit the running program

identity : (any -> any)

Purpose: to return the argument unchanged

struct? : (any -> boolean)

Purpose: to determine whether some value is a structure

andmap : ((X -> boolean) (listof X) -> boolean)

Purpose: (andmap p (list x-1 ... x-n)) = (and (p x-1) (and ... (p x-n)))

apply : 

((X-1 ... X-N -> Y)

 X-1

 ...

 X-i

 (list X-i+1 ... X-N)

 ->

 Y)

Purpose: to apply a function using items from a list as the arguments

build-list : (nat (nat -> X) -> (listof X))

Purpose: (build-list n f) = (list (f 0) ... (f (- n 1)))

build-string : (nat (nat -> char) -> string)

Purpose: (build-string n f) = (string (f 0) ... (f (- n 1)))

compose : 

((Y-1 -> Z)

 ...

 (Y-N -> Y-N-1)

 (X-1 ... X-N -> Y-N)

 ->

 (X-1 ... X-N -> Z))

Purpose: to compose a sequence of procedures into a single procedure

filter : ((X -> boolean) (listof X) -> (listof X))

Purpose: to construct a list from all those items on a list for which the predicate holds

foldl : ((X Y -> Y) Y (listof X) -> Y)

Purpose: (foldl f base (list x-1 ... x-n)) = (f x-n ... (f x-1 base))

foldr : ((X Y -> Y) Y (listof X) -> Y)

Purpose: (foldr f base (list x-1 ... x-n)) = (f x-1 ... (f x-n base))

for-each : ((any ... -> any) (listof any) ... -> void)

Purpose: to apply a function to each item on one or more lists for effect only

map : ((X ... -> Z) (listof X) ... -> (listof Z))

Purpose: to construct a new list by applying a function to each item on one or more existing lists

memf : 

((X -> boolean)

 (listof X)

 ->

 (union false (listof X)))

Purpose: to determine whether the first argument produces true for some value in the second argument

ormap : ((X -> boolean) (listof X) -> boolean)

Purpose: (ormap p (list x-1 ... x-n)) = (or (p x-1) (or ... (p x-n)))

procedure? : (any -> boolean)

Purpose: to determine if a value is a procedure

quicksort : ((listof X) (X X -> boolean) -> (listof X))

Purpose: to construct a list from all items on a list in an order according to a predicate

sort : ((listof X) (X X -> boolean) -> (listof X))

Purpose: to construct a list from all items on a list in an order according to a predicate