Skip to content

Instantly share code, notes, and snippets.

View ohlawdie's full-sized avatar
😟

Ohlawdie ohlawdie

😟
  • Michigan
View GitHub Profile
@ohlawdie
ohlawdie / asyncstream.fs
Created February 11, 2020 22:41
C8 Async Streams #F
namespace global
open System
open System.Collections.Generic
open System.Threading.Tasks
namespace ExploreCsharpEight
type AsyncStreams() =
member this.GenerateSequence() =
do
let mutable (i : int) = 0
while (i < 20) do
@ohlawdie
ohlawdie / uncheckedcs2fs.fs
Last active February 11, 2020 22:40
Unchecked #cs2fs
namespace global
namespace ConsumerVehicleRegistration
type Car() =
member val Passengers = Unchecked.defaultof<int> with get, set
namespace CommercialRegistration
type DeliveryTruck() =
member val GrossWeightClass = Unchecked.defaultof<int> with get, set
namespace LiveryRegistration
type Taxi() =
@ohlawdie
ohlawdie / stuffgunk.fs
Last active February 11, 2020 22:40
C8 Indices and Ranges #cs2fs
namespace global
open System
open System.Linq
namespace ExploreCsharpEight
type IndicesAndRanges() =
member val private words = [|"The"; "quick"; "brown"; "fox"; "jumped"; "over"; "the"; "lazy"; "dog"|] with get, set
member this.Syntax_LastIndex() =
Console.WriteLine (sprintf "The last word is %O" this.words.[(int (* ERROR UnknownPrefixOperator "^" *))])
0
member this.Syntax_Range() =
@ohlawdie
ohlawdie / ActivePatternDecomposition
Last active February 11, 2020 22:40
Active Pattern Decomp #F
open System.Drawing
let (|RGB|) (col : System.Drawing.Color) =
( col.R, col.G, col.B )
let (|HSB|) (col : System.Drawing.Color) =
( col.GetHue(), col.GetSaturation(), col.GetBrightness() )
let printRGB (col: System.Drawing.Color) =
match col with
@ohlawdie
ohlawdie / ExplicitFieldaccess.fs
Last active February 11, 2020 22:40
ExplicitField VAL #F F# #Let
//Line 4 and 17
type MyType() =
let mutable myInt1 = 10
[<DefaultValue>] val mutable myInt2 : int
[<DefaultValue>] val mutable myString : string
member this.SetValsAndPrint( i: int, str: string) =
myInt1 <- i
this.myInt2 <- i + 1
@ohlawdie
ohlawdie / ExtensionOfLinqBuilder.fs
Last active February 11, 2020 22:46
Ext of LinqBuilder #linq F#
type Microsoft.FSharp.Linq.QueryBuilder with
[<CustomOperation("existsNot")>]
member _.ExistsNot (source: QuerySource<'T, 'Q>, predicate) =
Enumerable.Any (source.Source, Func<_,_>(predicate)) |> not
@ohlawdie
ohlawdie / MethodSyntaxes.fs
Last active February 11, 2020 22:41
Method Syntaxes F# #FSharp
// Instance method definition.
[ attributes ]
member [inline] self-identifier.method-name parameter-list [ : return-type ] =
method-body
// Static method definition.
[ attributes ]
static member [inline] method-name parameter-list [ : return-type ] =
method-body
@ohlawdie
ohlawdie / helpvBuffer.cs
Last active February 11, 2020 22:52
#buffer
class BufferClassDemo
{
// Display the array elements from right to left in hexadecimal.
public static void DisplayArray( short[ ] arr )
{
Console.Write( " arr:" );
for( int loopX = arr.Length - 1; loopX >= 0; loopX-- )
Console.Write( " {0:X4}", arr[ loopX ] );
Console.WriteLine( );
}
@ohlawdie
ohlawdie / MethodBinding.cs
Last active February 11, 2020 22:48
MethodInfo #reflection
public override MethodInfo[] GetMethods(BindingFlags bindingAttr)
{
List<FlexMethodInfo> methods = new List<FlexMethodInfo>();
if (typeName == "Product")
{
methods.Add(new FlexMethodInfo("Concatenate", typeName));
methods.Add(new FlexMethFlexMethodInfo("Register", typeName));
return methods.ToArray();
}
@ohlawdie
ohlawdie / filestackrec.cs
Last active February 11, 2020 22:52
File Recursion #file #recursion
public class FileStackRec
{
static void Main(string[] args)
{
// Specify the starting folder on the command line, or in
// Visual Studio in the Project > Properties > Debug pane.
TraverseTree(args[0]);
Console.WriteLine("Press any key");
Console.ReadKey();