Skip to content

Instantly share code, notes, and snippets.

@Gab-km
Gab-km / robustness_head.rst
Last active August 29, 2015 14:08
公式チュートリアルである "Getting Started with Erlang User's Guide" の翻訳 - Robustness (翻訳中)
@Gab-km
Gab-km / TestBuilder.fs
Last active August 29, 2015 14:07
テストをコンピュテーション式で書けないか、という思考実験
// コンピュテーション式中で用いる型
type AssertionResult<'T> =
| NotAsserted of 'T
| Success
| Failure of string
// コンピュテーションビルダー
type TestBuilder() =
member self.Bind(x, f) =
match x with
@Gab-km
Gab-km / Applyable.java
Last active August 29, 2015 14:07
カリー化とインターフェイス
// TVar -> TResult
interface Applyable<TVar, TResult> {
public abstract TResult apply(TVar variable);
}
@Gab-km
Gab-km / Adder.java
Created October 20, 2014 13:47
高階関数とインターフェイス
class Adder implements Applyable {
@override
public int func(int a, int b) {
return a + b;
}
}
@Gab-km
Gab-km / obsolete.py
Last active July 31, 2017 04:12
C# の Obsolete 属性を Python に持ち込んでみた。
def obsolete(message=None, deprecated=False):
"""今後使用しない関数やメソッドにマークを付けます。
@message 警告に表示するテキスト
@deprecated すでに非推奨の場合、True
今後非推奨になる予定の場合、False
@see http://msdn.microsoft.com/ja-jp/library/system.obsoleteattribute.aspx
"""
def outer(fn):
import warnings
def inner(*args, **kwargs):
@Gab-km
Gab-km / dict.py
Last active August 29, 2015 14:07
2つの dict の和を取る関数(キー重複は後勝ち)
def add_dict(this, other):
"""2つの dict の和を取る関数(キー重複は後勝ち)
@this ベースとなる dict オブジェクト
@other 追加される dict オブジェクト
@return 2つの dict を合成した dict
"""
result = this.copy()
for key in other:
result[key] = other[key]
return result
@Gab-km
Gab-km / concurrentProgramming_head.rst
Last active August 29, 2015 14:07
公式チュートリアルである "Getting Started with Erlang User's Guide" の翻訳 - Concurrent Programming (翻訳中)
@Gab-km
Gab-km / sequencialProgramming_head.rst
Last active December 17, 2015 03:05
公式チュートリアルである "Getting Started with Erlang User's Guide" の翻訳 - Sequential Programming
@Gab-km
Gab-km / introduction_head.rst
Last active December 17, 2015 00:48
公式チュートリアルである "Getting Started with Erlang User's Guide" の翻訳 - Introduction
namespace FsCheck.Ext
module Test =
open System
open FsCheck
open FsCheck.Arb
type JapaneseChar = char
let japaneseChar (s: string) =