prelude
(abs v) -> number?
  v: number?

Returns the absolute value of v.

(acos v) -> number?
  v: number?

Returns the arc cosine of v.

(all-of f1, f2, ...) -> procedure?
  f1, f2, ...: procedure? that takes a value as input and returns a boolean.

Returns a unary function that returns #t if and only all of f1, f2, … are #t for its argument.

(any-of f1, f2, ...) -> procedure?
  f1, f2, ...: procedure? that takes a value as input and returns a boolean.

Returns a unary function that returns #t if and only one of f1, f2, … is #t for its argument.

(append l1, l2, ...) -> list?
  l1, l2, ...: list?

Returns a new list containing the elements of lists l1, l2, … in sequence.

(apply f l) -> any
  f: procedure?
  l: list?

Calls f with the values contained in l.

(asin v) -> number?
  v: number?

Returns the arc sine of v.

(assoc-key? k l) -> any
  k: any
  l: list?, an association list

Returns #t if k is a key in association list l.

(assoc-ref k l) -> any
  k: any
  l: list?, an association list

Returns the value associated with key k in association list l.

(assoc-set k v l) -> list?
  k: any
  v: any
  l: list?, an association list

Returns a new association list containing the same key-value pairs as l except that k is associated with v.

(atan v) -> number?
  v: number?

Returns the arc tangent of v.

(boolean? v) -> boolean?
  v: any

Returns #t if and only v is a boolean.

(car v) -> any
  v: pair? or list?

Returns the first element of v.

(cdr v) -> any
  v: pair? or list?

Returns the second element of v.

(ceiling v) -> integer?
  v: number?

Returns the smallest integer greater than or equal to v.

(char-alphabetic? c) -> boolean?
  c: char?

Returns #t if and only c is an alphabetic character.

(char-downcase c) -> char?
  c: char?

Returns the lower-case equivalent of c.

(char=? c1, c2, ...) -> boolean?
  c1, c2, ...: char?

Returns #t if and only c1, c2, … are all equivalent characters.

(char-ci=? c1, c2, ...) -> boolean?
  c1, c2, ...: char?

Returns #t if and only c1, c2, … are all equivalent characters, ignoring case.

(char-foldcase c) -> char?
  c: char?

Returns the case-folded equivalent of c. This is a version of c that is appropriate for case-insensitive comparison.

(char>=? c1, c2, ...) -> boolean?
  c1, c2, ...: char?

Returns #t if and only c1, c2, … have non-increasing character values.

(char-ci>=? c1, c2, ...) -> boolean?
  c1, c2, ...: char?

Returns #t if and only c1, c2, … have non-increasing character values, ignoring case.

(char>? c1, c2, ...) -> boolean?
  c1, c2, ...: char?

Returns #t if and only c1, c2, … have strictly decreasing character values.

(char-ci>? c1, c2, ...) -> boolean?
  c1, c2, ...: char?

Returns #t if and only c1, c2, … have strictly decreasing character values, ignoring case.

(char<=? c1, c2, ...) -> boolean?
  c1, c2, ...: char?

Returns #t if and only c1, c2, … have non-decreasing character values.

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

Returns #t if and only c1, c2, … have non-decreasing character values, ignoring case.

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

Returns #t if and only c is a lower-case character.

(char<? c1, c2, ...) -> boolean?
  c1, c2, ...: char?

Returns #t if and only c1, c2, … have strictly increasing character values.

(char-ci<? c1, c2, ...) -> boolean?
  c1, c2, ...: char?

Returns #t if and only c1, c2, … have strictly increasing character values, ignoring case.

(char-numeric? c) -> boolean?
  c: char?

Returns #t if and only c is a numeric character.

(char? v) -> boolean?
  v: any

Returns #t if and only v is a character.

(char->integer c) -> integer?
  c: char?

Returns the codepoint value of character c.

(char-upcase c) -> char?
  c: char?

Returns the upper-case equivalent of c.

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

Returns #t if and only c is an upper-case character.

(char-whitespace? c) -> boolean?
  c: char?

