Skip to content

Instantly share code, notes, and snippets.

@YuukiARIA
YuukiARIA / gist:6409957
Created September 2, 2013 07:08
[memo] helping inference of a type parameter
class Entity<X>
{
public Entity(X x)
{
}
public static <X> Entity<X> of(X x)
{
return new Entity<X>(x);
@YuukiARIA
YuukiARIA / gist:6732424
Last active December 24, 2015 02:39
[neta] Chaos Java
// This is a well-compiled java class!
class A
{
A(A A) { } A
A(A A) { return new A(A); }
}
@YuukiARIA
YuukiARIA / gist:8185507
Created December 30, 2013 18:03
循環リスト
環状リストです。
+----+
| |
[0] |
| |
[1] |
| |
[2] |
@YuukiARIA
YuukiARIA / list_link.cpp
Created December 30, 2013 19:37
list link
@YuukiARIA
YuukiARIA / swap.cpp
Created April 18, 2014 08:59
C++ swap
#include <cstdio>
using namespace std;
void swap(int &a, int &b)
{
int t = a;
a = b;
b = t;
}
@YuukiARIA
YuukiARIA / swap.java
Last active August 29, 2015 14:00
Java swap
public class Main
{
private static void swap(Integer a, Integer b) // Integer使って参照(共有)渡し
{
Integer t = a;
a = b;
b = t;
}
public static void main(String[] args)
use strict;
use warnings;
use List::Util qw/sum reduce/;
use Test::More;
sub sample1 {
my ( $a, $b ) = @_;
if ( !$a && !$b ) {
package sandbox;
class First
{
public static Second setName(String name)
{
return new Second(name);
}
}
@YuukiARIA
YuukiARIA / lambda.rb
Created April 11, 2015 21:00
work in progress
module Church
Z = -> (s) { -> (z) { z } }
SUCC = -> (x) { -> (s) { -> (z) { s[x[s][z]] } } }
ADD = -> (x) { -> (y) { -> (s) { -> (z) { y[s][x[s][z]] } } } }
def value(x, succ: -> (n) { n + 1 }, unit: 0)
x[succ][unit]
end
end
module Peano
O = [].freeze
def succ(n)
n | [n]
end
def pred_rec(n, p, q)
if n == p
q