PowTrees.LINQPad
0.0.40
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 PowTrees.LINQPad --version 0.0.40
NuGet\Install-Package PowTrees.LINQPad -Version 0.0.40
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="PowTrees.LINQPad" Version="0.0.40" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PowTrees.LINQPad --version 0.0.40
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: PowTrees.LINQPad, 0.0.40"
#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.
// Install PowTrees.LINQPad as a Cake Addin #addin nuget:?package=PowTrees.LINQPad&version=0.0.40 // Install PowTrees.LINQPad as a Cake Tool #tool nuget:?package=PowTrees.LINQPad&version=0.0.40
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
PowTrees
Table of content
Introduction
Tree structure with algorithms
Usage
FoldL
Map a tree recursively. For each node, we use the node and the mapped parent as input
Example:
record Rec(int Val, int Ofs); // where Ofs is an offset we want to apply to Val
// root =
// ┌►(30,0)
// │
// (10,0)──►(20,3)─┤ ┌►(50,0)
// └►(40,6)─┤
// └►(60,1)
// 1. Apply Ofs on the node and its descendents:
// ---------------------------------------------
root.FoldL((nod, acc) => acc + nod.V.Ofs, 0)
┌►3
│
0──►3─┤ ┌►9
└►9─┤
└►10
// 2. Apply Ofs on the node descendents only:
// ------------------------------------------
root.FoldL((nod, acc) => acc + nod.ParentOr(e => e.Ofs, 0), 0)
┌►3
│
0──►0─┤ ┌►9
└►3─┤
└►9
// 3. Create a dictionary from the nodes to their accumulators
// -----------------------------------------------------------
root.Zip(root.FoldL(fun))
.ToDictionary(
e => e.First.V,
e => e.Second.V
);
Build a node lookup map
If you transform a tree (A) into tree (B) without changing its shape (just changing the node content, not children). Very often, you then need to map the nodes of B back to A. For this use:
static IReadOnlyDictionary<TNod<T>, TNod<U>> BuildNodeLookup<T, U>(TNod<T> rootSrc, TNod<U> rootDst);
var lookupMap = TreeUtils.BuildNodeLookup(B, A);
License
MIT
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0-windows7.0 is compatible. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net7.0-windows7.0
- PowTrees (>= 0.0.40)
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 |
---|---|---|
0.1.2 | 112 | 6/30/2024 |
0.1.1 | 104 | 6/30/2024 |
0.1.0 | 105 | 6/30/2024 |
0.0.48 | 160 | 9/15/2023 |
0.0.47 | 122 | 9/3/2023 |
0.0.46 | 143 | 8/23/2023 |
0.0.45 | 123 | 8/22/2023 |
0.0.44 | 176 | 8/5/2023 |
0.0.43 | 149 | 7/30/2023 |
0.0.42 | 148 | 7/18/2023 |
0.0.41 | 151 | 7/15/2023 |
0.0.40 | 148 | 7/15/2023 |
0.0.39 | 149 | 7/12/2023 |
0.0.38 | 152 | 7/12/2023 |
0.0.37 | 166 | 7/11/2023 |
0.0.36 | 150 | 7/10/2023 |
0.0.35 | 139 | 7/10/2023 |
0.0.34 | 146 | 7/9/2023 |
0.0.33 | 142 | 7/8/2023 |
0.0.32 | 143 | 7/5/2023 |
0.0.31 | 146 | 7/5/2023 |
0.0.30 | 155 | 7/5/2023 |
0.0.29 | 144 | 7/4/2023 |
0.0.28 | 149 | 7/2/2023 |
0.0.27 | 133 | 6/21/2023 |
0.0.26 | 131 | 6/20/2023 |
0.0.25 | 132 | 6/20/2023 |
0.0.24 | 139 | 6/15/2023 |
0.0.23 | 138 | 6/15/2023 |
0.0.22 | 131 | 6/15/2023 |
0.0.21 | 139 | 6/12/2023 |
0.0.20 | 138 | 6/12/2023 |
0.0.19 | 143 | 6/5/2023 |
0.0.18 | 126 | 6/3/2023 |
0.0.17 | 127 | 6/3/2023 |
0.0.16 | 127 | 6/1/2023 |
0.0.15 | 134 | 5/31/2023 |
0.0.14 | 126 | 5/28/2023 |
0.0.13 | 131 | 5/28/2023 |
0.0.12 | 122 | 5/12/2023 |
0.0.10 | 145 | 4/24/2023 |
0.0.9 | 150 | 4/24/2023 |
0.0.8 | 304 | 12/4/2022 |
0.0.7 | 309 | 11/26/2022 |
0.0.6 | 304 | 11/26/2022 |