Skip to content

Instantly share code, notes, and snippets.

Matsushima, Kazuhiro Gab-km

Block or report user

Report or block Gab-km

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Gab-km
Gab-km / fizzbuzz.scala
Last active Aug 29, 2015
Scala で Active Patterns っぽいことやってみた
View fizzbuzz.scala
class FizzBuzzExtractor[T](f: T => Boolean){
def unapply(t: T) = f(t)
}
val FizzBuzz = new FizzBuzzExtractor[Int](_ % 15 == 0)
object Fizz extends FizzBuzzExtractor[Int](_ % 3 == 0)
object Buzz extends FizzBuzzExtractor[Int](_ % 5 == 0)
object FizzBuzzRunner {
def run(num: Int) = num match {
@Gab-km
Gab-km / 00_fsharp_tips_for_newbies.rst
Last active Aug 29, 2015
F# Tips inspired by @kmizu's Scala Tips for newbies
View 00_fsharp_tips_for_newbies.rst

これは、 @kmizu さんの「初学者向けの Scala Tips」を勝手に F# にポートした記事です。

@Gab-km
Gab-km / Callable.fs
Last active Aug 29, 2015
This is a sample implementation of Callable in F#.
View Callable.fs
// Interface
type ICallable<'a, 'b> =
abstract member callback: 'a -> 'b
// concrete class
type Callable<'a, 'b>(f: 'a -> 'b) =
interface ICallable<'a, 'b> with
member self.callback x = f x
// computation builder
@Gab-km
Gab-km / mongodb.ps1
Created Jun 3, 2014
MongDB の C# Driver を PowerShell から使ってみた
View mongodb.ps1
[System.Reflection.Assembly]::LoadFile('/path/to/MongoDB.Driver.dll')
[System.Reflection.Assembly]::LoadFile('/path/to/MongoDB.Bson.dll')
$client = New-Object MongoDB.Driver.MongoClient("mongodb://hostname")
$server = $client.GetServer()
$db = $server.GetDatabase("test")
$user = $db.GetCollection("User")
foreach($doc in $user.FindAll() {
[System.Console]::WriteLine($doc)
View CoYoneda.fs
namespace FSharp.Monad
type CoYoneda<'U> =
abstract Run: obj -> 'U
type CoYoneda<'F, 'A>(fi: 'F, k: CoYoneda<'A>) = class end
module CoYoneda =
let apply fa k =
@Gab-km
Gab-km / mailboxProcessorSample.fs
Created Aug 6, 2014
MailboxProcessor<'Message> の調べ物
View mailboxProcessorSample.fs
type Message = string * AsyncReplyChannel<string>
let agent = new MailboxProcessor<Message>(fun inbox ->
let rec loop count =
async {
System.Threading.Thread.Sleep(1000) // something busy
let! msg, replyChannel = inbox.Receive()
printfn "%s" msg
replyChannel.Reply(msg + msg)
return! loop (count + 1)
View gist:afc2db9d6503004f6ed1
namespace FsCheck.Ext
module Test =
open System
open FsCheck
open FsCheck.Arb
type JapaneseChar = char
let japaneseChar (s: string) =
@Gab-km
Gab-km / concurrentProgramming_head.rst
Last active Aug 29, 2015
公式チュートリアルである "Getting Started with Erlang User's Guide" の翻訳 - Concurrent Programming (翻訳中)
View concurrentProgramming_head.rst
@Gab-km
Gab-km / dict.py
Last active Aug 29, 2015
2つの dict の和を取る関数(キー重複は後勝ち)
View dict.py
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 / Adder.java
Created Oct 20, 2014
高階関数とインターフェイス
View Adder.java
class Adder implements Applyable {
@override
public int func(int a, int b) {
return a + b;
}
}
You can’t perform that action at this time.