Module dalpy.factory_utils

This module provides factory functions for creating and modifying DALPy objects.

The functions contained in this module are meant to be used when writing test cases for problems implemented in DALPy.

Functions

def copy_stack(s)

Creates a copy of a Stack.

Args

s
The Stack to copy.
def make_array(ls)

Makes an Array from a list of elements.

Args

ls
The list of elements to insert into a new Array.
def make_queue(ls)

Creates a Queue from a list of elements, enqueueing from left to right.

Args

ls
A list of elements to be enqueued into the Queue.
def make_stack(ls)

Creates a Stack from a list of elements, pushing from left to right.

Args

ls
A list of elements to be enqueued into the Stack.
def nary_add_children(root, children)

Adds NaryTreeNodes to be the children of another NaryTreeNode.

Args

root
an NaryTreeNode to which we will be adding children. This will be modified in place by this function.
children
a list of NaryTreeNodes that are the children to be added. These nodes will be added as the children of root in the order they occur in this list. children[0] will be the leftmost child of root, children[1] will be the right sibling of children[0] and so on.