Skip to content

Instantly share code, notes, and snippets.

View koji-k's full-sized avatar

koji koji-k

  • Germany
View GitHub Profile
@fumokmm
fumokmm / CalcOperator.properties
Created December 9, 2012 17:26
動的プロパティ読み込みクラス in Groovy
plus={ a, b -> a + b }
minus={ a, b -> a - b }
multiply={ a, b -> a * b }
div={ a, b -> a / b }
//Zコンビネータ
//再帰する関数を定義するのに使う
ZCONB = { f -> ({ x -> f({ y -> x(x)(y) }) })({ x -> f({ y -> x(x)(y) }) }) }
//数の定義
ZERO = { f -> { x -> x }}
ONE = { f -> { x -> f(x) }}
THREE = { f -> { x -> f(f(f(x))) }}
FIVE = { f -> { x -> f(f(f(f(f(x))))) }}
// http://blog.64p.org/entry/2016/09/30/014358
//
// orelang を Groovy で実装してみた
//
// "わりとよくある JSON ベースの lisp っぽいインタープリタの実装ですが、コードを見ていてもよくわからなかったので自分で実装しなおしてみました。"
//
class OreLang {
Map<String, Object> vars = [:]
@Dierk
Dierk / Either.groovy
Created January 20, 2017 09:41
Either type in Groovy as a special implementation of the generic sum type (works the same in Java)
// Either type in Groovy as a special implementation of the generic sum type
// see: Phil Wadler at LambdaWorld 2016: youtu.be/V10hzjgoklA
import java.util.function.*
import groovy.transform.*
interface Either<A,B> {
public <C> C match (Function <A,C> leftCase, Function <B,C> rightCase)
}
<?php
class Introduce {
private $arraylist = array();
public function regist($num) {
$this->arraylist[] = $num;
@wreulicke
wreulicke / Sample.java
Created February 28, 2017 17:19
委譲メモ
interface SomeService{
public void fire(String parameter){}
}
// pattern 1 複数のクラスに委譲
class DelegatingSomeService implements SomeService{
private List<SomeService> services;
public DelegatingSomeService(List<SomeService> service){
this.services=service;
}