5 Advanced Student
program | = | def-or-expr ... | ||||
def-or-expr | = | definition | ||||
| | expr | |||||
| | test-case | |||||
| | library-require | |||||
definition | = | (define (id id id ...) expr) | ||||
| | (define id expr) | |||||
| | (define-struct id (id ...)) | |||||
expr | = | (begin expr expr ...) | ||||
| | (begin0 expr expr ...) | |||||
| | (set! id expr) | |||||
| | (delay expr) | |||||
| | (lambda (id ...) expr) | |||||
| | (λ (id ...) expr) | |||||
| | (local [definition ...] expr) | |||||
| | (letrec ([id expr] ...) expr) | |||||
| | (shared ([id expr] ...) expr) | |||||
| | (let ([id expr] ...) expr) | |||||
| | (let id ([id expr] ...) expr) | |||||
| | (let* ([id expr] ...) expr) | |||||
| | (recur id ([id expr] ...) expr) | |||||
| | (expr expr ...) ; function call | |||||
| | (cond [expr expr] ... [expr expr]) | |||||
| | (cond [expr expr] ... [else expr]) | |||||
| |
| |||||
| |
| |||||
| | (if expr expr expr) | |||||
| | (when expr expr) | |||||
| | (unless expr expr) | |||||
| | (and expr expr expr ...) | |||||
| | (or expr expr expr ...) | |||||
| | (time expr) | |||||
| | empty | |||||
| | id ; identifier | |||||
| | prim-op ; primitive operation | |||||
| | ’quoted ; quoted value | |||||
| | `quasiquoted ; quasiquote | |||||
| | number | |||||
| | true | |||||
| | false | |||||
| | string | |||||
| | character | |||||
choice | = | id ; treated as a symbol | ||||
| | number | |||||
quoted | = | id | ||||
| | number | |||||
| | string | |||||
| | character | |||||
| | (quoted ...) | |||||
| | ’quoted | |||||
| | `quoted | |||||
| | ,quoted | |||||
| | ,@quoted | |||||
quasiquoted | = | id | ||||
| | number | |||||
| | string | |||||
| | character | |||||
| | (quasiquoted ...) | |||||
| | ’quasiquoted | |||||
| | `quasiquoted | |||||
| | ,expr | |||||
| | ,@expr | |||||
test-case | = | (check-expect expr expr) | ||||
| | (check-within expr expr expr) | |||||
| | (check-member-of expr expr ...) | |||||
| | (check-range expr expr expr) | |||||
| | (check-error expr expr) | |||||
library-require | = | (require string) | ||||
| | (require (lib string string ...)) | |||||
| | (require (planet string package)) | |||||
package | = | (string string number number) |
A prim-op is one of: | |||||||||
Numbers: Integers, Rationals, Reals, Complex, Exacts, Inexacts | |||||||||
< : (real real real ... -> boolean) | |||||||||
<= : (real real real ... -> boolean) | |||||||||
= : (number number number ... -> boolean) | |||||||||
> : (real real real ... -> boolean) | |||||||||
>= : (real real ... -> boolean) | |||||||||
abs : (real -> real) | |||||||||
acos : (number -> number) | |||||||||
add1 : (number -> number) | |||||||||
angle : (number -> real) | |||||||||
asin : (number -> number) | |||||||||
atan : (number -> number) | |||||||||
ceiling : (real -> integer) | |||||||||
complex? : (any -> boolean) | |||||||||
conjugate : (number -> number) | |||||||||
cos : (number -> number) | |||||||||
cosh : (number -> number) | |||||||||
current-seconds : (-> integer) | |||||||||
denominator : (rat -> integer) | |||||||||
e : real | |||||||||
even? : (integer -> boolean) | |||||||||
exact->inexact : (number -> number) | |||||||||
exact? : (number -> boolean) | |||||||||
exp : (number -> number) | |||||||||
expt : (number number -> number) | |||||||||
floor : (real -> integer) | |||||||||
gcd : (integer integer ... -> integer) | |||||||||
imag-part : (number -> real) | |||||||||
inexact->exact : (number -> number) | |||||||||
inexact? : (number -> boolean) | |||||||||
integer->char : (integer -> char) | |||||||||
integer-sqrt : (number -> integer) | |||||||||
integer? : (any -> boolean) | |||||||||
lcm : (integer integer ... -> integer) | |||||||||
log : (number -> number) | |||||||||
magnitude : (number -> real) | |||||||||
make-polar : (real real -> number) | |||||||||
make-rectangular : (real real -> number) | |||||||||
max : (real real ... -> real) | |||||||||
min : (real real ... -> real) | |||||||||
modulo : (integer integer -> integer) | |||||||||
negative? : (number -> boolean) | |||||||||
number->string : (number -> string) | |||||||||
number? : (any -> boolean) | |||||||||
numerator : (rat -> integer) | |||||||||
odd? : (integer -> boolean) | |||||||||
pi : real | |||||||||
positive? : (number -> boolean) | |||||||||
quotient : (integer integer -> integer) | |||||||||
| |||||||||
rational? : (any -> boolean) | |||||||||
real-part : (number -> real) | |||||||||
real? : (any -> boolean) | |||||||||
remainder : (integer integer -> integer) | |||||||||
round : (real -> integer) | |||||||||
sgn : (real -> (union 1 1.0 0 0.0 -1 -1.0)) | |||||||||
sin : (number -> number) | |||||||||
sinh : (number -> number) | |||||||||
sqr : (number -> number) | |||||||||
sqrt : (number -> number) | |||||||||
sub1 : (number -> number) | |||||||||
tan : (number -> number) | |||||||||
zero? : (number -> boolean) | |||||||||
Booleans | |||||||||
boolean=? : (boolean boolean -> boolean) | |||||||||
boolean? : (any -> boolean) | |||||||||
false? : (any -> boolean) | |||||||||
not : (boolean -> boolean) | |||||||||
Symbols | |||||||||
symbol->string : (symbol -> string) | |||||||||
symbol=? : (symbol symbol -> boolean) | |||||||||
symbol? : (any -> boolean) | |||||||||
Lists | |||||||||
append : ((listof any) ... -> (listof any)) | |||||||||
assoc : (any (listof any) -> (listof any) or false) | |||||||||
| |||||||||
| |||||||||
| |||||||||
caar : ((cons (cons Z (listof Y)) (listof X)) -> Z) | |||||||||
| |||||||||
cadddr : ((listof Y) -> Y) | |||||||||
caddr : ((cons W (cons Z (cons Y (listof X)))) -> Y) | |||||||||
cadr : ((cons Z (cons Y (listof X))) -> Y) | |||||||||
car : ((cons Y (listof X)) -> Y) | |||||||||
| |||||||||
| |||||||||
| |||||||||
| |||||||||
| |||||||||
cddr : ((cons Z (cons Y (listof X))) -> (listof X)) | |||||||||
cdr : ((cons Y (listof X)) -> (listof X)) | |||||||||
cons : (X (listof X) -> (listof X)) | |||||||||
cons? : (any -> boolean) | |||||||||
eighth : ((listof Y) -> Y) | |||||||||
empty? : (any -> boolean) | |||||||||
fifth : ((listof Y) -> Y) | |||||||||
first : ((cons Y (listof X)) -> Y) | |||||||||
fourth : ((listof Y) -> Y) | |||||||||
length : ((listof any) -> number) | |||||||||
list : (any ... -> (listof any)) | |||||||||
list* : (any ... (listof any) -> (listof any)) | |||||||||
list-ref : ((listof X) natural-number -> X) | |||||||||
list? : (any -> boolean) | |||||||||
make-list : (natural-number any -> (listof any)) | |||||||||
member : (any (listof any) -> boolean) | |||||||||
member? : (any (listof any) -> boolean) | |||||||||
memq : (any (listof any) -> (union false list)) | |||||||||
memv : (any (listof any) -> (union false list)) | |||||||||
null : empty | |||||||||
null? : (any -> boolean) | |||||||||
pair? : (any -> boolean) | |||||||||
remove : (any (listof any) -> (listof any)) | |||||||||
rest : ((cons Y (listof X)) -> (listof X)) | |||||||||
reverse : ((listof any) -> list) | |||||||||
second : ((cons Z (cons Y (listof X))) -> Y) | |||||||||
seventh : ((listof Y) -> Y) | |||||||||
sixth : ((listof Y) -> Y) | |||||||||
third : ((cons W (cons Z (cons Y (listof X)))) -> Y) | |||||||||
Posns | |||||||||
make-posn : (number number -> posn) | |||||||||
posn : signature | |||||||||
posn-x : (posn -> number) | |||||||||
posn-y : (posn -> number) | |||||||||
posn? : (anything -> boolean) | |||||||||
set-posn-x! : (posn number -> void) | |||||||||
set-posn-y! : (posn number -> void) | |||||||||
Characters | |||||||||
char->integer : (char -> integer) | |||||||||
char-alphabetic? : (char -> boolean) | |||||||||
char-ci<=? : (char char char ... -> boolean) | |||||||||
char-ci<? : (char char char ... -> boolean) | |||||||||
char-ci=? : (char char char ... -> boolean) | |||||||||
char-ci>=? : (char char char ... -> boolean) | |||||||||
char-ci>? : (char char char ... -> boolean) | |||||||||
char-downcase : (char -> char) | |||||||||
char-lower-case? : (char -> boolean) | |||||||||
char-numeric? : (char -> boolean) | |||||||||
char-upcase : (char -> char) | |||||||||
char-upper-case? : (char -> boolean) | |||||||||
char-whitespace? : (char -> boolean) | |||||||||
char<=? : (char char char ... -> boolean) | |||||||||
char<? : (char char char ... -> boolean) | |||||||||
char=? : (char char char ... -> boolean) | |||||||||
char>=? : (char char char ... -> boolean) | |||||||||
char>? : (char char char ... -> boolean) | |||||||||
char? : (any -> boolean) | |||||||||
Strings | |||||||||
explode : (string -> (listof string)) | |||||||||
format : (string any ... -> string) | |||||||||
implode : ((listof string) -> string) | |||||||||
int->string : (integer -> string) | |||||||||
list->string : ((listof char) -> string) | |||||||||
make-string : (nat char -> string) | |||||||||
replicate : (nat string -> string) | |||||||||
string : (char ... -> string) | |||||||||
string->int : (string -> integer) | |||||||||
string->list : (string -> (listof char)) | |||||||||
string->number : (string -> (union number false)) | |||||||||
string->symbol : (string -> symbol) | |||||||||
string-alphabetic? : (string -> boolean) | |||||||||
string-append : (string ... -> string) | |||||||||
string-ci<=? : (string string string ... -> boolean) | |||||||||
string-ci<? : (string string string ... -> boolean) | |||||||||
string-ci=? : (string string string ... -> boolean) | |||||||||
string-ci>=? : (string string string ... -> boolean) | |||||||||
string-ci>? : (string string string ... -> boolean) | |||||||||
string-copy : (string -> string) | |||||||||
string-ith : (string nat -> string) | |||||||||
string-length : (string -> nat) | |||||||||
string-lower-case? : (string -> boolean) | |||||||||
string-numeric? : (string -> boolean) | |||||||||
string-ref : (string nat -> char) | |||||||||
string-upper-case? : (string -> boolean) | |||||||||
string-whitespace? : (string -> boolean) | |||||||||
string<=? : (string string string ... -> boolean) | |||||||||
string<? : (string string string ... -> boolean) | |||||||||
string=? : (string string string ... -> boolean) | |||||||||
string>=? : (string string string ... -> boolean) | |||||||||
string>? : (string string string ... -> boolean) | |||||||||
string? : (any -> boolean) | |||||||||
substring : (string nat nat -> string) | |||||||||
Images | |||||||||
image=? : (image image -> boolean) | |||||||||
image? : (any -> boolean) | |||||||||
Misc | |||||||||
=~ : (real real non-negative-real -> boolean) | |||||||||
current-milliseconds : (-> exact-integer) | |||||||||
eof : eof | |||||||||
eof-object? : (any -> boolean) | |||||||||
eq? : (any any -> boolean) | |||||||||
equal? : (any any -> boolean) | |||||||||
equal~? : (any any non-negative-real -> boolean) | |||||||||
eqv? : (any any -> boolean) | |||||||||
error : (any ... -> void) | |||||||||
exit : (-> void) | |||||||||
force : (delay -> any) | |||||||||
gensym : (-> symbol?) | |||||||||
identity : (any -> any) | |||||||||
promise? : (any -> boolean) | |||||||||
sleep : (-> positive-number void) | |||||||||
struct? : (any -> boolean) | |||||||||
void : (-> void) | |||||||||
void? : (any -> boolean) | |||||||||
Numbers (relaxed conditions) | |||||||||
* : (number ... -> number) | |||||||||
+ : (number ... -> number) | |||||||||
- : (number ... -> number) | |||||||||
/ : (number ... -> number) | |||||||||
Higher-Order Functions | |||||||||
andmap : ((X -> boolean) (listof X) -> boolean) | |||||||||
| |||||||||
argmax : ((X -> real) (listof X) -> X) | |||||||||
argmin : ((X -> real) (listof X) -> X) | |||||||||
build-list : (nat (nat -> X) -> (listof X)) | |||||||||
build-string : (nat (nat -> char) -> string) | |||||||||
| |||||||||
filter : ((X -> boolean) (listof X) -> (listof X)) | |||||||||
foldl : ((X Y -> Y) Y (listof X) -> Y) | |||||||||
foldr : ((X Y -> Y) Y (listof X) -> Y) | |||||||||
for-each : ((any ... -> any) (listof any) ... -> void) | |||||||||
map : ((X ... -> Z) (listof X) ... -> (listof Z)) | |||||||||
| |||||||||
ormap : ((X -> boolean) (listof X) -> boolean) | |||||||||
procedure? : (any -> boolean) | |||||||||
quicksort : ((listof X) (X X -> boolean) -> (listof X)) | |||||||||
sort : ((listof X) (X X -> boolean) -> (listof X)) | |||||||||
Reading and Printing | |||||||||
display : (any -> void) | |||||||||
newline : (-> void) | |||||||||
pretty-print : (any -> void) | |||||||||
print : (any -> void) | |||||||||
printf : (string any ... -> void) | |||||||||
read : (-> sexp) | |||||||||
with-input-from-file : (string (-> any) -> any) | |||||||||
with-input-from-string : (string (-> any) -> any) | |||||||||
with-output-to-file : (string (-> any) -> any) | |||||||||
with-output-to-string : (string (-> any) -> any) | |||||||||
write : (any -> void) | |||||||||
Vectors | |||||||||
build-vector : (nat (nat -> X) -> (vectorof X)) | |||||||||
make-vector : (number X -> (vectorof X)) | |||||||||
vector : (X ... -> (vector X ...)) | |||||||||
vector-length : ((vector X) -> nat) | |||||||||
vector-ref : ((vector X) nat -> X) | |||||||||
vector-set! : ((vectorof X) nat X -> void) | |||||||||
vector? : (any -> boolean) | |||||||||
Boxes | |||||||||
box : (any -> box) | |||||||||
box? : (any -> boolean) | |||||||||
set-box! : (box any -> void) | |||||||||
unbox : (box -> any) | |||||||||
Hash Tables | |||||||||
hash-copy : (hash -> hash) | |||||||||
hash-count : (hash -> integer) | |||||||||
hash-eq? : (hash -> boolean) | |||||||||
hash-equal? : (hash -> boolean) | |||||||||
hash-eqv? : (hash -> boolean) | |||||||||
hash-for-each : ((hash X Y) (X Y -> any) -> void) | |||||||||
hash-has-key? : ((hash X Y) X -> boolean) | |||||||||
hash-map : ((hash X Y) (X Y -> A) -> (listof A)) | |||||||||
| |||||||||
| |||||||||
hash-remove! : ((hash X Y) X -> void) | |||||||||
hash-set! : ((hash X Y) X Y -> void) | |||||||||
| |||||||||
hash? : (any -> boolean) | |||||||||
make-hash : ((listof (list X Y)) -> (hash X Y)) | |||||||||
make-hasheq : ((listof (list X Y)) -> (hash X Y)) | |||||||||
make-hasheqv : ((listof (list X Y)) -> (hash X Y)) |