# Advanced Student Language

- PROGRAM
  - DEF-OR-EXP ...
- DEF-OR-EXP
  - DEFINITION
  - EXPRESSION
- DEFINITION
  - `(`define` (NAME NAME ...) EXPRESSION)`
  - `(`define` NAME EXPRESSION)`
  - `(`define-struct` NAME (NAME ...))`
- EXPRESSION
  - `(`begin` EXPRESSION EXPRESSION ...)`
  - `(`begin0` EXPRESSION EXPRESSION ...)`
  - `(`set!` NAME EXPRESSION)`
  - `(`delay` EXPRESSION)`
  - `(`lambda` (NAME ...) EXPRESSION)`
  - `(`local` (DEFINITION ...) EXPRESSION)`
  - `(`letrec` ((NAME EXPRESSION) ...) EXPRESSION)`
  - `(`shared` ((NAME EXPRESSION) ...) EXPRESSION)`
  - `(`let` ((NAME EXPRESSION) ...) EXPRESSION)`
  - `(`let` NAME ((NAME EXPRESSION) ...) EXPRESSION)`
  - `(`let*` ((NAME EXPRESSION) ...) EXPRESSION)`
  - `(`recur` NAME ((NAME EXPRESSION) ...) EXPRESSION)`
  - `(EXPRESSION EXPRESSION ...)`
  - `(PRIM-OP EXPRESSION ...)`
  - `(`cond` (EXPRESSION EXPRESSION) (EXPRESSION EXPRESSION) ...)`
  - `(`cond` (EXPRESSION EXPRESSION) ... (`else` EXPRESSION))`
  - `(`case` EXPRESSION ((CHOICE CHOICE ...) EXPRESSION) ((CHOICE CHOICE ...) EXPRESSION) ...)`
  - `(`case` EXPRESSION ((CHOICE CHOICE ...) EXPRESSION) ... (`else` EXPRESSION))`
  - `(`if` EXPRESSION EXPRESSION EXPRESSION)`
  - `(`when` EXPRESSION EXPRESSION)`
  - `(`unless` EXPRESSION EXPRESSION)`
  - `(`and` EXPRESSION EXPRESSION EXPRESSION ...)`
  - `(`or` EXPRESSION EXPRESSION EXPRESSION ...)`
  - `(`time` EXPRESSION)`
  - `empty`
  - `NAME`
  - `'`QUOTED
  - ```QUASIQUOTED
  - NUMBER
  - `true`
  - `false`
  - STRING
  - CHARACTER
- NAME
  - a sequence of keyboard characters not including: space " , ' ` ( ) [ ] { } | ; #
- CHOICE
  - `NAME`
  - NUMBER
