PPA Tools PPA Tools: Lists

Summary

This module contains actions used to process lists.

Actions

ppa_tools.lists.

append

Append an item to a list.

Minimum Plugin Version: 3.1.0

Input
  • items: the list to append the new value to

  • value: the value to append to items

Output

The updated list.

Example

Appending an integer to a list.

1
2
3
4
5
6
- ppa_tools.lists.append:
    items:
      - 1
      - 2
    value: 3
  save: numbers

The numbers variable will be:

1
2
3
- 1
- 2
- 3

ppa_tools.lists.

combine

Combine two lists into one.

Minimum Plugin Version: 3.5.0

Input
  • first: the first list

  • second: the second list

Output

A new list containing first & second.

Example

Combining two lists of numbers:

1
2
3
4
5
6
7
8
- ppa_tools.lists.combine:
    first:
      - 1
      - 2
    second:
      - 3
      - 4
  save: new_list

In this example the new_list variable will be:

1
2
3
4
- 1
- 2
- 3
- 4

ppa_tools.lists.

common

Compare two lists and get all items present in both.

Minimum Plugin Version: 3.5.0

Input
  • first: the first list

  • second: the second list

Output

A new list containing all items present in both first and second.

Example

Getting the common items from two lists of numbers:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
- ppa_tools.lists.common:
    first:
      - 1
      - 2
      - 3
      - 4
      - 5
    second:
      - 3
      - 4
      - 5
      - 6
      - 7
  save: new_list

In this example the new_list variable will be:

1
2
3
- 3
- 4
- 5

ppa_tools.lists.

difference

Compare two lists and get all items only present in the first.

Minimum Plugin Version: 3.5.0

Input
  • first: the first list

  • second: the second list

Output

A new list containing all items from first that are not present in second.

Example

Getting the difference between two lists of numbers:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
- ppa_tools.lists.difference:
    first:
      - 1
      - 2
      - 3
    second:
      - 3
      - 4
      - 5
  save: new_list

In this example the new_list variable will be:

1
2
- 1
- 2

ppa_tools.lists.

get_first_item

Get the first item from a list.

Minimum Plugin Version: 3.0.0

Input
  • items: a list of values
Output

The value at position 0 in the items list.

Example

Getting the first item from a list of cities.

1
2
3
4
5
6
7
8
- ppa_tools.lists.get_first_item:
    items:
      - Paris
      - London
      - Cardiff
      - Berlin
      - Brussels
  save: first_city

The first_city variable will be a string containing "Paris".

ppa_tools.lists.

get_item

Get an item from a list using an index.

Minimum Plugin Version: 3.0.0

List Indexing

Values from a list are accessed using their position in the list (index).

PPA lists are zero-indexed, meaning the first item is always at position 0.

Input
  • items: a list of values

  • index: the index of the item to get

Output

The value at position index in the items list.

Example

Getting the first item from a list of cities.

1
2
3
4
5
6
7
8
9
- ppa_tools.lists.get_item:
    items:
      - Paris
      - London
      - Cardiff
      - Berlin
      - Brussels
    index: 0
  save: selected_city

The selected_city variable will be a string containing "Paris".

ppa_tools.lists.

get_items

Get items from a list using a list of indices.

Minimum Plugin Version: 3.0.0

List Indexing

Values from a list are accessed using their position in the list (index).

PPA lists are zero-indexed, meaning the first item is always at position 0.

Input
  • items: a list of values

  • indices: a list of indices for the items to get

Output

A list of items taken from items at the positions supplied in indices.

Example

Getting indices 1 & 3 from a list of cities.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
- ppa_tools.lists.get_items:
    items:
      - Paris
      - London
      - Cardiff
      - Berlin
      - Brussels
    indices:
      - 1
      - 3
  save: selected_cities

The selected_cities variable will be a list containing:

- London
- Berlin