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 sys, os, pygame, scipy, numpy as np | |
# 引数チェック | |
if len(sys.argv) != 6: | |
print("Usage: vq.py <input_file> <w> <h> <k> <output_file>") | |
sys.exit(1) | |
inFile, W, H, K, outFile = sys.argv[1:] | |
W,H,K=[int(v) for v in [W,H,K]] | |
if not os.path.isfile(inFile): |
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
# read https://qiita.com/wisteria/items/5c7c218bb0b3dfce984b | |
import usb.core, usb.util, pyautogui, time | |
class MDMiniPad: | |
def __init__(self): | |
self.dev = usb.core.find(idVendor=0x0ca3,idProduct=0x0024) | |
self.ep = usb.util.find_descriptor( | |
self.dev.get_active_configuration()[(0,0)], | |
custom_match = lambda e: | |
usb.util.endpoint_direction(e.bEndpointAddress) == usb.util.ENDPOINT_IN) | |
interface = 0 |
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
% https://github.com/pycket/pycket/blob/master/papers/icfp15-paper.pdf | |
% e ::= x | λ(x,e) | e $ e | i | e + e | add(x,x) | |
% k ::= [] | [arg(e,p)|k] | [fun(v,p)|k] | |
:- op(1100,yfx,$). | |
v(I):- integer(I). | |
v(λ(_X,_E)). | |
cek(X/P/K , V/P/K):- atom(X),member(X->V,P). | |
cek((E1$E2)/P/K , E1/P/[arg(E2,P)|K]). | |
cek(V/P/[arg(E,P_)|K] , E/P_/[fun(V,P)|K]):- v(V). | |
cek(V/_/[fun(λ(X,E),P_)|K], E/[X->V|P_]/K):- v(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
read_key([Code|Codes]):- get_single_char(Code), read_pending_codes(user,Codes,[]). | |
read_keyatom(KAtom) :- read_key(Codes), codes_keyatom(Codes,KAtom). | |
codes_keyatom([27,91,65],up) :- !. | |
codes_keyatom([27,91,66],down) :- !. | |
codes_keyatom([27,91,67],right) :- !. | |
codes_keyatom([27,91,68],left) :- !. | |
data('#####################'). | |
data('#.........#.........#'). |
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
% shiftreset.pl | |
% http://pllab.is.ocha.ac.jp/~asai/cw2011tutorial/main-j.pdf | |
% 汎用構文定義用述語 | |
:- op(1200,xfx,::=),op(600,xfx,∈). | |
G∈(G|_). G∈(_|G2):-!, G∈G2. G∈G. | |
bnf(G,E):-G=..[O|Gs],E=..[O|Es],maplist(bnf,Gs,Es),!. | |
bnf(G,E):-(G::=Gs),!,G1∈Gs,bnf(G1,E),!. | |
bnf(i,I):-integer(I),!. | |
bnf(x,I):- atom(I),!. |
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
#lang racket | |
(require redex) | |
(define-language calc | |
(e ::= n (e + e) (e - e) (e * e) (e / e) (- e)) | |
(n ::= number)) | |
(define-metafunction calc | |
⊢ : e -> n | |
[(⊢ n) n] |
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
% ------------------------ SYNTAX ------------------------ | |
m(M) :- M = true | |
; M = false | |
; M = if(M1,M2,M3) , m(M1),m(M2),m(M3) | |
; M = zero | |
; M = succ(M1) , m(M1) | |
; M = pred(M1) , m(M1) | |
; M = iszero(M1) , m(M1) | |
. |
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
% Implementation on Prolog of The Design and Implementation of Typed Scheme | |
:- op(1200,xfx,[::=]),op(600,xfx,[∈,<:,:>]). | |
:- op(990,xfx,[⊢]),op(990,fy,[⊢]). | |
:- op(250,yf,[*]). | |
:- op(920, xfx, ['→', '↠']). | |
:- op(600,yfx,[$]). | |
G∈(G|_). G∈(_|G2):-G∈G2. G∈G :- G\=(_|_). | |
bnf(S/[S2],AEs) :- compound_name_arguments(AEs,A,Es),bnf(S,A),bnf(S2,Es). | |
bnf(G,E):-G=..[O|Gs],E=..[O|Es],maplist(bnf,Gs,Es),!. | |
bnf(G,E):-(G::=Gs),!,G1∈Gs,bnf(G1,E),!. |
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
#lang racket | |
(require redex) | |
(provide λ λV ev) | |
(define-language λ | |
(e ::= (e e) x (λ (x τ) e) (if0 e e e) (e + e) n) | |
(n ::= number) | |
(τ ::= (τ -> τ) num) | |
(x ::= variable-not-otherwise-mentioned)) |
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
use nom::bytes::complete::tag; | |
use nom::character::complete::multispace0; | |
use nom::combinator::map; | |
use nom::error::VerboseError; | |
use nom::sequence::tuple; | |
use nom::IResult; | |
struct Ctx { | |
a: i32 | |
} | |
impl Ctx { |
NewerOlder