Quantum::Superpositions::Lazy::State - a weighted state implementation
This is a simple implementation of a state that contains a weight and a value. The states are meant to be immutable, so once created you cannot change the value or weight of a state (without cloning it).
my $state = Quantum::Superpositions::Lazy::State->new( weight => 2, value => "on" );
A generic Moose constructor. Accepts two arguments: weight of numeric type (positive), which is optional and 1 by default, and value of any type (defined), which is required.
Returns the weight.
Returns the value.
Resets the state of a superposition inside of the value attribute, if that value is indeed a superposition.
Creates a new state with the parameters of the current one.
# doubles the weight on the cloned state $state->clone_with(weight => sub { shift() * 2 });
Clones the objects with clone and then applies some transformators on top of the object fields.
Merges two states into one. Only possible for values that are the same (compared as strings with eq). The weights are added together on the resulting state.
Quantum::Superpositions::Lazy::ComputedState
To install Quantum::Superpositions::Lazy, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Quantum::Superpositions::Lazy
CPAN shell
perl -MCPAN -e shell install Quantum::Superpositions::Lazy
For more information on module installation, please visit the detailed CPAN module installation guide.