Skip to content

Instantly share code, notes, and snippets.

@eldesh
eldesh / fix_fact.sml
Last active December 19, 2015 17:18
圏論勉強会#9 関数 fact の最小不動点を調べる例をSMLで実装 http://nineties.github.io/category-seminar/9.html#/45
(**
* 圏論勉強会#9
*
* 関数 fact の最小不動点を調べる 例をSMLで実装
* http://nineties.github.io/category-seminar/9.html#/45
*
*)
structure Fact =
struct
infixr 1 $
@eldesh
eldesh / banana.sml
Last active December 19, 2015 14:39
圏論勉強会 @ ワークスアプリケーションズ#8 http://nineties.github.io/category-seminar/8.html#/55 練習問題 回答
(**
* 圏論勉強会 @ ワークスアプリケーションズ#8
* http://nineties.github.io/category-seminar/8.html#/55
* 練習問題 回答
*
* 実行方法(for SML/NJ)
* $ cat banana.cm
* group
* is
* $/basis.cm
@eldesh
eldesh / sendmoremoney.sml
Created June 29, 2013 20:59
https://gist.github.com/yonta/5851577#file-sendmoremoney2-sml に触発されて書いてみた。力ずくで解く例。
(**
* SEND
* + MORE
* ------
* MONEY
*
* S,E,N,D,M,O,R,Y
*
* run:
* - Option.app (print o pp) (search ())
@eldesh
eldesh / gist:5714388
Last active December 18, 2015 02:58
De Bruijn変換をStandardMLで実装
(*
* (* debruijn.cm *)
* Group
* is
* $/basis.cm
* debrujn.sml
*)
(**
* De Bruijn変換
@eldesh
eldesh / demo.sml
Last active December 16, 2015 11:19
demonstrate datatype replication declarations of SML'97
(**
* datatype replication declarations(specifications)のサンプル
*)
(** monomorphic version *)
structure S =
struct
datatype either = L | R
end
@eldesh
eldesh / array_unfold.sml
Created September 7, 2012 06:37
Unfolding on Array(fixed size memory block)
(***
* Array, Vector 等の固定長データ構造を生成するために状態を持ちたい。
* unfold すればよいが、要素を一つずつ連結するのはイヤ(重すぎる)なので 配列用unfold 作ってみた
* ***)
infixr 1 $
fun f $ a = f a
structure Array =
@eldesh
eldesh / qcheck_sample.cm
Created June 14, 2012 17:34
QCheck sample solution
library
structure Sample
is
$/basis.cm
$/qcheck.cm
qcheck_sample.sml
@eldesh
eldesh / caesar.sml
Created February 20, 2012 03:38
simple caesar cipher module implemented with SML
(* see. http://d.hatena.ne.jp/a-hisame/20120217/1329499672 *)
(* ===========================================================
* for using
* > sml
* > use "caesar.sml";
* > Caesar.encode "hoge";
* val it = "mtlj" : string
* > _