NFun 1.1.2
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 NFun --version 1.1.2
NuGet\Install-Package NFun -Version 1.1.2
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="NFun" Version="1.1.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NFun" Version="1.1.2" />
<PackageReference Include="NFun" />
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 NFun --version 1.1.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: NFun, 1.1.2"
#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 NFun@1.1.2
#: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=NFun&version=1.1.2
#tool nuget:?package=NFun&version=1.1.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
NFun — Expression Evaluator for .NET
Embeddable expression language with rich type system, absolute type inference, and LINQ-like collections.
PM> Install-Package NFun
Quick Start
// Simple evaluation
double d = Funny.Calc<double>("2 * 10 + 1"); // 21
bool b = Funny.Calc<bool>("false and (2 > 1)"); // false
// With input model
string alias = Funny.Calc<User, string>(
"if(age < 18) name else 'Mr. {name}'", user);
// Multiple inputs and outputs
var person = new Person(birthYear: 2000);
Funny.CalcContext(@"
age = 2022 - birthYear
cars = [
{ name = 'lada', cost = 1200, power = 102 },
{ name = 'camaro', cost = 5000, power = 275 }
]", person);
// Low-level API
var runtime = Funny.Hardcore.Build("y = 2x + 1");
runtime["x"].Value = 42;
runtime.Run();
var result = runtime["y"].Value; // 85
Key Features
Operators & Arithmetic
y1 = 2*(x//2 + 1) / (x % 3 - 1)**0.5 + 3x # arithmetic, implicit multiplication
y2 = (x | y & 0xF0FF << 2) ^ 0x1234 # bitwise
y3 = x and false or not (y > 0) # logical
If-expressions
y = if(age > 18)
if(weight > 100) 'heavy'
if(weight > 50) 'normal'
else 'light'
if(age > 16) 'teen'
else 'child'
Collections & Higher-Order Functions
out = [1,2,3,4,5]
.filter(rule it > 2)
.map(rule it * 10)
.reverse() # [50, 40, 30]
Structs & Named Types
type point = {x: int, y: int}
p: point = {x = 3, y = 4}
dist = (p.x**2 + p.y**2)**0.5
Optional Types & Type Narrowing
user:{name: text, age: int}? = none
greeting = if(user == none) 'Guest'
if(user.age > 18) 'Hello, {user.name}'
else 'Hi, {user.name}'
Strict Type System with Full Inference
y = 2x # x and y inferred as Int32
z:int = y * x # explicit annotation
m:real[] = [1,2,3].map(rule it/2) # [0.5, 1.0, 1.5]
Dialect Customization
var runtime = Funny.Hardcore
.WithDialect(
integerPreferredType: IntegerPreferredType.I64,
integerOverflow: IntegerOverflow.Unchecked,
optionalTypesSupport: OptionalTypesSupport.Enabled,
namedTypesSupport: NamedTypesSupport.Enabled)
.Build("y = 2x + 1");
Documentation
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. 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 is compatible. 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.
-
net5.0
- IndexRange (>= 1.0.2)
- System.Memory (>= 4.5.5)
-
net6.0
- IndexRange (>= 1.0.2)
- System.Memory (>= 4.5.5)
-
net8.0
- IndexRange (>= 1.0.2)
- System.Memory (>= 4.5.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 1.2.2 | 1,421 | 7/11/2026 | |
| 1.2.1 | 148 | 7/9/2026 | |
| 1.2.0 | 252 | 7/4/2026 | |
| 1.1.3 | 671 | 6/1/2026 | |
| 1.1.2 | 115 | 5/30/2026 | |
| 1.1.1 | 668 | 5/17/2026 | |
| 1.1.0 | 6,410 | 5/1/2026 | |
| 1.0.3 | 9,156 | 7/26/2025 | |
| 1.0.2 | 446 | 7/26/2025 | |
| 1.0.1 | 54,081 | 7/17/2023 | |
| 1.0.0 | 2,558 | 12/1/2022 | |
| 0.9.9 | 822 | 7/6/2022 | |
| 0.9.8 | 773 | 5/29/2022 | |
| 0.9.7 | 857 | 4/2/2022 | |
| 0.9.6 | 801 | 4/2/2022 | |
| 0.9.5 | 851 | 1/15/2022 | |
| 0.9.4 | 684 | 12/26/2021 |
Loading failed
v1.1.2: minor bug fixes.