LISTS - nus-cs4215/x-slang-t1-xz-jj GitHub Wiki

The functions in LISTS provide useful functions for list processing, as introduced on section 2.2 Hierarchical Data and the Closure Property of the textbook Structure and Interpretation of Computer Programs, JavaScript Adaptation (SICP JS). We provide an adaptation of the functions in Python.

List of predeclared names

accumulate

append

build_list

draw_data

enum_list

equal

filter

for_each

head

is_list

is_null

is_pair

length

list

list_ref

list_to_string

map

member

pair

remove

remove_all

reverse

tail

Predeclared Names

accumulate


Not implemented.

append


append(xs,ys)

Parameters

xs : list : list of values

ys : list : another list of values

Append ys to the tail of xs.

Returns

list

build_list


Not implemented.

draw_data


Not implemented.

enum_list


Not implemented.

equal


Not implemented.

filter


Not implemented.

for_each


Not implemented.

head


head(xs)

Parameters

xs : list, pair : list or pair to extract the head value from.

Returns value of head element from list or pair

Returns

value: any

is_list


is_list(xs)

Parameters

v : any : value to be checked

checks if a given value is a list. Returns True or False

Returns

bool

is_null


Not applicable

is_pair


is_pair(v)

Parameters

xv : any : value to be checked

checks if a given value is a pair. Returns True or False

Returns

bool

length


length(xs)

Parameters

xs : list : the list whose length is to be determined

Returns length of list.

Returns

int

list


list(elements...)

Parameters

elements... : any : variadic elements to be included in the list

Create a linked list out of element values.

Returns

list

list_ref


Not implemented.

list_to_string


Not implemented.

map


Not implemented.

member


Not implemented.

pair


pair(x,y)

Parameters

x : any : value 1 of the pair

y : any : value 2 of the pair

x and y can also be lists

Returns

pair

remove


Not implemented.

remove_all


Not implemented.

reverse


Not implemented.

tail


tail(xs)

Parameters

xs : list, pair : list or pair for which its tail value is to be extracted

Extracts the tail value of a list or pair.

Returns

value, list, pair