Skip to content

Instantly share code, notes, and snippets.

/*
Algorithm W
*/
object poly extends App {
type X = String
type U = Int
type Assump = Map[X, Scheme]
type Subst = Map[U, T]
type FTV = Set[U]
@hsk
hsk / poly.ml
Last active October 27, 2017 07:48
type x = string
type e =
| EInt of int
| EBool of bool
| EVar of x
| EApp of e * e
| EAbs of x * e
| ELet of x * e * e
let rec show_e = function
@hsk
hsk / poly.rs
Last active October 27, 2017 07:44
Algorithm W on Rust
/*
Algorithm W
*/
use std::collections::BTreeMap;
use std::collections::BTreeSet;
type X = String;
type U = i32;
type Assump = BTreeMap<X, Scheme>;
type Subst = BTreeMap<U, T>;
class MatchError
attr_accessor :r
def initialize(a)
@r = self
@match = a
end
def >>(a)
self
end
def >=(a)
@hsk
hsk / index.html
Last active March 22, 2017 13:42
smartlog.js hispeed big log data view
<html>
<title>SmartLogJs Example</title>
<script src="smartlog.js"></script>
<script>
window.onload = function () {
var counter = 0
var log = new SmartLog({
el:document.getElementById("log"),
buildRow:function(){return {
head:"",text:"",
@hsk
hsk / arith.pl
Created March 7, 2017 08:17
define syntax on prolog
:- op(1200, xfx, ['--', where, ::=]).
:- op(920, xfx, ['==>', '==>>']).
term_expansion((A where B), (A :- B)).
% 構文
zip([], [], []).
zip([L|Ls], [R|Rs], [(L,R)|Ps]) :- zip(Ls, Rs, Ps).
@hsk
hsk / elvm.pl
Created December 23, 2016 16:17
% elvm on prolog
:- style_check(-singleton).
reg(a). reg(b). reg(c). reg(d). reg(sp). reg(bp).
imm(N) :- integer(N), N >= 0, MAX is 256 * 65536, N < MAX.
update([],V,[V]).
update([Reg=_|R],Reg=V,[Reg=V|R]).
update([V1|R],V,[V1|R2]) :- update(R,V,R2).
@hsk
hsk / NSON.BNF
Last active November 7, 2016 15:17
NSON BNF
## NSON BNF
bool ::= 'true' | 'false'
value ::= '"' (not('"')|'\' _)+ '"'
| ('a'|...|'z'|'A'|...|'Z'|'_')('a'|...|'z'|'A'|...|'Z'|'_'|'0'|...'9')*
number ::= ('0'|...|'9')+
| ('0'|...|'9')* '.' ('0'|...|'9')+ | ('0'|...|'9')+ '.' ('0'|...|'9')*
value ::= atom | number | bool
expression ::= value | object | array
object ::= '{' (value ':' expression ','?)* '}'
@hsk
hsk / index.html
Last active October 14, 2016 02:13
prolog
<html>
<head>
<script src="http://pengines.swi-prolog.org/vendor/jquery/jquery-2.0.3.min.js"></script>
<script src="http://pengines.swi-prolog.org/pengine/pengines.js"></script>
<script type="text/x-prolog">
/*
TLLP interpreter in Prolog
*/
:- op(1060, xfy, (&)).
:- op( 950, xfy, [-<>, =>]).
@hsk
hsk / index.html
Last active October 14, 2016 02:03
Plain JS 3
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<title>$title</title>
$styles
</head>
<body>
<h1>$title</h1>