Skip to content

Latest commit

 

History

History
479 lines (259 loc) · 15.3 KB

scml_base_list.md

File metadata and controls

479 lines (259 loc) · 15.3 KB

Module scml_base_list

Scheme base library for pairs and lists

. __Authors:__ Joseph Wayne Norton ([`norton@alum.mit.edu`](mailto:norton@alum.mit.edu)).

Function Index

'$scml_exports'/0
'list-copy'/1Equivalent to list(obj).
'list-ref'/2

Returns the kth element of list. It is an error if list has fewer than k elements.

.
'list-set!'/3

unsupported

.
'list-tail'/2

Returns the sublist of list obtained by omitting the first k elements. It is an error if list has fewer than k elements.

.
'list?'/1

Returns #t if obj is a (proper) list, otherwise returns #f.

.
'make-list'/1Equivalent to 'make-list'(K, '#f').
'make-list'/2

Returns a list of k elements.

.
'null?'/1

Returns #t if obj is the empty list, otherwise returns #f.

.
'pair?'/1

Returns #t if obj is a pair, and otherwise returns #f.

.
'set-car!'/2

unsupported

.
'set-cdr!'/2

unsupported

.
append/1

Returns a list consisting of the elements of the first list followed by the elements of the other lists. If there are no arguments, the empty list is returned. If there is exactly one argument, it is returned. An improper list results if the last argument is not a proper list. The last argument, if there is one, can be of any type.

.
assoc/5Equivalent to assoc(Obj, List, 'equal?').
assoc/6

Return the first pair of alist whose car field is obj. If no pair in alist has obj as its car, then #f is returned.

.
assq/5Equivalent to assq(Obj, List, 'eq?').
assv/5Equivalent to assv(Obj, List, 'eqv?').
caar/1

Returns the composition of car.

.
cadr/1

Returns the composition of car and cdr.

.
car/1

Returns the contents of the car field of pair. Note that it is an error to take the car of the empty list.

.
cdar/1

Returns the composition of cdr and car.

.
cddr/1

Returns the composition of cdr and cdr.

.
cdr/1

Returns the contents of the cdr field of pair. Note that it is an error to take the car of the empty list.

.
cons/2

Returns a pair whose car is obj1 and whose cdr is obj2. The pair constructed by cons is not guaranteed to be different (in the sense of eqv?) from every existing object.

.
length/1

Returns the length of list.

.
list/1

Returns a list of the arguments.

.
member/5Equivalent to memq(Obj, List, 'equal?').
member/6

Return the first sublist of list whose car is obj where the sublists of list are the non-empty lists returned by (list-tail list k) for k less than the length of list. If obj does not occur in the list, the #f is returned.

.
memq/5Equivalent to memq(Obj, List, 'eq?').
memv/5Equivalent to memq(Obj, List, 'eqv?').
reverse/1

Returns a list consisting of the elements of list in reverse order.

.

Function Details

'$scml_exports'/0


'$scml_exports'() -> [{scm_symbol(), scmi_nip()}]



'list-copy'/1


'list-copy'(Obj::scm_obj()) -> scm_obj()



Equivalent to list(obj).

'list-ref'/2


'list-ref'(List::scm_list(), K::scm_k()) -> scm_obj()



Returns the kth element of list. It is an error if list has fewer than k elements.

'list-set!'/3


'list-set!'(List::scm_list(), K::scm_k(), Obj::scm_obj()) -> scm_false()



unsupported

'list-tail'/2


'list-tail'(List::scm_list(), K::scm_k()) -> scm_list()



Returns the sublist of list obtained by omitting the first k elements. It is an error if list has fewer than k elements.

'list?'/1


'list?'(T::scm_obj()) -> scm_boolean()



Returns #t if obj is a (proper) list, otherwise returns #f.

'make-list'/1


'make-list'(K::scm_k()) -> scm_list()



Equivalent to 'make-list'(K, '#f').

'make-list'/2


'make-list'(K::scm_k(), Fill::scm_obj()) -> scm_list()



