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
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; | |
} |
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
<?php | |
class Introduce { | |
private $arraylist = array(); | |
public function regist($num) { | |
$this->arraylist[] = $num; |
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
// 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) | |
} |
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
// http://blog.64p.org/entry/2016/09/30/014358 | |
// | |
// orelang を Groovy で実装してみた | |
// | |
// "わりとよくある JSON ベースの lisp っぽいインタープリタの実装ですが、コードを見ていてもよくわからなかったので自分で実装しなおしてみました。" | |
// | |
class OreLang { | |
Map<String, Object> vars = [:] |
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
//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))))) }} |
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
plus={ a, b -> a + b } | |
minus={ a, b -> a - b } | |
multiply={ a, b -> a * b } | |
div={ a, b -> a / b } |