This file contains hidden or 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
| // Monadic DI: Reader and Free monad | |
| // https://www.youtube.com/watch?v=ZasXwtTRkio | |
| module Reader = | |
| type Reader<'d, 'a> = {Apply:('d -> 'a)} | |
| let reader f = {Reader.Apply = f} | |
| let (|Reader|) ({Reader.Apply = apply}) = apply |
This file contains hidden or 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
| // non-recursive implementation of Y-combinator, based on example from https://en.wikipedia.org/wiki/Fixed-point_combinator#Type_for_the_Y_combinator | |
| // with memoization | |
| using System; | |
| using System.Diagnostics; | |
| using System.Collections.Concurrent; | |
| //type 'a Recc = In of ('a Recc -> 'a) |
This file contains hidden or 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 scanLeft (s:'s) (f:'s -> 'a -> 's) (lst:'a list) : 's list = | |
| lst | |
| |> List.mapi (fun i _ -> | |
| lst | |
| |> List.take i | |
| |> List.fold f s ) | |
This file contains hidden or 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://adventofcode.com/2021 | |
| let readings = | |
| [| | |
| 199 | |
| 227 | |
| 229 | |
| |] | |
| // part1 |
OlderNewer