Returns a list of k elements.

'null?'/1


'null?'(X1::scm_obj()) -> scm_boolean()



Returns #t if obj is the empty list, otherwise returns #f.

'pair?'/1


'pair?'(X1::scm_obj()) -> scm_boolean()



Returns #t if obj is a pair, and otherwise returns #f.

'set-car!'/2


'set-car!'(Pair::scm_pair(), Obj::scm_obj()) -> scm_false()



unsupported

'set-cdr!'/2


'set-cdr!'(Pair::scm_pair(), Obj::scm_obj()) -> scm_false()



unsupported

append/1


append(Lists::scmi_vargs()) -> scm_list()



Returns a list consisting of the elements of the first list followed by the elements of the other lists. If there are no arguments, the empty list is returned. If there is exactly one argument, it is returned. An improper list results if the last argument is not a proper list. The last argument, if there is one, can be of any type.

assoc/5


assoc(Obj::scm_obj(), Alist::scm_alist(), Env::scmi_denv(), Ok::scmi_dok(), Ng::scmi_dng()) -> scm_pair() | scm_false()



Equivalent to assoc(Obj, List, 'equal?').

assoc/6


assoc(Obj::scm_obj(), T::scm_alist(), Compare::scm_proc(), Env::scmi_denv(), Ok::scmi_dok(), Ng::scmi_dng()) -> scm_pair() | scm_false()



Return the first pair of alist whose car field is obj. If no pair in alist has obj as its car, then #f is returned.

assq/5


assq(Obj::scm_obj(), Alist::scm_alist(), Env::scmi_denv(), Ok::scmi_dok(), Ng::scmi_dng()) -> scm_pair() | scm_false()



Equivalent to assq(Obj, List, 'eq?').

assv/5


assv(Obj::scm_obj(), Alist::scm_alist(), Env::scmi_denv(), Ok::scmi_dok(), Ng::scmi_dng()) -> scm_pair() | scm_false()



Equivalent to assv(Obj, List, 'eqv?').

caar/1


caar(Pair::scm_pair()) -> scm_obj()



Returns the composition of car.

cadr/1


cadr(Pair::scm_pair()) -> scm_obj()



Returns the composition of car and cdr.

car/1


car(X1::scm_pair()) -> scm_obj()



Returns the contents of the car field of pair. Note that it is an error to take the car of the empty list.

cdar/1


cdar(Pair::scm_pair()) -> scm_obj()



Returns the composition of cdr and car.

cddr/1


cddr(Pair::scm_pair()) -> scm_obj()



Returns the composition of cdr and cdr.

cdr/1


cdr(T::scm_pair()) -> scm_obj()



Returns the contents of the cdr field of pair. Note that it is an error to take the car of the empty list.

cons/2


cons(Obj1::scm_obj(), Obj2::scm_obj()) -> scm_pair()



Returns a pair whose car is obj1 and whose cdr is obj2. The pair constructed by cons is not guaranteed to be different (in the sense of eqv?) from every existing object.

length/1


length(List::scm_list()) -> scm_k()



Returns the length of list.

list/1


list(List::scm_list()) -> scm_list()



Returns a list of the arguments.

member/5


member(Obj::scm_obj(), List::scm_list(), Env::scmi_denv(), Ok::scmi_dok(), Ng::scmi_dng()) -> scm_list() | scm_false()



Equivalent to memq(Obj, List, 'equal?').

member/6


member(Obj::scm_obj(), T::scm_list(), Compare::scm_proc(), Env::scmi_denv(), Ok::scmi_dok(), Ng::scmi_dng()) -> scm_list() | scm_false()



Return the first sublist of list whose car is obj where the sublists of list are the non-empty lists returned by (list-tail list k) for k less than the length of list. If obj does not occur in the list, the #f is returned.

memq/5



Equivalent to memq(Obj, List, 'eq?').

memv/5



Equivalent to memq(Obj, List, 'eqv?').

reverse/1


reverse(List::scm_list()) -> scm_list()



Returns a list consisting of the elements of list in reverse order.