- QUOTED
  - `NAME`
  - NUMBER
  - STRING
  - CHARACTER
  - (QUOTED ...)
  - `'`QUOTED
  - ```QUOTED
  - `,`QUOTED
  - `,@`QUOTED
- QUASIQUOTED
  - `NAME`
  - NUMBER
  - STRING
  - CHARACTER
  - (QUASIQUOTED ...)
  - `'`QUASIQUOTED
  - ```QUASIQUOTED
  - `,`EXPRESSION
  - `,@`EXPRESSION
- PRIM-OPs
  - 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 -> bool)`
    - `conjugate` : `(num -> num)`
    - `cos` : `(num -> num)`
    - `cosh` : `(num -> num)`
    - `current-seconds` : `(-> int)`
    - `denominator` : `(rat -> int)`
    - `e` : `real`
    - `even?` : `(integer -> bool)`
    - `exact->inexact` : `(num -> num)`
    - `exact?` : `(num -> bool)`
    - `exp` : `(num -> num)`
    - `expt` : `(num num -> num)`
    - `floor` : `(real -> int)`
    - `gcd` : `(int int ... -> int)`
    - `imag-part` : `(num -> real)`
    - `inexact->exact` : `(num -> num)`
    - `inexact?` : `(num -> bool)`
    - `integer->char` : `(int -> char)`
    - `integer?` : `(any -> bool)`
    - `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 -> bool)`
    - `number->string` : `(num -> string)`
    - `number?` : `(any -> boolean)`
    - `numerator` : `(rat -> int)`
    - `odd?` : `(integer -> bool)`
    - `pi` : `real`
    - `positive?` : `(number -> bool)`
    - `quotient` : `(int int -> int)`
    - `random` : `(int -> int)`
    - `rational?` : `(any -> bool)`
    - `real-part` : `(num -> real)`
    - `real?` : `(any -> bool)`
    - `remainder` : `(int int -> int)`
    - `round` : `(real -> int)`
    - `sgn` : `(real -> (union 1 #i1.0 0 #i0.0 -1 #i-1.0))`
    - `sin` : `(num -> num)`
    - `sinh` : `(num -> num)`
    - `sqr` : `(num -> num)`
    - `sqrt` : `(num -> num)`
    - `sub1` : `(number -> number)`
    - `tan` : `(num -> num)`
    - `zero?` : `(number -> bool)`
  - Booleans
    - `boolean=?` : `(boolean boolean -> boolean)`
    - `boolean?` : `(any -> boolean)`
    - `not` : `(boolean -> boolean)`
  - Symbols
    - `symbol->string` : `(symbol -> string)`
    - `symbol=?` : `(symbol symbol -> boolean)`
    - `symbol?` : `(any -> boolean)`
  - Lists
    - `append` : `((listof any) ... -> (listof any))`
    - `append!` : `((listof any) ... -> (listof any))`
    - `assq` : `(x (listof (cons x y)) -> (union false (cons x y)))`
    - `caaar` : `((cons (cons (cons w (listof z)) (listof y)) (listof x)) -> w)`
    - `caadr` : `((cons (cons (cons w (listof z)) (listof y)) (listof x)) -> (listof z))`
    - `caar` : `((cons (cons z (listof y)) (listof x)) -> z)`
    - `cadar` : `((cons (cons w (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)`
    - `cdaar` : `((cons (cons (cons w (listof z)) (listof y)) (listof x)) -> (listof z))`
    - `cdadr` : `((cons w (cons (cons z (listof y)) (listof x))) -> (listof y))`
    - `cdar` : `((cons (cons z (listof y)) (listof x)) -> (listof y))`
    - `cddar` : `((cons (cons w (cons z (listof y))) (listof x)) -> (listof y))`
    - `cdddr` : `((cons w (cons z (cons y (listof x)))) -> (listof x))`
    - `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)`
    - `equal?` : `(list list -> boolean)`
    - `fifth` : `((listof y) -> y)`
    - `first` : `((cons y (listof x)) -> y)`
    - `fourth` : `((listof y) -> y)`
    - `length` : `(list -> number)`
    - `list` : `(any ... (listof any) -> (listof any))`
    - `list` : `(any ... -> (listof any))`
    - `list-ref` : `((listof x) number -> x)`
    - `list?` : `(any -> boolean)`
    - `member` : `(any list -> (union false list))`
    - `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)`
    - `set-car!` : `((cons y (listof x)) y -> void)`
    - `set-cdr!` : `((cons y (listof x)) (listof x) -> void)`
    - `set-first!` : `((cons y (listof x)) y -> void)`
    - `set-rest!` : `((cons y (listof x)) (listof x) -> void)`
    - `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)`
    - `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 ... -> 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->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)`
  - Misc
    - `eof` : `eof`
    - `eof-object?` : `(any -> boolean)`
    - `eq?` : `(any any -> boolean)`
    - `eqv?` : `(any any -> boolean)`
    - `error` : `(symbol string -> void)`
    - `exit` : `(-> void)`
    - `force` : `(delay -> any)`
    - `identity` : `(any -> any)`
    - `image=?` : `(image image -> boolean)`
    - `promise?` : `(any -> boolean)`
    - `struct?` : `(any -> boolean)`
    - `void?` : `(any -> boolean)`
  - Higher-Order Functions
    - `andmap` : `((x -> boolean) (listof x) -> boolean)`
    - `apply` : `((x-1 ... x-n -> y) x-1 ... x-i (list x-i+1 ... x-n) -> y)`
    - `assf` : `((x -> boolean) (listof (cons x y)) -> (union false (cons x y)))`
    - `build-list` : `(nat (nat -> x) -> (listof x))`
    - `build-string` : `(nat (nat -> char) -> string)`
    - `compose` : `((y-1 -> z) ... (y-n -> y-n-1) (x-1 ... x-n -> y-n) -> (x-1 ... x-n -> z))`
    - `filter` : `((x -> boolean) (listof x) -> (listof x))`
    - `foldl` : `((x y -> z) y (listof x) -> z)`
    - `foldr` : `((x y -> z) y (listof x) -> z)`
    - `for-each` : `((any ... -> any) (listof any) ... -> void)`
    - `map` : `((x ... -> z) (listof x) ... -> (listof z))`
    - `memf` : `((x -> boolean) (listof x) -> (union false (listof x)))`
    - `ormap` : `((x -> boolean) (listof x) -> boolean)`
    - `procedure?` : `(any -> boolean)`
    - `quicksort` : `((x x -> boolean) (listof x) -> (listof x))`
  - Reading and Printing
    - `display` : `(any -> void)`
    - `newline` : `(-> void)`
    - `pretty-print` : `(any -> void)`
    - `print` : `(any -> void)`
    - `printf` : `(string any ... -> void)`
    - `read` : `(-> sexp)`
    - `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 -> (vectorof x))`
    - `vector?` : `(any -> boolean)`
  - Boxes
    - `box` : `(any -> box)`
    - `box?` : `(any -> boolean)`
    - `set-box!` : `(box any -> void)`
    - `unbox` : `(box -> any)`

This language is a superset of Intermediate Student with Lambda.