Skip to content

Instantly share code, notes, and snippets.

interface Z {}
interface N<T> {}
interface E<T> extends N<N<? super E<? super T>>> {}
// Changing E to the following, Oracle JDK 1.8.0_92 says
// `error: incompatible types: E<Z> cannot be converted to N<? super E<Z>>`
// interface E<T> extends N<N<? super E<T>>> {}
class GenericsLoop {
--- configure_help_1.4.0.txt 2016-05-01 23:00:52.643008544 +0900
+++ configure_help_1.5.0.txt 2016-05-01 22:51:46.547470970 +0900
@@ -7,6 +7,7 @@
--target=TARGET target platform tuple [generic-gnu]
--cpu=CPU optimize for a specific cpu rather than a family
--extra-cflags=ECFLAGS add ECFLAGS to CFLAGS []
+ --extra-cxxflags=ECXXFLAGS add ECXXFLAGS to CXXFLAGS []
--enable-extra-warnings emit harmless warnings (always non-fatal)
--enable-werror treat warnings as errors, if possible
(not available with all compilers)
# nixos-rebuild build-vm -I nixpkgs=~/src/nixpkgs -I nixos-config=./configuration.nix
{ config, pkgs, ... }:
{
nix.maxJobs = 4;
nix.useChroot = true;
nixpkgs.config.allowUnfree = true;
# nixos-rebuild build-vm -I nixpkgs=~/src/nixpkgs -I nixos-config=./configuration.nix
{ config, pkgs, ... }:
{
imports =
[
<nixos/modules/installer/scan/not-detected.nix>
];
nix.maxJobs = 4;
M1 k1 = (call/cc (M2 k1)) + 3
M2 k1 k2 = if b then (k1 1) else (k2 2)
(call/cc M1) + 4
S1 = shift(λk1. k1(reset(k1((S2 k1) + 3))))
S2 k1 = shift(λk2. k2(if b then (k1 1) else (k2 2)))
reset(exit(S1 + 4))
@taku0
taku0 / Main.scala
Last active March 12, 2016 12:26
ユーザのコレクションをJAX-RSで書いた場合とFinchで書いた場合(コンパイルしていない)
object Main {
val users: Users = new Users()
val api = {
import EndPoints._
getUsers :+: addNewUser :+: putUser :+: deleteUser :+:
getUser:+: getUserId :+: getUserName :+:putUserName :+:
}
object EndPoints {
tryGrammar(
"subtract",
MacroPEGParser.parse(
"""
|S = ReadRight("") !.;
|// the number of occurence of '1 represents a natural number.
|// a-b=c
|// Essentially, this checks a=b+c.
|ReadRight(Right)
| = &("1"* "-" Right "1") ReadRight(Right "1")
# '1'を並べた数で自然数を表すとする。
# a+b=c$をチェックする。
Plus = Plus0();
Plus0(Left)
= &(Left "+") Plus1(Left, )
/ &(Left "1") Plus0(Left "1");
Plus1(Left, Right)
= &(Left "+" Right "=") Plus2(Left, Right)
/ &(Left "+" Right "1") Plus1(Left, Right "1");

部分適用の無いHOPEG(高階PEG)の表現力はFOPEG(一階PEG)と同じ?

  1. 規則の数は有限である。
  2. 規則の各パラメタについて、それが規則を受け取るのかどうかは決定可能。 例: Foo(f, x) = f(x); Bar(g, x) = Foo(g, x)ならfとgはルールでないといけない。
  3. よって、全てのルールを展開すればルールを受け取るパラメタを消せる。 例:
      Foo(f, x) = 'd' f(f, x);
      Bar(f, x) = 'c' / 'a' Foo(f, 'a' x) Foo(f, 'b' x);
    
# X ↑ Y / Zを X Y / !(X) Zの略記法とする(カット)。
# 入力は変数x1, x2, ..., xnを使った連言標準形の論理式とする。ただし最後に特別な記号$を付ける。
# 例: x1 ∨ x2 ∧ x1 ∨ ¬x3 $
# 簡単のために、¬x3は1つのシンボルとする。
# .は任意の1シンボルにマッチするパターン。...は省略
START <- SAT(., ., ..., .)