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
(defn- decode-huffman [nodes buffer] | |
(string/join (loop [byte-pos 0 bits (first buffer) | |
node (last nodes) | |
bits-remaining 8 output []] | |
(if (= 0 bits-remaining) | |
(recur (inc byte-pos) (nth buffer (inc byte-pos)) node 8 output) | |
(let [next-node (if (bit-test bits 7) :right :left)] | |
(if (= 255 (:right node)) | |
(if (not= (:value node) "|") |
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 attribute = | Attribute of string * string | |
type node = | |
| Node of string * (attribute list) * (node list) | |
| Text of string | |
let element name attrs nodes = | |
Node (name, attrs, nodes) | |
let attr k v = |
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
defmodule DeepMerge do | |
defp _merge(key, v1, v2) when is_map(v1) do | |
Map.merge(v1, v2, &_merge/3) | |
end | |
defp _merge(key, v1, v2), do: v2 | |
def merge(map1, map2) when is_map(map1) and is_map(map2) do | |
Map.merge map1, map2, &_merge/3 | |
end |
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 (..) | |
worldData = | |
{ people = | |
[ { money = 129825, name = "Alice Brown" } | |
, { money = 100, name = "John Smith" } | |
, { money = 50000000000, name = "Scrooge McDuck" } | |
, { money = 2870, name = "Charlie Johnson" } | |
, { money = 8273280, name = "Michael Smith" } | |
] |
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) | |
(>>=) x y = Result.andThen y x | |
-- We need | |
r = Ok "hello" | |
|> Result.andThen (\x -> Ok " world" | |
|> Result.andThen (\y -> Ok (x ++ y))) | |
r2 = Ok "hello" |
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 pipe_forward_test | |
(|>) x y = y x | |
add x y = x + y | |
add_one x = add 1 x | |
res = 2 |> add_one |
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
-- In MLFE | |
module curry_fun | |
export curried/1 | |
curried arg1 = | |
let curried2 arg2 = | |
let curried3 arg3 = | |
arg1 + arg2 + arg3 |
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 hackney | |
export main | |
-- simple result ADT | |
type result 'a 'b = Error 'a | Ok 'b | |
-- define 'bind' for result | |
let (*>>=) a f = | |
match a 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
alias dril="docker run -it `docker images | head -n 2 | tail -n 1 | awk '{print $3}'`" |
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
[{alpaca_codegen,gen_expr, | |
[{env,[{<<"fails">>,1},{<<"succeeds">>,1}],alpaca_bad,0,0}, | |
{alpaca_fun,6,undefined,1,undefined, | |
[{alpaca_fun_version,0, | |
[{'Symbol', | |
#{'__struct__' => record, | |
line => 6, | |
name => <<"svar_1">>, |