Skip to content
bobappleyard edited this page Sep 13, 2010 · 11 revisions

When a new interpreter is created, a default set of bindings are available. These comprise the standard library.

Most of the standard library concerns itself with the manipulation of objects of particular types.

Atomic Types

(atom? x)

An atom is any object that is not a sequence, that is does not group together other objects in an ordered fashion.

Booleans

(boolean? x)
(object->boolean x)
(not x)

Numbers

(number? x)
(fixnum? x)
(flonum? x)
(zero? x)
(even? x)
(odd? x)

The fixnum type in Golisp corresponds to the Go type int, likewise flonum to float.

(+ x y)
(- x y)
(* x y)
(/ x y)

Standard arithmetic functions. If both arguments are fixnums, they will return fixnums, except in the case of /, which will return a fixnum if there is no remainder to the division.

(quotient x y)
(remainder x y)
(modulo x m)

Perform integer division on fixnums. Given x/y = q + r, quotient returns q and remainder returns r. modulo returns x (mod m).

Strings

Ports

Sequences

Lists

(pair? x)
(list? x)
(proper-list? x)
(improper-list? x)
(null? x)

A proper list is composed of pairs terminated by the empty list, while an improper list is terminated by a pair. When a list is referred to, it is generally as a synonym for a proper list. The function null? tests if an object is the empty list.

(cons a d)
(car x)
(cdr x)

A pair is, as it sounds, two objects joined together. For historical reasons, the first of these objects is referred to as the car, while the second is known as the cdr.

Vectors

Clone this wiki locally