Skip to content

Instantly share code, notes, and snippets.

@Gab-km
Gab-km / assertSeqEquals.fs
Last active April 8, 2016 02:35
Persimmon の暫定的な assertSeqEquals を書いてみた
(*
* The MIT License (MIT)
*
* Copyright (c) 2016 Kazuhiro Matsushima
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the
* Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
@Gab-km
Gab-km / factorialNumberSystem.fs
Created March 17, 2016 01:44
何をやりたいか分からなくなってきたので放流する
let rec factorial n =
match n with
| 0 | 1 -> 1
| _ -> n * (factorial (n - 1))
type FactorialNumber(num: int) =
let infactorials = Seq.initInfinite <| fun i -> factorial (i+1)
let range = Seq.takeWhile (fun fc -> fc <= num) infactorials |> Seq.toList
let rec factSystemize n fcs acc =
match fcs with
@Gab-km
Gab-km / decorator.py
Created September 30, 2013 01:18
賢明なる Pythonista の諸兄に於かれましては、どちらの書き方をなさいますでしょうか。
# -*- coding: utf-8 -*-
def class_extender(cls):
def __init__(self, value):
self.value = value
cls.__init__ = __init__
return cls
@class_extender
class Hoge:
@Gab-km
Gab-km / fake_undefined.fs
Created August 6, 2013 12:24
Haskell の undefined の真似事
let undefined _ = failwith "undefined"
let hoge (x : string) : int = undefined()
@Gab-km
Gab-km / IOSample.fs
Last active December 17, 2015 08:39
人様の作品をいじっているだけです
open System
//============================================
// IOモナド
//============================================
module IO =
type IO<'a> = IO of (unit -> 'a)
type IOBuilder() =
member this.Bind (IO x, f) = f (x())
@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
@Gab-km
Gab-km / ConsolePrinter.fs
Created December 15, 2015 08:28
何かのコード
module ConsolePrinter =
open System.Text
open System.ComponentModel
[<EditorBrowsable(EditorBrowsableState.Never)>]
let private bit mask b =
b &&& mask = mask
[<EditorBrowsable(EditorBrowsableState.Never)>]
let private bit0 = bit 0b00000001uy
@Gab-km
Gab-km / indentGuidelineWithFSharp.rst
Created March 18, 2013 08:47
「F# のインデントガイドライン」を読んで、自分のインデントルールを書いてみた。

「F# のインデントガイドライン」に寄せて

今朝、 F# のインデントガイドライン という記事がアップされてました。大変興味深い内容だったんですが、ちょっと時間がなくて反応ができなかったんで、今やってしまおうと思います。

今回の概要としては、単純に「僕はこんなインデントルールでやってるよ!」という差分を紹介しよう、というものです。そのため、思想の一致を見るルールについては特に取り上げないこととします。

インデントの基本ルール

@Gab-km
Gab-km / gifts.fs
Created December 15, 2015 00:42
某所のアレをやってみた
type Family = Blair | Smith | Kelly | Tavares | Chen | Singh
type Person = { First: string; Last: Family }
let blair's first = { First = first; Last = Blair }
let smith's first = { First = first; Last = Smith }
let kelly's first = { First = first; Last = Kelly }
let tavares' first = { First = first; Last = Tavares }
let chen's first = { First = first; Last = Chen }
let singh's first = { First = first; Last = Singh }