Returns #t if and only c is a whitespace character.

(compose f1, ..., fk) -> procedure?
  f1, ..., fk: procedure?

Returns a new procedure that is the composition of the given functions, i.e., f(x) = f1(f2(...(fk(x)))).

(cons v1 v2) -> pair?
  v1: any
  v2: any

Returns a new cons cell containing v1 and v2.

(cos v) -> number?
  v: number?

Returns the cosine of v.

(c...r v) -> any
  v: pair? or list?

Chains together car and cdr operations according to the sequence of a and d characters in the function name, up to four levels deep. For example, (caddr v) is equivalent to (car (cdr (cdr v))).

(digit-value c) -> integer?
  c: char?

Returns the numeric value of c if c is a decimal digit (0-10), otherwise raises an error.

(/ v1, v2, ...) -> number?
  v1, v2, ...: number?

Returns the quotient of v1, v2, … .

else : boolean?

A synonym for #t appropriate for use as the final guard of a cond expression.

(equal? v1 v2) -> boolean?
  v1: any
  v2: any

Returns #t if and only v1 and v2 are (structurally) equal values.

(=-eps n) -> procedure?
  n: number?

Returns a function that takes two numbers x and y as input returns #t if |x - y| < n.

(error msg) -> any
  msg: string?

Raises a runtime error with message msg.

(even? v) -> boolean?
  v: any

Returns #t if and only v is even.

(exp v) -> number?
  v: number?

Returns the exponential of v.

(expt x y) -> number?
  x: number?
  y: number?

Returns x raised to the power of y.

(file->lines path) -> list?
  path: string?

Returns the contents of the file at path as a list of strings, one for each line.

(file->string path) -> string?
  path: string?

Returns the contents of the file at path as a string.

(filter f l) -> list?
  f: procedure?
  l: list?

Returns a new list containing the elements of l for which f returns #t.

(floor v) -> integer?
  v: number?

Returns the largest integer less than or equal to v.

(fold f v l) -> any
  f: procedure?
  v: any
  l: list?

Returns the result of accumulating the result of applying f to each element of l, starting with initial value v. The function f takes two arguments, the first is the accumulated value and the second is the current element.

(fold-left f v l) -> any
  f: procedure?
  v: any
  l: list?

An alias for fold.

(fold-right f v l) -> any
  f: procedure?
  v: any
  l: list?

Returns the result of accumulating the result of applying f to each element of l in reverse order, starting with initial value v. The function f takes two arguments, the first is the current element and the second is the accumulated value.

(for-range beg end f) -> void
  beg: number?
  end: number?
  f: procedure?

Runs f on each integer in the range [beg, end). f takes one argument, the current value of integer.

(>= v1 v2) -> boolean?
  v1: number?
  v2: number?

Returns #t if and only v1 is greater than or equal to v2.

(> v1 v2) -> boolean?
  v1: number?
  v2: number?

Returns #t if and only v1 is strictly greater than v2.

(ignore v) -> void
  v: any

Suppresses the output of value v to the page.

(implies v1 v2) -> boolean?
  v1: boolean?
  v2: boolean?

