Skip to content

Instantly share code, notes, and snippets.

@amutake
amutake / LCGs.v
Created August 1, 2023 12:07
LCGs.v
Require Import Coq.ZArith.ZArith.
Inductive rand : Set :=
| State : Z -> rand.
(* 線形合同法による疑似乱数 *)
Definition next (r : rand) : rand :=
match r with
| State s =>
let s' := Z.modulo (Z.mul 48271 s) 2147483647 in
@amutake
amutake / empty.v
Last active July 25, 2023 10:01
coq
(* コードを書く *)
Definition x := 42.
@amutake
amutake / Main.hs
Created January 17, 2020 01:33
Haskell GC
module Main where
main :: IO ()
main = do
putStrLn "Hello World"
@amutake
amutake / .gitignore
Last active January 10, 2020 13:03
resource-pool with HDBC-postgresql
dist
dist-newstyle
.ghc.environment.*
@amutake
amutake / match.ml
Created January 11, 2019 01:43
extract nested match expressions
(* types *)
type erl_expr =
| ErlInt of int
| ErlVar of string
| ErlApp of erl_expr * erl_expr (* F(A) *)
| ErlMatch of erl_pat * erl_expr (* P = E *)
and erl_pat =
| ErlPatVar of string
@amutake
amutake / parsed.txt
Last active October 2, 2018 00:51
quic-14 ngtcp2 vector
クライアント -> サーバ (UDPパケット1つにQUICパケット1つ)
Header: Long Header (0b1000_0000)
Type: Initial (0x7f)
Version: IETF QUIC draft-14 (0xff00000e)
DCIL: 18 (0xf + 3)
SCIL: 17 (0xe + 3)
Dst Connection ID: 0xf2aca972962edd0f195aa1bb9a16734be91b
Src Connection ID: 0xd545b3713ec650dc4844f59652f737fa3a
Token Length: 0 (0x00, variable-length integer)
@amutake
amutake / fun_call_vs_msg_passing_heavy.erl
Created June 15, 2018 12:56
Erlang のメッセージパッシングのコストに関する雑なベンチマーク
-module(fun_call_vs_msg_passing_heavy).
-export([fun_call/1, msg_passing/1]).
fib(0) -> 0;
fib(1) -> 1;
fib(N) -> fib(N - 1) + fib(N - 2).
%% fib(20) (そこそこ重い処理のつもり) を N 回呼び出す
fun_call(N) ->
module Main where
import Control.Monad
import Data.List (nub)
data Coin = Black | White | Blank deriving (Eq, Ord)
instance Show Coin where
show Black = ""
show White = ""
@amutake
amutake / 2005-pattern-binding-modes-ja.md
Last active November 20, 2017 07:01
2005-pattern-binding-modes-ja

概要

参照に関するパターンマッチをよりわかりやすくします。

現在、参照に関するパターンマッチは ref& を使いわけなければいけません。

@amutake
amutake / 1522-conservative-impl-trait.md
Last active November 6, 2017 07:00
1522-conservative-impl-trait-ja