Instantly share code, notes, and snippets.

# Simon Stender Boisenssboisen

• Sort options
Created Feb 6, 2012
Project Euler Problems
View project_euler_p1.fsx
 {1..999} |> Seq.sumBy (fun n -> if n % 3 = 0 || n % 5 = 0 then n else 0)
Created Feb 6, 2012
View problem_2.fsx
 let fibs = Seq.unfold( fun (a,b) -> Some( a + b, (b, a + b) ) ) (1,1) let result = fibs |> Seq.takeWhile ( fun x -> x <= 4000000) |> Seq.sumBy ( fun x -> if x % 2 = 0 then x else 0)
Created Feb 21, 2012
View gist:1877672
 public static void ShouldBeStructurallyEqualTo(this IEnumerable actual, IEnumerable expected) { var actualList = actual.ToList(); var expectedList = expected.ToList(); actualList.Should().HaveCount(expectedList.Count()); bool isArrayOfValueType = typeof (T).IsArray && typeof (T).GetElementType().IsValueType; foreach (var pair in actualList.Zip(expectedList, Tuple.Create)) { if (isArrayOfValueType)
Created Jun 27, 2012
Unfold in C# .
View gist:3002299
 public sealed class Option : IEquatable> { private readonly T m_Value; private static readonly Option g_None = new Option(); private Option() { } private Option(T value) { m_Value = value; }
Created Jun 28, 2012
Wrap-Git
View wrapgist.ps1
 \$psgit = @{ 'tb' = "git branch -r --no-color | where { `\$_ -match ' (?origin/(?#1.+))' } | % { git branch --set-upstream `\$matches['b'] `\$matches['fb'] }"; } Set-Alias git Wrap-Git function Wrap-Git { if (-not \$psgit.ContainsKey(\$args[0])) {
Created Jul 4, 2012
ReplaceElementAt alternatives
View gist:3049158
 let ReplaceElementAt index element sequence = let beforeIndex = sequence |> Seq.take index let atIndex = element |> Seq.singleton let afterIndex = sequence |> Seq.skip (index + 1) Seq.append beforeIndex <| Seq.append atIndex afterIndex let ReplaceElementAt index element sequence = let beforeIndex = sequence |> Seq.take index let afterIndex = sequence |> Seq.skip (index + 1) seq { yield! beforeIndex; yield element; yield! afterIndex }
Created Sep 25, 2012
ssh tunneling
View gist:3780381