s-expression module

s-expression module provides the following functions, which are related to S-expressions.

S ( ... )

S() creates a list.

S(1, 2, 3, 4, 5)
   ==> (1 2 3 4 5)
cons ( obj1 , obj2 )

cons() constructs a list from two objects.

cons(1, 2)
        ==> (1 . 2)

cons(1, S(2, 3))
        ==> (1 2 3)
car ( cell )
cdr ( cell )

car() returns the first element of the cell. cdr() returns the rest of the elements of the cell.

car(S(1,2,3))
        ==> 1
cdr(S(1,2,3))
        ==> (2 3)
setcar ( cell , value )
setcdr ( cell , value )

setcar() changes the first element of cell. setcdr() changes the rest of the elements of cell.

s = S(1,2,3)
setcar(s, 10)
        ==> (10 2 3)
setcdr(s, S(20, 30))
        ==> (10 20 30)