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) |
|
| | |
| (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]) |
|
| | |
| |
|
| | |
| (if expr expr expr) |
|
| | |
| (and expr expr expr ...) |
|
| | |
| (or expr expr expr ...) |
|
| | |
| (time expr) |
|
| | |
| |
|
| | |
| id ; identifier |
|
| | |
| prim-op ; primitive operation |
|
| | |
| 'id |
|
| | |
| ’quoted ; quoted value |
|
| | |
| `quasiquoted ; quasiquote |
|
| | |
| number |
|
| | |
| |
|
| | |
| |
|
| | |
| 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-error expr expr) |
|
|
|
|
|
library-require |
| = |
| (require string) |
|
| | |
| (require (lib string string ...)) |
|
| | |
| (require (planet string package)) |
|
|
|
|
|
package |
| = |
| (string string number number) |
An id is a sequence of characters not including a space or one of the following:
" , ' ` ( ) [ ] { } | ; #
A number is a number such as 123, 3/2, or 5.5.
A string is enclosed by a pair of ". Unlike symbols, strings may be split into characters and manipulated by a variety of primitive functions. For example, "abcdef", "This is a string", and "This is a string with \" inside" are all strings.
A character begins with #\ and has the name of the character. For example, #\a, #\b, and #\space are characters.
A prim-op is one of: | |||||||||
Numbers: Integers, Rationals, Reals, Complex, Exacts, Inexacts | |||||||||
* : (num num num ... -> num) | |||||||||
+ : (num num num ... -> num) | |||||||||
- : (num num ... -> num) | |||||||||
/ : (num num num ... -> num) | |||||||||
< : (real real real ... -> boolean) | |||||||||
<= : (real real real ... -> boolean) | |||||||||
= : (num num num ... -> boolean) | |||||||||
> : (real real real ... -> boolean) | |||||||||
>= : (real real ... -> boolean) | |||||||||
abs : (real -> real) | |||||||||
acos : (num -> num) | |||||||||
add1 : (number -> number) | |||||||||
angle : (num -> real) | |||||||||
asin : (num -> num) | |||||||||
atan : (num -> num) | |||||||||
ceiling : (real -> int) | |||||||||
complex? : (any -> boolean) | |||||||||
conjugate : (num -> num) | |||||||||
cos : (num -> num) | |||||||||
cosh : (num -> num) | |||||||||
current-seconds : (-> int) | |||||||||
denominator : (rat -> int) | |||||||||
e : real | |||||||||
even? : (integer -> boolean) | |||||||||
exact->inexact : (num -> num) | |||||||||
exact? : (num -> boolean) | |||||||||
exp : (num -> num) | |||||||||
expt : (num num -> num) | |||||||||
floor : (real -> int) | |||||||||
gcd : (int int ... -> int) | |||||||||
imag-part : (num -> real) | |||||||||
inexact->exact : (num -> num) | |||||||||
inexact? : (num -> boolean) | |||||||||
integer->char : (int -> char) | |||||||||
integer? : (any -> boolean) | |||||||||
lcm : (int int ... -> int) | |||||||||
log : (num -> num) | |||||||||
magnitude : (num -> real) | |||||||||
make-polar : (real real -> num) | |||||||||
max : (real real ... -> real) | |||||||||
min : (real real ... -> real) | |||||||||
modulo : (int int -> int) | |||||||||
negative? : (number -> boolean) | |||||||||
number->string : (num -> string) | |||||||||
number? : (any -> boolean) | |||||||||
numerator : (rat -> int) | |||||||||
odd? : (integer -> boolean) | |||||||||
pi : real | |||||||||
positive? : (number -> boolean) | |||||||||
quotient : (int int -> int) | |||||||||
random : (int -> int) | |||||||||
rational? : (any -> boolean) | |||||||||
real-part : (num -> real) | |||||||||
real? : (any -> boolean) | |||||||||
remainder : (int int -> int) | |||||||||
round : (real -> int) | |||||||||
sgn : (real -> (union 1 1.0 0 0.0 -1 -1.0)) | |||||||||
sin : (num -> num) | |||||||||
sinh : (num -> num) | |||||||||
sqr : (num -> num) | |||||||||
sqrt : (num -> num) | |||||||||
sub1 : (number -> number) | |||||||||
tan : (num -> num) | |||||||||
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 | |||||||||
| |||||||||
| |||||||||
| |||||||||
| |||||||||
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 : (list -> number) | |||||||||
list : (any ... -> (listof any)) | |||||||||
list* : (any ... (listof any) -> (listof any)) | |||||||||
list-ref : ((listof X) natural-number -> X) | |||||||||
member : (any list -> boolean) | |||||||||
memq : (any list -> (union false list)) | |||||||||
memv : (any list -> (union false list)) | |||||||||
null : empty | |||||||||
null? : (any -> boolean) | |||||||||
pair? : (any -> boolean) | |||||||||
rest : ((cons Y (listof X)) -> (listof X)) | |||||||||
reverse : (list -> 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-x : (posn -> number) | |||||||||
posn-y : (posn -> number) | |||||||||
posn? : (anything -> boolean) | |||||||||
Characters | |||||||||
char->integer : (char -> integer) | |||||||||
char-alphabetic? : (char -> boolean) | |||||||||
char-ci<=? : (char char ... -> boolean) | |||||||||
char-ci<? : (char char ... -> boolean) | |||||||||
char-ci=? : (char char ... -> boolean) | |||||||||
char-ci>=? : (char char ... -> boolean) | |||||||||
char-ci>? : (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 ... -> boolean) | |||||||||
char<? : (char char ... -> boolean) | |||||||||
char=? : (char char ... -> boolean) | |||||||||
char>=? : (char char ... -> boolean) | |||||||||
char>? : (char char ... -> boolean) | |||||||||
char? : (any -> boolean) | |||||||||
Strings | |||||||||
format : (string any ... -> string) | |||||||||
list->string : ((listof char) -> string) | |||||||||
make-string : (nat char -> string) | |||||||||
string : (char ... -> string) | |||||||||
string->list : (string -> (listof char)) | |||||||||
string->number : (string -> (union number false)) | |||||||||
string->symbol : (string -> symbol) | |||||||||
string-append : (string ... -> string) | |||||||||
string-ci<=? : (string string ... -> boolean) | |||||||||
string-ci<? : (string string ... -> boolean) | |||||||||
string-ci=? : (string string ... -> boolean) | |||||||||
string-ci>=? : (string string ... -> boolean) | |||||||||
string-ci>? : (string string ... -> boolean) | |||||||||
string-copy : (string -> string) | |||||||||
string-length : (string -> nat) | |||||||||
string-ref : (string nat -> char) | |||||||||
string<=? : (string string ... -> boolean) | |||||||||
string<? : (string string ... -> boolean) | |||||||||
string=? : (string string ... -> boolean) | |||||||||
string>=? : (string string ... -> boolean) | |||||||||
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) | |||||||||
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 : (symbol string -> void) | |||||||||
exit : (-> void) | |||||||||
identity : (any -> any) | |||||||||
struct? : (any -> boolean) | |||||||||
Higher-Order Functions | |||||||||
andmap : ((X -> boolean) (listof X) -> boolean) | |||||||||
| |||||||||
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)) |