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
'Usage example: | |
'Dim setsOfList = OriginalList.Chunk(3) | |
'For Each innerList In setsOfList | |
'Do stuff | |
'Next | |
<Extension()> | |
Public Iterator Function ChunkData(Of TSource)(source As IEnumerable(Of TSource), chunkSize As Integer) As IEnumerable(Of IEnumerable(Of TSource)) | |
Dim _chunkSize = IIf(source.Count < chunkSize, source.Count, chunkSize) | |
Dim i = 0 |
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
Imports System.Reflection | |
Imports System.Linq.Expressions | |
''' <summary> | |
'''This generic class encapsulates the main algorithms for building a rule engine and a list of matched source/merge '''"rows"To prove whether a row in source and target are equivalent. | |
''' A property in the classes we may be using represent columns in a table or query. | |
'''Say we have an instance thus: | |
'''SourcePerson = New Person with {.Name = "ommitted db query", | |
''' .DOB =" ommitted db query"} | |
'''MergedPerson = New Person with {.Name = "ommitted db query", | |
''' .DOB =" ommitted db query"} |
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
let squaresNcubes = Array2D.create 10 10 ([|1 .. 10|] |> Array.map (fun x -> x * x), [|1 .. 10|] |> Array.map (fun x -> x * x * x)) |
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
//Totally unnecessary implementation of course but attempting to implement one's own graphics also means | |
//getting to play with the idioms and datastructures of a language IMHO | |
//I might implement Logo in here someday :). | |
let square (x,y) length = [ (x,y,x+length,y); //top | |
(x,y+length,x+length,y+length); //bottom | |
(x,y,x ,y + length ); //left | |
(x + length,y,x + length, y + length )] //right | |
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
let counter(str:string,ch:char) = str.ToCharArray() | |
|> Array.sumBy(fun s -> | |
let x = 0 | |
match s with | |
| c when ch = s-> x + 1 | |
| _ -> x) | |
let chrs = ['e';'a';'o';'s';'t'] | |
let sample = "tesqatetweafwefwlvuioneuiounrv;onr;rvoian;c;oi;oijewrrfaa" | |
let character = chrs |> List.map(fun x-> counter (sample ,x)) |
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
//This belongs to the F# dll above. | |
Function buildFilmStackPanel(Title As netflix.ServiceTypes.Title) | |
Dim stack As New StackPanel | |
Dim Filmtitle As New Label With {.Content = Title.Name, .ClipToBounds = True} | |
Dim Synopsis As New TextBlock With {.Text = Title.Synopsis, .TextWrapping = TextWrapping.Wrap, .FontSize = 10, .ClipToBounds = True, .MaxWidth = 400} | |
Dim imageStr As String = Title.BoxArt.MediumUrl | |
Dim image As New Image() With {.Source = New BitmapImage(New Uri(imageStr)), | |
.Width = 256, |
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
open System | |
open System.Data | |
open System.Data.Linq | |
open Microsoft.FSharp.Data.TypeProviders | |
open Microsoft.FSharp.Linq | |
type dbschema = SqlDataConnection<"Data Source=Katrina\SQLExpress;Initial Catalog=RCPD;Integrated Security=SSPI;"> | |
let db = dbschema.GetDataContext() | |
db.DataContext.Log |> System.Console.Out |
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
let (|Vowel|) chr = match chr with | |
|'a'|'e'|'i'|'o'|'u' -> 1 | |
| _ -> 0 | |
let count = "afwefaf;oijv;oiwerj;gfj;wjofjojejfjov ns" |> Seq.map(fun (Vowel x) ->x ) |> Seq.sum | |
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
//I had a need to test a few combinations of AsParallel and OrderBy whilst learning C# | |
//Here I wanted to try initialising a dictionary inline - not keen on code repetition. | |
//Outcome was for this dataset, AsParallel didn't help but worsened performance. | |
//Note, I tried more combinations than this. | |
private void timedResult(IEnumerable<Data> data) | |
{ | |
var NoOrderNoParallel = data.Where(g => g.CODE == "BXF04A").Select(g => g); | |
var OrderedOnly = data.OrderBy(c => c.CODE).Where(g => g.CODE == "BXF04A").Select(g => g); | |
var ParallelOnly = data.AsParallel().Where(g => g.CODE == "BXF04A").Select(g => g); |
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
using System; | |
namespace PlayingAround | |
{ | |
class Program | |
{ | |
/// <summary> | |
/// 15 minute answer to Coding Interview Puzzle 1. Previous solution used a dictionary and extension method. | |
/// This is more old school and faster. | |
/// The question is given a million integers between 1 and 130, count how many of each value there are. |
OlderNewer