Simplee.Data 1.0.51

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Simplee.Data --version 1.0.51
NuGet\Install-Package Simplee.Data -Version 1.0.51
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="Simplee.Data" Version="1.0.51" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Simplee.Data --version 1.0.51
#r "nuget: Simplee.Data, 1.0.51"
#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 Simplee.Data as a Cake Addin
#addin nuget:?package=Simplee.Data&version=1.0.51

// Install Simplee.Data as a Cake Tool
#tool nuget:?package=Simplee.Data&version=1.0.51

Boole |> Koda |> Simplee.Data

This documentation is part of the documentation for the Boole project. For details related to this project, please check its readme file.

The Simplee.Data namespace implements several common data structures:

Package Installation

You can install the library using either nuget, dotnet cli, or paket cli. You can find the package in nuget at Simplee.Data

Install-Package Simplee.Control -Version 1.0.50 
dotnet add package Simplee.Control --version 1.0.50 
paket add Simplee.Data --version 1.0.50 

Range

The Range uses a pair of float values to represent a range of values between the minimum and maximum values. The library supports all different type of ranges: empty (see RangeNa) and non-empty which their complete combination of open/close ends (RangeOO, RangeCO, RangeOC, RangeCC). To create a range you can use one of the constructor function: na, oo, oc, co, cc or their variations which create ranges center in 0 (e.g. co0).

Checking a position

Given a float value, you can determine the relative position of the value to a range (below, inside, above) and the distance to the low boundary of the range by calling pos function.

open Simplee.Data

(-5., 10.) 
|> Range.oo
|> Result.bind (Range.pos -6. >> Ok)
|> isREqual (1. |> RangePositionBelow)
Boundary check

Another functionlaity exposed by the library is the capability to perform several standard operations on a given float value considering the boundaries of a range. For example the value can be wrapped by calling bndrwrap. The function determines if a given value is above a given range and it is moved back in the range by wrapping it position on the left boundary of the range). Similar operation is performed if the value is below the range, this time the wrapping happening on the right boundary of the range. Another type of boundary check is bndrbounce which bounces back inside the range a value if the value sits outside of the range.

open Simplee.Data

let wrap : BoundaryCheck = Range.bndrwrap

5.
|> Range.oo0
|> Result.bind (wrap 6. >> Ok)
|> isREqual (-4., DirectionUnchanged)

let bounce : BoundaryCheck = Range.bndrbounce

5.
|> Range.oo0
|> Result.bind (bounce -6. >> Ok)
|> isREqual (-4., DirectionChanged)
|> ignore   

In the examples above we use the range (-5, 5). In the first example, the value 6 is wrapped since its original distance outside of the range is 1 then it is moved to -4, which is 1 unit away from the left boundary. In the second example, the value -6 is bouced back in the range since it originally sits outside of the range, 1 unit distance from the left boundary. Its new position is -4, this time 1 unit distance from left boundary, but inside of the range.

The boundary check functions also return a value indicating if the direction of the value has changed. In the second example, we get DirectionChanged since the value was bounced back in the range (imagine a ball bouncing back the wall). In the first example, we get DirectionUnchanged because wrapping operation continues moving the value in the same direction but just starting from the other end.

For more examples, please take a look the unit tests provided in the project.

Stack

The Stack is implemented as a monad. Practically you can create a computation workflow where each item in the workflow represents a given instruction (which is general maps to the basic stack operations). In order to execute the computation workflow you should run run function. The run function uses as input function which are implementation for each instruction. Also, for each instruction you can find a pair function which allows you to create a workflow (push, pop, peek, bpush, bpop, bpeek), or append the instruction to an existing workflow (kpush, kpop, kpeek etc.)

Here is an example:

open Simplee.Data

5
|> Stack.push
|> Stack.kpush 6     
|> Stack.kpop

This example creates a computation workflow which first will push 5 on the stack, and then pushes 6 on the stack, and last it pops a value from stack. In order to execute this computation workflow, we should provide implementation for the instructions. A good example of computation workflow execution is the print function which actually takes the workflow and interprets each instruction by generating a log for each instruction, in the end these logs are returned at the end of the function. Here is the same example, this time with the computation workflow interpreted by the print function:

open Simplee.Data

5
|> Stack.push
|> Stack.kpush 6     
|> Stack.kpop
|> Stack.print 100 "My stack"
|> List.iter (printfn "%s")

My stack
 100 push  5
 101 push  6
 102 pop   
 103 rtrn  
Stack Computation Builder

The library provides also a computation builder, stack. This computation builder can be used to build stack workflow using an imperative way.

let w = stack {
    let! _ = Stack.push 5
    let! _ = Stack.push 6
    let! x = Stack.pop ()
    return x
}

w
|> Stack.print 100 "My stack"
|> List.iter (printfn "%s")

The two examples generate the same collection of logs.

Stack In-Memory

The library provides an implementation for an in-memory stack which is based in the List class. The implementation is yet another example of how we can interpret a stack computation workflow by using run function provided with different implementation for the stack operations - this time by adding and removing items from a list. To execute a stack computation workflow again the in-memory implementation, you should use the im or imdef functions. The first one allows you to handle the errors, while the second one uses the default error handler.

stack {
    let! _ = Stack.push 5
    let! _ = Stack.push 6
    let! x = Stack.pop ()
    return x
}
|> Stack.imdef 100
|> isREqual 6

For more examples, please take a look the unit tests provided in the project.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 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. 
.NET Core netcoreapp2.0 is compatible.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.0.50 906 6/7/2018
1.0.3 1,038 3/14/2018
1.0.2 1,014 3/14/2018
1.0.1 904 3/14/2018
1.0.0 1,019 3/2/2018

Added the in-memory implementation for the stack operations.