NFun 1.1.3
dotnet add package NFun --version 1.1.3
NuGet\Install-Package NFun -Version 1.1.3
<PackageReference Include="NFun" Version="1.1.3" />
<PackageVersion Include="NFun" Version="1.1.3" />
<PackageReference Include="NFun" />
paket add NFun --version 1.1.3
#r "nuget: NFun, 1.1.3"
#:package NFun@1.1.3
#addin nuget:?package=NFun&version=1.1.3
#tool nuget:?package=NFun&version=1.1.3
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. |
-
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.1.3 | 470 | 6/1/2026 | |
| 1.1.2 | 104 | 5/30/2026 | |
| 1.1.1 | 417 | 5/17/2026 | |
| 1.1.0 | 2,820 | 5/1/2026 | |
| 1.0.3 | 9,077 | 7/26/2025 | |
| 1.0.2 | 439 | 7/26/2025 | |
| 1.0.1 | 50,737 | 7/17/2023 | |
| 1.0.0 | 2,531 | 12/1/2022 | |
| 0.9.9 | 816 | 7/6/2022 | |
| 0.9.8 | 766 | 5/29/2022 | |
| 0.9.7 | 849 | 4/2/2022 | |
| 0.9.6 | 795 | 4/2/2022 | |
| 0.9.5 | 839 | 1/15/2022 | |
| 0.9.4 | 675 | 12/26/2021 | |
| 0.8.2 | 945 | 5/30/2020 |
v1.1.3: fix integer-bitwise type inference under Real-preferred dialect (e.g. `1 & 1` now resolves to Int32 instead of Int64 when IntegerPreferredType=Real). Restores 1.0.x behaviour that regressed when SimplePrimitiveSolver took over the primitive-only resolution path.