This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Solid.Implementations | |
open Solid | |
open Bitwise | |
open System | |
open Extensions | |
open System.Collections.Generic | |
open Solid.Implementations.MsdHashing | |
module TrieMap = | |
let keyWidth = 5 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//We use an abstract class to define a general linked list. | |
// We don't use discriminated unions as is frequent because they cannot store any initialization data, which makes them unsuitable for caching purposes. | |
//The generic type parameters are somewhat byzantine, but I don't know how else to accomplish this. | |
[<AbstractClass>] | |
type LinkedListAbstract<'list,'value when 'list :> LinkedListAbstract<'list,'value>>(value : 'value, tail : 'list option) = | |
member this.Tail = tail | |
member this.Value = value | |
abstract member Create : 'value -> 'list option -> 'list | |
member this.Cons v = this.Create v (Some (this :?> 'list)) | |
// These are basically the only instance members needed for full linked list functionality (unless I'm missing something). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Learn more about F# at http://fsharp.net | |
// See the 'F# Tutorial' project for more help. | |
module SoldiTesting.Main | |
open System.Numerics | |
open System.Diagnostics | |
open System |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace SolidTesting | |
open System | |
open System.Collections.Generic | |
open System.Collections | |
open System.Runtime.CompilerServices | |
open System.Runtime | |
module VariousLists = | |
//This attribute is added for optimization. It makes matches to the empty union case faster. | |
//http://stackoverflow.com/questions/11959321/why-is-none-represented-as-null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Fun fact: It is possible to define the Cons (::) symbolic union case | |
used by FSharp's own list data structures for your own discriminated unions. *) | |
type MyList<'t> = | |
| Nil | |
| (::) of 't * MyList<'t> | |
let x = 100::99::98::Nil | |
//The compiler will infer this to be of type MyList<int> since I explicitly used the Nil union case of MyList | |
//And not the [] union case of List. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* While you can give primitive types aliases, like this:*) | |
type Count = int | |
(* There will never be any type checking involved when assigning from int to Count. *) | |
(* An interesting use of units of measure changes this. If I define: *) | |
[<Measure>] type quantity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var x = | |
from blah in Enumerable.Range(0, 10000).AsSequential() | |
where blah % 2 == 1 | |
select blah; | |
//By default the result of this custom list comprehension is an object called DelayedSequential<T>. | |
//This object is evaluated and a concrete collection is returned via an implicit conversion. | |
Sequential<int> s = x; | |
//Alternatively, we can write |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public sealed class CustomRange : IEnumerable<int>,IEnumerator<int> | |
{ | |
private int cur; | |
private readonly int max; | |
public CustomRange(int start, int count) | |
{ | |
cur = start - 1; | |
max = start + count; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var delayed_list = | |
from item in Enumerable.Range(0, 1000).DelayedList() | |
where item%2 == 0 | |
select item*2; | |
// This is a 'delayed list'. | |
//Basically it is implicitly capable of producing a real List collection if we choose to force it. | |
//Before we do, we can just perform a few more LINQ queries... | |
var delayed_list2 = | |
from item in delayed_list |
OlderNewer