Equivalent to (if v1 v2 #t).

(index-of l v) -> integer?
  l: list?
  v: any

Returns the index of the first occurrence of v in l or -1 if v is not in l.

(integer? v) -> boolean?
  v: any

Returns #t if and only v is an integer.

(integer->char n) -> char?
  n: integer?

Returns the character with codepoint value n.

(length v) -> integer?
  v: list?

Returns the length of v.

(<= v1 v2) -> boolean?
  v1: number?
  v2: number?

Returns #t if and only v1 is less than or equal to v2.

(list v1, v2, ...) -> list?
  v1, v2, ...: any

Returns a new list containing v1, v2, … .

(list-drop l k) -> list?
  l: list?
  k: integer?, 0 <= k <= (length l)

An alias for (list-tail l k).

(list-of p) -> procedure?
  p: procedure?, returns `#t` if its argument is of the desired type

Returns a new predicate that tests whether its argument is a list of elements that satisfy the predicate p.

(list? v) -> boolean?
  v: any

Returns #t if and only v is a list.

(list-ref l n) -> any
  l: list?
  n: integer?, 0 <= n < (length l)

Returns the nth element of l.

(list->string l) -> string?
  l: list?

Returns a string made by joining the characters in l together.

(list-tail l k) -> list?
  l: list?
  k: integer?, 0 <= k <= (length l)

Returns l but with the first k elements of l omitted.

(list-take l k) -> list?
  l: list?
  k: integer?, 0 <= k <= (length l)

Returns a new list containing the first k elements of l.

(list->vector l) -> vector?
  l: list?

Returns a vector consisting of the values in list l.

(log v) -> number?
  v: number?

Returns the natural logarithm of v.

(< v1 v2) -> boolean?
  v1: number?
  v2: number?

Returns #t if and only v1 is strictly less than v2.

(make-list n v) -> list?
  n: integer?
  v: any

Returns a new list containing n copies of v.

(make-string k c) -> string?
  k: integer?
  c: char?

Returns a string of length k with each character set to c.

(make-vector k v) -> vector?
  k: integer?
  v: any

Returns a vector of length k with each element set to v.

(map f l) -> list?
  f: procedure?
  l: list?

Returns a new list containing the results of applying f to each element of l.

(max v) -> number?
  v: number?

Returns the maximum of the given numbers.

(min v) -> number?
  v: number?

Returns the minimum of the given numbers.

(- v1, v2, ...) -> number?
  v1, v2, ...: number?

Returns the difference of v1, v2, … .

(modulo v1 v2) -> number?
  v1: number?
  v2: number?

Returns k = n - d * q where q is the integer such that k has the same sign as the divisor d while being as close to 0 as possible. (Source: MDN docs.)

(nan? v) -> boolean?
  v: any

Returns #t if and only v is the number NaN.

(nand v1, v2, ...) -> boolean?
  v1, v2, ...: boolean?

Equivalent to (not (and v1 v2 ...)).

(negative? v) -> boolean?
  v: any

Returns #t if and only v is negative.

(nor v1, v2, ...) -> boolean?
  v1, v2, ...: boolean?

Equivalent to (not (or v1 v2 ...)).

(not v) -> boolean?
  v: any

Returns #t if and only v is #f.

(null? v) -> boolean?
  v: any

Returns #t if and only v is the empty list.

null : list?

The empty list.

(number? v) -> boolean?
  v: any

Returns #t if and only v is a number.

(number->string v) -> string?
  v: number?

Returns the string representation of v.

(= v1 v2) -> boolean?
  v1: number?
  v2: number?

Returns #t if and only v1 is equal to v2.

(=-eps epsilon) -> function?
  epsilon: number?

Returns an equality function that tests two numbers to see if the absolute value of their difference is no greater than epsilon, i.e., (< (- x y) epsilon).

(o f) -> procedure?
  f: procedure?

A synonym for compose.

(odd? v) -> boolean?
  v: any

Returns #t if and only v is odd.

(pair v1 v2) -> pair?
  v1: any
  v2: any

Returns a new pair containing v1 and v2.

(pair? v) -> boolean?
  v: any

Returns #t if and only v is a pair.

pi : number

The constant π.

π : number

The constant π.

(|> v f1, ..., fk) -> any
  v: any
  f1, ..., fk: procedure?

Returns the result of applying the given function in sequence, starting with initial value v, i.e., (fk (fk-1(...(f1 v))).

(+ v1, v2, ...) -> number?
  v1, v2, ...: number?

Returns the sum of v1, v2, … .

(positive? v) -> boolean?
  v: any

Returns #t if and only v is positive.

(procedure? v) -> boolean?
  v: any

Returns #t if and only v is a procedure.

?? : any

A placeholder for an expression that is not yet implemented.

(quotient v1 v2) -> number?
  v1: integer?
  v2: integer?

Returns the quotient of v1 and v2, i.e., the whole number part of v1 / v2.

(random n) -> list?
  n: integer?, n >= 0

Returns a random number in the range 0 to n (exclusive).

(range beg end step) -> list?
  beg: integer?, this argument can be omitted
  end: integer?
  step: integer?, step > 0, this argument can be omitted

Returns a list containing the numbers from beg to end (exclusive). If beg is not given, it defaults to 0. If step is not given, it defaults to 1.

(real? v) -> boolean?
  v: any

Returns #t if and only v is a real number.

(reduce f l) -> any
  f: procedure?
  l: list?

Like fold but uses the first element of l as the initial value.

(reduce-right f l) -> any
  f: procedure?
  l: list?

Like fold-right but uses the last element of l as the initial value.

(remainder v1 v2) -> number?
  v1: integer?
  v2: integer?

Returns the remainder of v1 and v2, i.e., the remainder of v1 / v2.

(reverse l) -> list?
  l: list?

Returns a new list containing the elements of l in reverse order.

(round v) -> integer?
  v: number?

Returns the integer closest to v.

(set-maximum-recursion-depth! n) -> void
  n: number? n >= 0

Sets the maximum recursion depth of Scamper to n. Note that tail call-optimized functions do not count towards this limit.

(sin v) -> number?
  v: number?

Returns the sine of v.

(sort l lt?) -> list?
  l: list?
  lt?: procedure?, returns `#t` if the first arg is less than the second

Returns a new list containing the elements of l sorted in ascending order according to the comparison function lt?.

(sqrt v) -> number?
  v: number?

Returns the square root of v.

(square v) -> number?
  v: number?

Returns the square of v.

(string c1, c2, ...) -> string?
  c1, c2, ...: char?

Returns a string consisting of the characters c1, c2, …

(string-append s1, s2, ...) -> string?
  s1, s2, ...: string?

Returns a string made by joining s1, s2, … together.

(string-contains s1 s2) -> boolean?
  s1: string?
  s2: string?

Returns #t if and only if string s1 contains string s2.

(string-downcase s) -> string?
  s: string?

Returns the lower-case version of s.

(string=? s1, s2, ...) -> boolean?
  s1, s2, ...: string?

Returns #t if and only s1, s2, … are equivalent strings.

(string-ci=? s1, s2, ...) -> boolean?
  s1, s2, ...: string?

Returns #t if and only s1, s2, … are equivalent strings, ignoring case.

(string-foldcase s) -> string?
  s: string?

Returns the case-folded version of s. This is a version of s that is appropriate for case-insensitive comparison.

(string>=? s1, s2, ...) -> boolean?
  s1, s2, ...: string?

Returns #t if and only s1, s2, … are in reverse lexicographical order.

(string-ci>=? s1, s2, ...) -> boolean?
  s1, s2, ...: string?

Returns #t if and only s1, s2, … are in reverse lexicographical order, ignoring case.

(string>? s1, s2, ...) -> boolean?
  s1, s2, ...: string?

Returns #t if and only s1, s2, … are in strictly lexicographically decreasing order.

(string-ci>? s1, s2, ...) -> boolean?
  s1, s2, ...: string?

Returns #t if and only s1, s2, … are in strictly lexicographically decreasing order, ignoring case.

(string-length v) -> integer?
  v: string?

Returns the length of v.

(string<=? s1, s2, ...) -> boolean?
  s1, s2, ...: string?

Returns #t if and only s1, s2, … are in lexicographical order.

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

Returns #t if and only s1, s2, … are in lexicographical order, ignoring case.

(string->list s) -> list?
  s: string?

Returns a list of the characters in s.

(string<? s1, s2, ...) -> boolean?
  s1, s2, ...: string?

Returns #t if and only s1, s2, … are in strictly lexicographically increasing order.

(string-ci<? s1, s2, ...) -> boolean?
  s1, s2, ...: string?

Returns #t if and only s1, s2, … are in strictly lexicographically increasing order, ignoring case.

(string-map f s) -> string?
  f: procedure?
  s: string?

Returns a new string containing the results of applying f to each character of s.

(string->number s) -> number?
  s: string?, presumed to be a number

Returns the number denoted by s as a number.

(string? v) -> boolean?
  v: any

Returns #t if and only v is a string.

(string-ref s n) -> string?
  s: string?
  n: integer?

Returns the character at index n of string s.

(string-split s sep) -> list?
  s: string?
  sep: string?

Returns a list of strings obtained by splitting s at occurrences of sep.

(string-split-vector s sep) -> vector?
  s: string?
  sep: string?

Returns a vector of strings obtained by splitting s at occurrences of sep.

(string->words s) -> list?
  s: string?

Returns a list of the words in s, stripping whitespace and punctuation.

(string-upcase s) -> string?
  s: string?

Returns the upper-case version of s.

(string->vector s) -> vector?
  s: string?

Returns a vector of the characters in s.

(substring s start end) -> string?
  s: string?
  start: integer?
  end: integer?

Returns the substring of s from index start (inclusive) to index end (exclusive).

(tan v) -> number?
  v: number?

Returns the tangent of v.

(* v1, v2, ...) -> number?
  v1, v2, ...: number?

Returns the product of v1, v2, … .

(truncate v) -> integer?
  v: number?

Returns the integer closest to v less than or equal to v.

(vector v1, v2, ...) -> vector?
  v1, v2, ...: any

Returns a vector consisting of the values v1, v2, …

(vector-append v1, ..., vk) -> vector?
  v1, ..., vk: vector?

Returns a new vector containing the elements of v1, …, vk in order.

(vector-fill! v x) -> void
  v: vector?
  x: any

Sets each element of vector v to x.

(vector-filter f l) -> list?
  f: procedure?
  l: vector?

Returns a new vector containing the elements of l for which f returns #t.

(vector-for-each f v) -> void
  f: procedure?
  v: vector?

Runs f on each element of v1, …, vk in a element-wise fashion. f takes k+1 arguments where the first argument is the current index and the remaining arguments are the elements of each vector at that index.

(vector-length v) -> integer?
  v: vector?

Returns the length of vector v.

(vector->list v) -> list?
  v: vector?

Returns a list consisting of the values in vector v.

(vector-map f v) -> vector?
  f: procedure?
  v: vector?

Returns a new vector containing the results of applying f to each element of v1, …, vk in a element-wise fashion.

(vector-map! f v) -> void
  f: procedure?
  v: vector?

Mutates v1 with the results of results of applying f to each element of v1, …, vk in a element-wise fashion.

(vector? v) -> boolean?
  v: any

Returns #t if and only v is a vector.

(vector-range beg end step) -> vector?
  beg: integer?, this argument can be omitted
  end: integer?
  step: integer?, step > 0, this argument can be omitted

Returns a vector containing the numbers from beg to end (exclusive). If beg is not given, it defaults to 0. If step is not given, it defaults to 1.

(vector-ref v n) -> any
  v: vector?
  n: integer?, a valid index into v

Returns the value at index n of vector v.

(vector-set! v n x) -> void
  v: vector?
  n: integer?, a valid index into v
  x: any

Sets the value at index n of vector v to x.

(vector->string v) -> string?
  v: vector?

Returns a string made by joining the characters in v together.

(void? v) -> boolean?
  v: any

Returns #t if and only if v is the void value.

void : void

The void value.

(with-file filename fn) -> void
  filename: string?
  fn: procedure?

Loads filename from browser storage and passes its contents to fn as input. The output of fn is then rendered to the screen.

(with-file-chooser fn) -> void
  fn: procedure?

Renders a file chooser widget. When the user selects a file, its contents are passed to fn as input. The output of fn is then rendered to the screen.

(with-handler h f v) -> any
  h: procedure?, a handler
  f: procedure?, a function
  v: any

Calls (f v1 .. vk) and if an error is occurred, calls (h err) where err is the string associated with the raised error.

(xor v1 v2) -> boolean?
  v1: boolean?
  v2: boolean?

Equivalent to (or (and v1 (not v2)) (and (not v1) v2)).

(zero? v) -> boolean?
  v: any

Returns #t if and only v is zero.