Lists Flashcards

1
Q

Data Structure

A
  • a combination of multiple values.
  • allows us to organize, process, retrieve and store data (values)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Linked List

A
  • a data structure that stores a sequence of elements
  • each element is called a node
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Node

A
  • an element in a list
  • has a value
  • has a reference to the next node in the list
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

list

A

Takes 0 or more arguments and returns a list containing those arguments as elements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

build-list

A

(build-list n func)
n = number of nodes starting from 0
func = a function applied to each node

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

null? empty?

A
  • boolean
  • shows if a list is empty
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

cons

A
  • add an element to the front of a list
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

append

A
  • combines lists
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

member

A

checks if a member is part of a list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

length

A

Returns the length of a list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Filter

A

(filter function list)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

foldr foldl

A
  • fold right/left
  • reduces a list to a single value
    (foldl func start-value g)
    func = function
    start-value = number you start with
    g = a list
17
Q

map

A
  • A function used to apply a given function to each element of one or more lists, producing a new one
    (map f lst)
    f = function to apply
    lst = list or lists