LfrlAnvil.Computable.Expressions 0.6.1

dotnet add package LfrlAnvil.Computable.Expressions --version 0.6.1
                    
NuGet\Install-Package LfrlAnvil.Computable.Expressions -Version 0.6.1
                    
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.Expressions" Version="0.6.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LfrlAnvil.Computable.Expressions" Version="0.6.1" />
                    
Directory.Packages.props
<PackageReference Include="LfrlAnvil.Computable.Expressions" />
                    
Project file
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.Expressions --version 0.6.1
                    
#r "nuget: LfrlAnvil.Computable.Expressions, 0.6.1"
                    
#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.Expressions@0.6.1
                    
#: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.Expressions&version=0.6.1
                    
Install as a Cake Addin
#tool nuget:?package=LfrlAnvil.Computable.Expressions&version=0.6.1
                    
Install as a Cake Tool

(root) NuGet Badge

<img src="https://raw.githubusercontent.com/CalionVarduk/LfrlAnvil/main/assets/logo-small.png" alt="logo" height="80"/> LfrlAnvil.Computable.Expressions

This project contains a parser of string expressions that can be compiled to invocable delegates.

Documentation

Technical documentation can be found here.

Examples

Following contains an example of a parser configuration, as well as creation, compilation and invocation of a delegate:

// creates a builder of a minimal parser capable of supporting most arithmetic and logical operators
// and branching functions, like 'if' and 'switch'
// in addition, it will try to parse all constant numbers as 32-bit signed integers
// instead of the default decimal type
var builder = new ParsedExpressionFactoryBuilder()
    .AddGenericArithmeticOperators()
    .AddGenericBitwiseOperators()
    .AddGenericLogicalOperators()
    .AddBooleanLogicalOperators()
    .AddStringArithmeticOperators()
    .AddBranchingVariadicFunctions()
    .SetNumberParserProvider( p => ParsedExpressionNumberParser.CreateDefaultInt32( p.Configuration ) );

// builds an expression parser
var parser = builder.Build();

// string expression to parse, that contains two external arguments: 'a' and 'b'
var input =
    """
    let x = (a + 1).ToString();
    let y = if(x.Length > 1, b * 2, b * 4).ToString();
    y + x + y;
    """;

// creates a parsed expression from the given string input
var expression = parser.Create<int, string>( input );

// compiles the expression to an invocable delegate
var func = expression.Compile();

// invokes the delegate with 'a' = 42 and 'b' = 31,
// which should return '624362'
var result = func.Invoke( 42, 31 );
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on LfrlAnvil.Computable.Expressions:

Package Downloads
LfrlAnvil.MessageBroker.Server

This project contains server-side message broker implementation.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.6.1 117 5/18/2026
0.6.0 120 5/16/2026
0.5.1 121 5/18/2026
0.5.0 126 5/16/2026
0.4.0 134 3/14/2026
0.3.0 235 1/7/2025
0.2.1 230 6/16/2024
0.2.0 193 6/16/2024
0.1.1 206 5/29/2024
0.1.0 210 5/26/2024