This file contains hidden or 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
| open System.IO | |
| open System.Collections.Concurrent | |
| // A Merkle tree for a file system might look like this | |
| // PASTE!! | |
| let isDirectory(path:string) = | |
| let attr = File.GetAttributes(path) | |
| attr.HasFlag(FileAttributes.Directory) |
This file contains hidden or 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
| // Today's example is courtesy of @jindraivanek | |
| // https://gist.github.com/jindraivanek/5ff029577d2b544b2cd739d994750a18#file-memoizerec-fsx | |
| // As you remember, there was a warning on line 14 | |
| // For a good explaination, see @tomaspetricek's Stack Overflow post. | |
| // http://stackoverflow.com/questions/8636630/recursive-objects-in-f |
This file contains hidden or 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
| // A poor reimplementation of IAsyncResult. It was a fun exercise though | |
| public interface ITaskTrigger<T> { | |
| void SetComplete(T value); | |
| void ThrowException(Exception ex); | |
| } | |
| public class AsyncRequest<T, U> : ITaskTrigger<U> { | |
| public readonly T Request; | |
| public readonly ITaskTrigger<U> Trigger; |
This file contains hidden or 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
| void Main() { | |
| var doWork = CreatePipeLineFunc(async (int x) => { | |
| var delay = ((x % 3) + 1) * 1000; | |
| await Task.Delay(delay); | |
| return new { x, delay }; | |
| }, maxDegreeOfParallelism: 10); | |
| Enumerable.Range(1, 100).Select(m => doWork(m)).Dump(); | |
| } |
This file contains hidden or 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
| void Main() { | |
| string line; | |
| int runningTotal = 0, input = 0; | |
| do { | |
| line = Console.ReadLine(); | |
| if (Int32.TryParse(line, out input)) { | |
| runningTotal += input; | |
| Console.WriteLine(runningTotal); | |
| } else if (line == "quit" || line == null) { |
This file contains hidden or 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
| open System | |
| open System.Linq | |
| open System.Collections.Generic | |
| open System.Linq.Expressions | |
| type SortOrder = Asc | Desc | |
| type MongoQuery<'a> private(queryable:IQueryable<'a>, filters, sortFn, takeQty, skipQty) as this = | |
| new(query) = MongoQuery(query, [], None, None, None) | |
| member this.Where(filter:Expression<Func<'a,bool>>) = |
This file contains hidden or 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 NextWeb.Collections | |
| open System | |
| open System.Runtime.CompilerServices | |
| type ITree<'a> = | |
| abstract member Value: 'a | |
| abstract member Children: seq<ITree<'a>> | |
| [<Extension>] |
This file contains hidden or 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
| // This will generate a database, but EF will not materialize the objects | |
| // because our types do not have default parameterless constructors | |
| namespace DataModel | |
| open System | |
| open System.ComponentModel.DataAnnotations | |
| open System.Data.Entity | |
| type User = { mutable ID : int; mutable Name: string; mutable DB: DateTime; mutable Tasks: Task[]; | |
| mutable Projects: Project[] } |
This file contains hidden or 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
| Option Strict On | |
| Imports Allied | |
| Imports BaseTest.TestExtensions | |
| Imports Microsoft.VisualStudio.TestTools.UnitTesting | |
| Imports System.Xml.Linq | |
| Imports System.Collections.Generic | |
| <TestClass()> _ | |
| Public Class MParserTest |