Lists Flashcards
1
Q
Data Structure
A
- a combination of multiple values.
- allows us to organize, process, retrieve and store data (values)
2
Q
Linked List
A
- a data structure that stores a sequence of elements
- each element is called a node
3
Q
Node
A
- an element in a list
- has a value
- has a reference to the next node in the list
4
Q
list
A
Takes 0 or more arguments and returns a list containing those arguments as elements.
5
Q
build-list
A
(build-list n func)
n = number of nodes starting from 0
func = a function applied to each node
6
Q
null? empty?
A
- boolean
- shows if a list is empty
7
Q
first
A
- Takes a list as an argument and returns the value stored in the first node of that list.
- returns an error if used on an empty list
8
Q
rest
A
- Takes a list as an argument and returns the node that the first element of the list is linked to
- results in an error if you try to use it on an empty list
9
Q
car
A
- Takes a list as an argument and returns the value stored in the first node of that list.
- returns an error if used on an empty list
10
Q
cdr
A
- Takes a list as an argument and returns the node that the first element of the list is linked to
- results in an error if you try to use it on an empty list
11
Q
cons
A
- add an element to the front of a list
12
Q
append
A
- combines lists
13
Q
member
A
checks if a member is part of a list
14
Q
length
A
Returns the length of a list
15
Q
Filter
A
(filter function list)