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 ConsoleApp1.Program | |
type Store<'s, 'a> = Store of lookup : ('s -> 'a) * index : 's | |
type Coord = int * int | |
type Grid<'a> = Store<Coord, 'a> | |
module Utils = | |
let getOrDefault k d m = | |
m |> Map.tryFind k |> (function | Some(v) -> v | None -> d) |
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 BinaryTree<'a> = | |
| Empty | |
| Node of value: 'a * left: BinaryTree<'a> * right: BinaryTree<'a> | |
let rec traverse f = | |
function | |
| Empty -> [] | |
| node -> f node | |
let rec inorder = |
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
#!/usr/bin/env stack | |
-- stack --resolver lts-9.17 --install-ghc runghc --package ilist | |
import Data.List.Index | |
main :: IO () | |
main = print $ indexed "example" |
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
#!/usr/bin/env stack | |
-- stack --resolver lts-9.17 script | |
{-# LANGUAGE QuasiQuotes #-} | |
module Main where | |
import Data.ByteString.Lazy (ByteString) | |
import Data.ByteString.Lazy.UTF8 (toString) | |
import Data.List (find) | |
import Data.Maybe | |
import Data.String.Here | |
import GHC.IO.Encoding |