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
type KeyedLookupT<TKey, TValue> = { | |
get: (key: TKey) => TValue | undefined | |
set: (key: TKey, value: TValue) => KeyedLookupT<TKey, TValue> | |
entries: () => TValue[] | |
} | |
const KeyedLookup = { | |
create: <TKey extends object | string, TValue>() : KeyedLookupT<TKey, TValue> => { | |
type MapValueT = { type: 'TValue', value: TValue} | |
type InnerMapT<TKey, TValue> = { |
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
public static IObservable<T> MyScan<T>(this IObservable<T> stream, T init, Func<(T acc, T curr), T> resultCalc) | |
{ | |
return Observable.Create<T>(obs => | |
{ | |
var result = init; | |
var dispose = | |
stream.Subscribe( | |
x => { | |
result = resultCalc((result, x)); | |
obs.OnNext(result); |
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
// https://leetcode.com/problems/add-two-numbers/submissions/ | |
public class Solution { | |
public ListNode AddTwoNumbers(ListNode l1, ListNode l2) { | |
ListNode head = null; | |
ListNode current = null; | |
int carry = 0; | |
while(l1 != null || l2 != null) { | |
var v1 = (l1?.val) ?? 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
// https://leetcode.com/problems/two-sum/submissions/ | |
public class Solution { | |
public int[] TwoSum(int[] nums, int target) { | |
var dict = new Dictionary<int, (int num, int index)> (); | |
for(int i = 0; i < nums.Length; ++i) { | |
var current = nums[i]; | |
var required = target - current; | |
if(dict.TryGetValue(required, out var avail)) { |
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
<!DOCTYPE html> | |
<head> | |
<!-- Layouts --> | |
<style type="text/css"> | |
html, body { | |
margin: 0; | |
height: 100%; | |
} | |
body { |
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
<!DOCTYPE html> | |
<head> | |
<!-- Layouts --> | |
<style type="text/css"> | |
.fixed-topleft { | |
position: fixed; | |
top: 0px; | |
left: 0px; | |
width: 100%; | |
} |
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
module Program = | |
type Fizz = Fizz | |
type Buzz = Buzz | |
let fizzBuzzLines = | |
let fizzPattern = Seq.initInfinite (fun _ -> [ None; None; Some Fizz ] ) |> Seq.concat | |
let buzzPattern = Seq.initInfinite (fun _ -> [ None; None; None; None; Some Buzz ] ) |> Seq.concat | |
let fizzBuzzPattern = | |
buzzPattern | |
|> Seq.zip fizzPattern |
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
import Html exposing (text) | |
import Time exposing (Time) | |
type UnitType = Metric | Imperial | |
type Speed = Mph Float | Kph Float | |
type Pace = MinPerMile Float | MinPerKm Float | |
type Distance = Miles Float | Kms Float | |
speedConversionFactor = 0.621371192 |
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
module MergeSort = | |
let rec sort listToSort = | |
let rec merge lhs rhs = | |
match (lhs, rhs) with | |
| [], [] -> [] | |
| l, [] -> l | |
| [], r -> r | |
| x::xs, y::ys -> if x < y then x :: (merge xs rhs) else y :: (merge lhs ys) | |
match listToSort with |
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
#r @"C:\Users\Andy\Documents\Programming\Projects\F#\ScratchPad\packages\Rx-Core.2.2.5\lib\net45\System.Reactive.Core.dll" | |
#r @"C:\Users\Andy\Documents\Programming\Projects\F#\ScratchPad\packages\Rx-Interfaces.2.2.5\lib\net45\System.Reactive.Interfaces.dll" | |
#r @"C:\Users\Andy\Documents\Programming\Projects\F#\ScratchPad\packages\Rx-Linq.2.2.5\lib\net45\System.Reactive.Linq.dll" | |
#r @"C:\Users\Andy\Documents\Programming\Projects\F#\ScratchPad\packages\FSharp.Control.Reactive.3.2.0\lib\net40\FSharp.Control.Reactive.dll" | |
open FSharp.Control.Reactive | |
open System.Reactive.Disposables | |
open System.Reactive.Linq | |
open System.Reactive.Subjects |
NewerOlder