This file contains hidden or 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
module Toy.Rot13 (encrypt) where | |
import Data.Char | |
lowerA = ord 'a' | |
lowerZ = ord 'z' | |
upperA = ord 'A' | |
upperZ = ord 'Z' |
This file contains hidden or 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
module Parupunte ((+), (*)) where | |
import qualified Prelude | |
(+) = (Prelude.*) | |
(*) = (Prelude.+) |
This file contains hidden or 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 | |
Ginq::range(1,10) | |
->selectManyWith( | |
function($x) { if ($x % 2 == 0) return [null]; else return []; }, | |
function($x) { return $x; }); | |
This file contains hidden or 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 | |
// 巻き戻しできないデータソース | |
function dbFetch() { | |
... | |
yield $row; | |
... | |
} | |
// ごにょごにょしたのをメモ化 | |
// もちろんこの段階ではまだ何も起らない |
This file contains hidden or 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 DefaultEqualityComparer implements EqualityComparer | |
{ | |
public function equals($v0, $v1, $k0, $k1) | |
{ | |
// オブジェクト | |
// (==) に委譲 | |
// 同一でなく同値。全フィールドが一致? | |
if (is_object($v0) && is_object($v1)) { |
This file contains hidden or 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 | |
/** | |
* toDictonary | |
* 廃止 | |
* @deprecated | |
* @param \Closure $valueSelector | |
* @param \Closure $keySelector | |
* @param \Closure $combiner | |
* @return array |
This file contains hidden or 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
{-# LANGUAGE XNoMonomorphismRestriction #-} | |
import Control.Monad | |
newtype Foo m a b = Foo (m a -> (a -> m b)) | |
instance (Monad m) => Monoid (Foo m a b) where | |
mempty = return | |
mappend x y = x <=< y |
This file contains hidden or 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 | |
public function equals($v0, $v1) | |
{ | |
if (is_array($v0) && is_array($v1)) { | |
return $v0 === $v1; | |
// 配列 | |
// キーと値すべてが一致 | |
} | |
if (is_object($v0) && is_object($v1)) { | |
return $v0 == $v1; |
This file contains hidden or 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 Decoder<A> { | |
decode(source: string): A; | |
} | |
class NumDecoder implements Decoder<Number> { | |
decode(source: string): Number { | |
return Number(source.trim()); | |
} | |
} |
This file contains hidden or 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 | |
/** | |
* @property float $x_of_pos | |
* @property float $y_of_pos | |
*/ | |
class GlobalPosition | |
{ | |
public $x_of_pos; | |
public $y_of_pos; |