Skip to content

Instantly share code, notes, and snippets.

@AdamSpeight2008
AdamSpeight2008 / gist:1600610
Created January 12, 2012 13:49
BrainFuck in F# (50 LoC)
// Learn more about F# at http://fsharprogram.net
#light
module BrainFuck
open System
open System.Collections.Generic
exception UnmatchedBrace of string
let bf (program:string) (input: unit->char ) (output : char->unit) =
if program.Length=0 then ()
Imports CodeCracker
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Diagnostics
Imports Microsoft.CodeAnalysis.CSharp
Public Class CatchEmpty
Inherits CodeCracker.CSharp.Bases.Design.Analyzer
Public Sub New()
MyBase.New(DiagnosticIDs.CatchEmpty, "Your catch maye include some exception", "{0}", Kinds:={SyntaxKind.CatchClause})
.method private
instance class Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax.SyntaxToken TryScanToken (
valuetype Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax.SyntaxList`1<class Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax.VisualBasicSyntaxNode> precedingTrivia
) cil managed
{
// Method begins at RVA 0x1307a8
// Code size 2090 (0x82a)
.maxstack 6
.locals init (
[0] class Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax.SyntaxToken,
.method private
instance class Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax.SyntaxToken TryScanToken (
valuetype Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax.SyntaxList`1<class Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax.VisualBasicSyntaxNode> precedingTrivia
) cil managed
{
// Method begins at RVA 0x1307a8
// Code size 2049 (0x801)
.maxstack 6
.locals init (
[0] class Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax.SyntaxToken,
File: Microsoft.CodeAnalysis.Analyzers.dll, Size: 58056, Instructions: 3090 Switches: 0 (0%), OptimizableSwitches: 0 (0%), Size Saving: 0 (0%)
File: Microsoft.CodeAnalysis.CSharp.Analyzers.dll, Size: 16088, Instructions: 175 Switches: 0 (0%), OptimizableSwitches: 0 (0%), Size Saving: 0 (0%)
File: Microsoft.CodeAnalysis.Analyzers.dll, Size: 58056, Instructions: 3090 Switches: 0 (0%), OptimizableSwitches: 0 (0%), Size Saving: 0 (0%)
File: Microsoft.CodeAnalysis.VisualBasic.Analyzers.dll, Size: 16096, Instructions: 203 Switches: 0 (0%), OptimizableSwitches: 0 (0%), Size Saving: 0 (0%)
File: Microsoft.CodeAnalysis.Desktop.dll, Size: 186560, Instructions: 14256 Switches: 9 (0.06313131%), OptimizableSwitches: 9 (100%), Size Saving: 105 (0.05628216%)
File: Microsoft.CodeAnalysis.dll, Size: 1555120, Instructions: 135365 Switches:161 (0.1189377%), OptimizableSwitches: 161 (100%), Size Saving: 4324 (0.2780493%)
File: Microsoft.CodeAnalysis.dll, Size: 1555120, Instructions: 135365 Switches:161 (0.1189377%), OptimizableS
Errors Roslyn.Compilers.CompilerServer.UnitTests.dll:
Command: C:\Users\Adam\.nuget\packages\xunit.runner.console\2.1.0\tools\xunit.console.x86.exe "Binaries\Debug\Roslyn.
Compilers.CompilerServer.UnitTests.dll" -xml "Binaries\Debug\xUnitResults\Roslyn.Compilers.CompilerServer.UnitTests.d
ll.xml" -noshadow
Microsoft.CodeAnalysis.CompilerServer.UnitTests.CompilerServerUnitTests.HelloWorldVB [FAIL]
Microsoft.CodeAnalysis.CompilerServer.UnitTests.CompilerServerUnitTests.FallbackToVbc [FAIL]
Microsoft.CodeAnalysis.CompilerServer.UnitTests.CompilerServerUnitTests.ExecuteVbcBuildTaskWithServer [FAIL]
Microsoft.CodeAnalysis.CompilerServer.UnitTests.CompilerServerUnitTests.MultipleSimultaneousCompiles [FAIL]
Microsoft.CodeAnalysis.CompilerServer.UnitTests.CompilerServerUnitTests.ReferenceCachingVB [FAIL]
Microsoft.CodeAnalysis.CompilerServer.UnitTests.CompilerServerUnitTests.ExecuteCscBuildTaskWithServer [FAIL]
<?xml version="1.0" encoding="utf-16"?>
<?xml-stylesheet type="text/xsl" href="ActivityLog.xsl"?>
<activity>
<entry>
<record>1</record>
<time>2015/11/14 18:23:08.764</time>
<type>Information</type>
<source>VisualStudio</source>
<description>Microsoft Visual Studio 2015 RC version: 14.0.24627.0</description>
</entry>
@AdamSpeight2008
AdamSpeight2008 / gist:c7d4469a45542a6e5414
Created November 23, 2015 06:57
Digit Character Value (Test Code)
Imports System.Runtime.CompilerServices
Module Module1
Dim sw As New Stopwatch
Dim taken As Long = 0
Sub Main()
Dim methods() As Func(Of Char, Byte) = {AddressOf XX.Method1,
AddressOf XX.Method2,
AddressOf XX.IntegralLiteralCharacterValue,
AddressOf XX.Method3,
@AdamSpeight2008
AdamSpeight2008 / gist:c42b222dbc3ccac1177e
Created November 23, 2015 06:58
Digit Character Value (Test Results)
Method_1(0) : 0 510
Method_1(1) : 10000000 525
Method_1(2) : 20000000 551
Method_1(3) : 30000000 579
Method_1(4) : 40000000 576
Method_1(5) : 50000000 573
Method_1(6) : 60000000 578
Method_1(7) : 70000000 576
Method_1(8) : 80000000 526
Method_1(9) : 90000000 478
@AdamSpeight2008
AdamSpeight2008 / gist:eab776f68509d858c374
Created November 23, 2015 07:19
Digit Character Value (Test Results)
Method_1(0) : 0 307
Method_1(1) : 10000000 306
Method_1(2) : 20000000 381
Method_1(3) : 30000000 425
Method_1(4) : 40000000 405
Method_1(5) : 50000000 408
Method_1(6) : 60000000 401
Method_1(7) : 70000000 403
Method_1(8) : 80000000 340
Method_1(9) : 90000000 282