LogicGrowsOnTrees-1.1.0.2: a parallel implementation of logic programming using distributed tree exploration

Safe HaskellNone

LogicGrowsOnTrees.Utils.PerfectTree

Contents

Description

This modules contains utility functions for constructing perfect trees for use in some of the tests and examples.

Synopsis

Tree generators

perfectTreeSource

Arguments

:: MonadPlus m 
=> α

the value to place at the leaves

-> Word

the arity of the tree (i.e., number of branches at each internal node)

-> Word

the depth of the tree

-> m α 

Generate a perfectly balanced tree with the given leaf value, arity, and leaf.

trivialPerfectTreeSource

Arguments

:: MonadPlus m 
=> Word

the arity of the tree (i.e., number of branches at each internal node)

-> Word

the depth of the tree

-> m WordSum 

Like perfectTree but with WordSum 1 at the leaves.

numberOfLeavesSource

Arguments

:: Word

the arity of the tree (i.e., number of branches at each internal node)

-> Word

the depth of the tree

-> Word 

Computes the number of leaves in a perfect tree. It returns a value of type Word so that it can be easily compared to the WordSum value returned by the tree generators, but a consequence of this is that it will overflow if the arity and/or depth arguments are too large.

Arity and depth parameters

newtype Arity Source

Newtype wrapper for arities that has an ArgVal instance that enforces that the arity be at least 2.

Constructors

Arity 

Fields

getArity :: Word
 

data ArityAndDepth Source

Datatype representing the arity and depth of a tree, used for command line argument processing (see makeArityAndDepthTermAtPositions).

Constructors

ArityAndDepth 

Fields

arity :: !Word
 
depth :: !Word
 

makeArityAndDepthTermAtPositionsSource

Arguments

:: Int

the position of the arity parameter in the command line

-> Int

the position of the depth parameter in the command line

-> Term ArityAndDepth 

Constructs a configuration term that expects the arity and depth to be at the given command line argument positions.

formArityAndDepth :: Arity -> Word -> ArityAndDepthSource

A convenience function used when you have an value of type Arity for the arity of the tree rather than a value of type Word and want to construct a value of type ArityAndDepth.