LfrlAnvil.Computable.Automata
0.1.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package LfrlAnvil.Computable.Automata --version 0.1.0
NuGet\Install-Package LfrlAnvil.Computable.Automata -Version 0.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LfrlAnvil.Computable.Automata" Version="0.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LfrlAnvil.Computable.Automata" Version="0.1.0" />
<PackageReference Include="LfrlAnvil.Computable.Automata" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LfrlAnvil.Computable.Automata --version 0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: LfrlAnvil.Computable.Automata, 0.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LfrlAnvil.Computable.Automata@0.1.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LfrlAnvil.Computable.Automata&version=0.1.0
#tool nuget:?package=LfrlAnvil.Computable.Automata&version=0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
(root)
LfrlAnvil.Computable.Automata
This project contains structures and algorithms related to the automata theory.
Examples
Following is an example of a deterministic finite state machine (FSM):
public enum TurnstileState
{
Locked = 0,
Unlocked = 1
}
public enum TurnstileInput
{
Coin = 0,
Push = 1
}
public enum TurnstileOutput
{
Unchanged = 0,
Locked = 1,
Unlocked = 2
}
// creates a new state machine builder that will represent a turnstile state machine
var builder = new StateMachineBuilder<TurnstileState, TurnstileInput, TurnstileOutput>( TurnstileOutput.Unchanged );
// registers a 'Locked' => 'Locked' transition with 'Push' input, that returns the default 'Unchanged' output
builder.AddTransition(
source: TurnstileState.Locked,
destination: TurnstileState.Locked,
input: TurnstileInput.Push );
// registers a 'Locked' => 'Unlocked' transition with 'Coin' input that returns the 'Unlocked' output
builder.AddTransition(
source: TurnstileState.Locked,
destination: TurnstileState.Unlocked,
input: TurnstileInput.Coin,
handler: StateTransitionHandler.Create<TurnstileState, TurnstileInput, TurnstileOutput>( _ => TurnstileOutput.Unlocked ) );
// registers an 'Unlocked' => 'Unlocked' transition with 'Coin' input, that returns the default 'Unchanged' output
builder.AddTransition(
source: TurnstileState.Unlocked,
destination: TurnstileState.Unlocked,
input: TurnstileInput.Coin );
// registers an 'Unlocked' => 'Locked' transition with 'Coin' input that returns the 'Locked' output
builder.AddTransition(
source: TurnstileState.Unlocked,
destination: TurnstileState.Locked,
input: TurnstileInput.Push,
handler: StateTransitionHandler.Create<TurnstileState, TurnstileInput, TurnstileOutput>( _ => TurnstileOutput.Locked ) );
// marks the 'Locked' state as initial
builder.MarkAsInitial( TurnstileState.Locked );
// builds the state machine
var machine = builder.Build();
// creates a traversable instance of the state machine that starts at the initial 'Locked' state
var instance = machine.CreateInstance();
// applies 'Push' input to the current 'Locked' state,
// which does not change the state and returns 'Unchanged' output
var result = instance.Transition( TurnstileInput.Push );
// applies 'Coin' input to the current 'Locked' state,
// which changes the state to 'Unlocked' and returns 'Unlocked' output
result = instance.Transition( TurnstileInput.Coin );
// applies 'Coin' input to the current 'Unlocked' state,
// which does not change the state and returns 'Unchanged' output
result = instance.Transition( TurnstileInput.Coin );
// applies 'Push' input to the current 'Unlocked' state,
// which changes the state to 'Locked' and returns 'Locked' output
result = instance.Transition( TurnstileInput.Push );
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net7.0
- LfrlAnvil.Core (>= 0.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.