Skip to content

Instantly share code, notes, and snippets.

@0x53A
0x53A / Ringbuffer.cs
Created July 24, 2013 11:27
Ringbuffer in C#, fixed size
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
namespace xxx
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace xxx
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace xxx
{
using Microsoft.ConcurrencyVisualizer.Instrumentation;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApplication3
open Microsoft.FSharp.Quotations
open Microsoft.FSharp.Quotations.Patterns
open Microsoft.FSharp.Quotations.DerivedPatterns
let println expr =
let rec print expr =
match expr with
| Application(expr1, expr2) ->
// Function application.
open Microsoft.FSharp.Quotations
open Microsoft.FSharp.Quotations.Patterns
open Microsoft.FSharp.Quotations.DerivedPatterns
open System
type Variable = Variable of string
type Expression =
| VarExp of Variable
| Const of float
open Microsoft.FSharp.Quotations
open Microsoft.FSharp.Quotations.Patterns
open Microsoft.FSharp.Quotations.DerivedPatterns
let println expr =
let rec print expr =
match expr with
| Application(expr1, expr2) ->
// Function application.
print expr1
@0x53A
0x53A / C#
Last active December 30, 2015 22:16
F# using patterns
public static void sample1()
{
FileStream fs = File.Create("x.txt");
try
{
fs.WriteByte(1);
}
finally
{
IDisposable disposable = fs as IDisposable;
#r "System.ValueTuple.dll";;
type fstsnd = class
static member Fst ((x, _)) = x
static member Fst ((x, _, _)) = x
static member Fst ((x, _, _, _)) = x
static member Fst ((x, _, _, _, _)) = x
static member Fst ((x, _, _, _, _, _)) = x