Listwiz API Reference
Listwiz
This is a module with toy list manipulation and inspection functions for a EuroSciPy tutorial.
There are three submodules containing our functionality:
Listwiz inspect
This module contains some functions inspecting a list.
- listwiz.inspect.largest_element(l)
Find the largest element and its index
- Parameters:
- llist
The list to find the largest element in.
- Returns:
- value, index
A tuple of the largest value and its index.
Listwiz sorting
This submodule contains implementations for different sorting methods.
- listwiz.sorting.merge_sort(l)
Use the merge sort algorithm to sort the list elements.
- Parameters:
- llist
The list to sort
- Returns:
- sorted_list
Listwiz replace
This module contains functions to replace some elements of a list.
- listwiz.replace.replace_sublist(l, sublist, replacement)
Naive function to replace a sublist with a replacement list.
- Parameters:
- llist
List to replace all occurances of sublist.
- sublistlist
A (shorter) list to search for.
- replacementlist
A new list to insert instead of sublist.
Examples
>>> from listwiz.replace import replace_sublist
Replace any occurance of
[2, 3]with[3, 2]>>> replace_sublist([1, 2, 3, 4], [2, 3], [3, 2]) [1, 3, 2, 4]