4 Intermediate Student with Lambda
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 | = | (lambda (id id ...) expr) | ||
| | (λ (id id ...) expr) | |||
| | (local [definition ...] expr) | |||
| | (letrec ([id expr] ...) expr) | |||
| | (let ([id expr] ...) expr) | |||
| | (let* ([id expr] ...) expr) | |||
| | (expr expr expr ...) ; function call | |||
| | (cond [expr expr] ... [expr expr]) | |||
| | (cond [expr expr] ... [else expr]) | |||
| | (if expr 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 | |||
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) | |||
| | (check-error 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) | |||||||||
random : (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)) | |||||||||
| |||||||||
| |||||||||
| |||||||||
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) | |||||||||
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) | |||||||||
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 | |||||||||
=~ : (number number non-negative-real -> boolean) | |||||||||
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) | |||||||||
identity : (any -> any) | |||||||||
struct? : (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)) |