Skip to content

Instantly share code, notes, and snippets.

View leque's full-sized avatar

OOHASHI Daichi leque

View GitHub Profile
@leque
leque / s.ml
Created March 14, 2020 15:03
camlp5o pr_scheme.cmo pr_schemep.cmo s.ml > s.scm
type t =
| Leaf of int * string
| Concat of int * t * t
let length = function
| Leaf (i, _) -> i
| Concat (i, _, _) -> i
let leaf s =
Leaf (String.length s, s)
@leque
leque / s.ml
Created February 17, 2020 15:52
type t =
| Leaf of int * string
| Concat of int * t * t
let length = function
| Leaf (i, _) -> i
| Concat (i, _, _) -> i
let leaf s =
Leaf (String.length s, s)
@leque
leque / cs.scm
Last active February 14, 2020 16:40
;;; Gaucheの拡張文字クラス
(use util.match)
(pprint
(let ()
(define f
(match-lambda
((name actual expected)
(let ((b (equal? actual expected)))
(and (not b) (list name b))))))
@leque
leque / s9.scm
Last active February 1, 2020 12:51
s9.scm from S9fES Interpreter, 2007 (1st ed.) version http://t3x.org/index.html#past
;;
;; Scheme 9 from Empty Space
;; Copyright (C) 2007 Nils M Holm <[email protected]>
;;
;;----- Library -----
(define (not x) (eq? #f x))
(define number? integer?)
@leque
leque / hoge.rb
Last active January 29, 2020 13:08
# cd opam-repository
# ruby hoge.rb packages/*
def ocaml_ver_lower_bound(dir)
File.read(File.join(dir, 'opam')).lines.collect {|line|
/ *"ocaml" {>= "([^"]*)".*$/.match(line){|m| m[1] }
}.detect{|x| x }
end
def latest_dir(package)
Require Extraction.
(* https://coq.github.io/doc/master/stdlib/Coq.Arith.Factorial.html *)
Require Import Coq.Arith.Factorial.
Extraction Language JSON.
Extraction fact.
(*
{
"what": "decl:fixgroup",
"fixlist": [
@leque
leque / ext.v
Created November 17, 2019 02:38
Require Extraction.
Inductive list (A : Type) : Type :=
| nil : list A
| cons : A -> list A -> list A.
CoInductive Stream (A : Type) :=
Cons : A -> Stream A -> Stream A.
Extraction Language Haskell.
(use srfi-1)
(use util.match)
(define id-cont
`(lambda (x) x))
(define (translate term env cont)
(match term
((? integer? term)
`(,cont ,term))
ℰ : Exp -> Env -> Cont -> Ans
Proc = Val -> Cont -> Ans
ρ ∈ Env = Var -> Val
κ ∈ Cont = Val -> Ans
ℰ⟦x⟧ρκ = κ (ρ⟦x⟧)
ℰ⟦E1 E2⟧ρκ = ℰ⟦E1⟧ρ (λf. ℰ⟦E2⟧ρ (λa. f a κ)
ℰ⟦λx.E⟧ρκ = κ (λv.λκ'. ℰ⟦E1⟧ρ[⟦x⟧↦v]κ')
ℰ⟦Sk.E⟧ρκ = ℰ⟦E⟧ρ[⟦k⟧↦λv.λκ'.κ' (κ v)] (λx. x)
ℰ⟦<E>⟧ρκ = κ (ℰ⟦E⟧ρ(λx. x))
@leque
leque / k.c
Created March 29, 2019 05:27
#include QMK_KEYBOARD_H
extern keymap_config_t keymap_config;
// Each layer gets a name for readability, which is then used in the keymap matrix below.
// The underscores don't mean anything - you can have a layer called STUFF or any other name.
// Layer names don't all need to be of the same length, obviously, and you can also skip them
// entirely and just use numbers.
#define _QWERTY 0
#define _COLEMAK 1