Skip to content

Instantly share code, notes, and snippets.

View koba-e964's full-sized avatar

Hiroki Kobayashi koba-e964

View GitHub Profile
(define-library (srfi 95)
(import (scheme base)
(scheme load))
;; this hack works only if the current directory is the root of picrin.
(load "piclib/srfi/1.scm")
(import (srfi 1))
(define (list-sorted? ls less?)
(let loop ((cur ls))
(if (<= (length cur) 1) #t
(if (less? (second cur) (first cur)) #f
module Var where
import Control.Monad.Trans (lift)
import Control.Monad.Trans.State.Strict
import Data.Map (Map, insert, empty)
import qualified Data.Map as Map
import Data.List (foldl')
type Var m = StateT (Map String Double) m
c-strtold.c
dtoastr.c
fprintftime.c
ldtoastr.c
strtoumax.c
xstrtold.c
false.c
lbracket.c
ls-dir.c
ls-ls.c
(* CoqEx 15 in http://qnighy.github.io/coqex2014/ *)
Inductive Tree:Set :=
| Node: list Tree -> Tree.
Theorem Tree_dec: forall a b:Tree, {a=b} + {a<>b}.
Proof.
fix 1.
intros a b.
destruct a.
Modification:
pic_try {
v = pic_apply(pic, mac->proc, args);
} pic_catch {
#if 1 && 1 /// TODO FIXME XXX
pic_printf(pic, "me error: %p --> %p %p :*: ~s \n", mac, mac->proc, mac->senv, pic_car(pic, args));
#endif
pic_errorf(pic, "macroexpand error while application: %s", pic_errmsg(pic));
kobae964@debian-kobae964:~/srcview/picrin/build$ bin/picrin
fatal error: failure in loading built-in.scm
macroexpand error while application: macroexpand error while application: pair required, but got #<proc 0xbc4910>アボートしました
using namespace std;
class Coloring {
private:
int cmin;
int n;
vector<vector<int> > e;
public:
/* n: number of edges, e: adjacent matrix of the graph */
Coloring(int n, vector<vector<int> > e) : cmin(n+1), n(n), e(e) {
if(n>=33) {
@koba-e964
koba-e964 / Hungarian.java
Created October 5, 2014 04:47
Hungarian Algorithm (n*n complete bipartite graph)
class Hungarian {
private int n;
private int e[][];
/**
* n*n complete bipartite graph
* @param e
*/
Hungarian(int[][] e) {
this.e = e; // shallow-copied
this.n = e.length;
/*
* Operations of power.
* Header requirement: algorithm, vector, cmath
*/
class Power {
typedef long long i64;
public:
/* a^b with no modulo operations */
static long long power(long long a, long long b) {
i64 s = 1;
/**
* Union-Find tree that contains a subset of {0..n-1} as nodes.
* @author koba-e964
*
*/
class UnionFind {
private int[] disj;
private int[] rank;
/**
* Initializes the union-find tree. At first, there are no nodes in it.