Amazon.co.jpをご利用いただき、ありがとうございます。
誠に申し訳ありませんが、お客様にご注文いただいた以下の商品が、仕入先から入荷の見込みがないことがわかりましたため、
やむを得ずご注文のキャンセルをさせていただきました。
Geoff Cant "Mastering Erlang: Writing Real World Applications"
Dear Customer: When we contacted our supplier we learned that the above item is no longer available. This unavailable item has been cancelled from your order. We apologize for this inconvenience.
あちこちのECサイトから消えているみたいだし、一体何が起きたんだろう?!
cooldaemon2010/06/12 22:15駄目もとで、購入可能になったらメールが来るようにしてみました orz
最近OCamlとPythonばっかり書いててちっともErlangに触れていないのですが、BERTを普及させるためにOCaml-BERTというのを書いています。きったねーロゴまで頑張って作ったので、我こそはという型は一緒に推論しm…もとい、我こそはという方は一緒に書きませんか?
こんなメール送ってみたよ
I'm writing a self-configuring node cluster with net_kernel:start/1.
It starts without -name nor -sname option and gets its IP adress from inet:getif/0.
And they configure themselves with net_kernel:start/1 as follows:
net_kernel:start( [ 'appname@192.168.0.22', longnames ] ).
Servers find each other by sending its longname by UDP broadcasting, and they connects each other.
The problem is, starting erl without -name option it doesn't kick epmd and following net_kernel:start/1 fails in tcp_inet_dist:listen (maybe because of epmd not running).
And another way - starting with -name option with bad ip address ( or local ip) makes net_kernel:start/1 result in {error, not_allowed}.
Is it a wrong to think that if epmd would start when net_kernel:start/1 had been called, isn't it?
いっつも忘れちゃうので。
The environment should be set up in the usual way for building Erlang/OTP.
Documentation - otp - GitHub
git pull origin dev
git checkout dev
./otp_build autoconf
./configure --enable-darwin-64bit
make
ファイルを削除するので…ま、どれも失敗の記録です。こんな風に試行錯誤したログ。
Y = \f.(\x.f(x x))(\x.f(x x)) Y g = (\x.g(x x))(\x. g(x x)) = g(\x.g(x x) \x.g(x x)) -> \g.g(\x.g(x x) )(\x.g(x x))??? Fa= fun(Fact)-> fun(1)->1; (N)-> N * Fact(N-1) end end. Y = fun(F)-> (fun(X)->F( X(X) ) end)(fun(X)->F(X(X)) end) end. Y(Fa) --> (fun(X)->Fa(X(X)) end)(fun(X)->Fa(X(X)) end ) --> Fa( (fun(X)->Fa(X(X))end)(fun(X)->Fa(X(X)) end) ) --> Fa( Fa( (fun(X)->Fa(X(X))end)(fun(X)->Fa(X(X)) end) ) ) Y = fun(F)-> (fun(X)->F(X(X)) end)(fun(X)->F(X(X))) end) end fun(G)-> G(( fun(X)->F(X(X)) end)( fun(X)->F(X(X)) end)) end <( fun(X)->F(X(X)) end)( fun(X)->F(X(X)) end)> (Y(Fa))(10) --> (<(fun(X)->Fa(X(X))end)(fun(X)->Fa(X(X)) end)>(G))(10) (Y(Fa))(10) --> (Fa( (fun(X)->Fa(X(X))end)(fun(X)->Fa(X(X)) end) ))(10) --> 10 * ( Fa( (fun(X)->Fa(X(X))end)(fun(X)->Fa(X(X)) end) ) )(9) --> 10 * (fun(X)->Fa(X(X))end)(fun(X)->Fa(X(X)) end) --> 10 * (Y(Fa))(9). --> 10 * Fa( (fun....) Y = fun(F)-> (fun(X)-> F(X (X)) end)(fun(X)->F(X(X))) end. Y = fun(F)-> fun(N)-> (fun(X)-> (F(X (X)))(N) end)(fun(X)->F(X(X)) end ) end end. Y = fun(F,N)-> (fun(X,M)->F(X(X,M),M) end)(fun(X,M)->F(X(X,M),M) end, N) end. Fa = fun(_,1)->1; (Fact,N)->N*Fact(Fact,N-1) end. Y = fun(F)-> fun(N)-> (fun(X)->F( fun(M)->X(X) end ) end)(fun(X)->F(fun(M)-> X(X) end) end) end end. Fa = fun(_,1)->1; (Fact,N)->N*Fact(Fact,N-1) end. Fa = fun(_, 1)->1; (Fact,N)-> N*Fact(Fact,N-1) end. Y = fun(F, N)-> (fun(X,M)-> F( X(X), M) end)( fun(X,M)-> F(X(X),M) end, N) end Y(Fa, 10) --> (fun(X)-> Fa( X(X), 10) end)( fun(X)-> Fa(X(X), 10) end). --> Fa( (fun(X)-> Fa((X),10) end)(fun(X)->Fa((X),10) end), 10) --> 10 * ((fun(X)-> Fa((X),10) end)(fun(X)->Fa((X),10) end)(9) Fa = fun(1)-> fun(_)-> 1 end; (N)-> fun(Fact)-> N * Fact(N-1) end end. Y = fun(N)-> fun(F)-> (fun(X)->(F(N))(X(X)) end)(fun(X)->(F(N))(X(X)) end) end end. (Y(10))(Fa) --> ( fun(F)-> (fun(X)-> (F(10))(X(X)) end)(fun(X)-> (F(10))(X(X)) end) end ) --> ( fun(X)-> (Fa(10))(X(X)) end)(fun(X)-> (Fa(10))(X(X)) end) Fa = fun(Fact)-> fun(1)->1; (N)-> N * Fact(N-1) end end. Y = fun(F)->fun(N)-> ((fun(X)-> fun(M)-> (F(X(X)))(M) end end)(fun(X)-> fun(M)-> (F(X(X)))(M) end end))(N) end end
OCamlだとちょっとずるだけどこう:
let fib f n = if n=1 then 1 else n * f(n-1);; let rec y f x = f (y f) x;;
こんどこそ。うごいたよー。もうソラで書けるようになったもんねー。
Y = fun(F)->fun(Argv)->((fun(X)->fun(Argvv)->(F(X(X))(Argvv)end end)(fun(X)->fun(Argvv)->(F(X(X))(Argvv)end end))(Argv)end end.
間違ってはいないけどこれは冗長。正しくはこう:
Y = fun(F)->(fun(X)->fun(Argv)->(F(X(X))(Argv)end end)(fun(X)->fun(Argv)->(F(X(X))(Argv)end end)end.
頑張って書いて動いた!と思ったら、指摘をいただいて問題アリアリなことに気付いたので let rec y f x = f (y f) x;;を意識して書き直してみた。Erlangで高階関数書くのめんどい。funのタイプが速くなったけどfunctionは相変わらずうまくタイプできない。
-module(yc). -compile(export_all). y(F)-> fun(X)-> (F( y(F)))(X) end. do(N)-> F = fun(Fact)-> fun (1)-> 1; (X)-> X* Fact(X-1) end end, (y(F))(N).
あれ、よくみたらyの定義が冗長じゃん、とおもって
y(F)-> F( y(F)).
って書いたら動かなかった、じゃない停止しなかった。これだとdo/1の奥の方でX-1を評価していく前に y(F) が永遠に再帰してしまって終わらない(のでボツ)。
なので、元のコードでtype/specちゃんと書くとこんな風になる:
-module(yc). -compile(export_all). -spec f( Fact::fun( (integer())-> integer() ) )-> fun((integer())-> integer()). f(Fact)-> fun (1)-> 1;(X)-> X*Fact(X-1) end. -spec y( F::fun( (fun((TypeA)-> TypeB)) -> fun((TypeA)-> TypeB) ))-> fun((TypeA)->TypeB). y(F)-> fun(X)-> (F( y(F)))(X) end. -spec do(integer())-> integer(). do(N)-> (y(fun f/1))(N).
y(fun f/1)ってのがどうにもErlangっぽくてイケてないよなぁ。念には念を入れて型の確認のためtyperにかけてみたらちゃんとパスした。
> $ typer yc.erl [kuenishi@shuna.local:~] %% File: "yc.erl" %% -------------- -spec f(Fact::fun((integer()) -> integer())) -> fun((integer()) -> integer()). -spec y(F::fun((fun((TypeA) -> TypeB)) -> fun((TypeA) -> TypeB))) -> fun((TypeA) -> TypeB). -spec do(integer()) -> integer().
おかしいところは一応ないみたい。しかしパターンマッチのほとんどない状況で関数型言語使ってると、ワンライナーで書きたくなってついつい一行が長くなるのは悪いクセだな。
というわけで、ついカッとなって作ってしまったツール第二弾、です。さすがweekend programmerだけあって車輪の再発明が得意なようですね>自分
Inspired by OMake with its '-P' option, continuous build.
Inspired by MochiWeb with its reloader.erl, continuous test.
kuenishi's permake at master - GitHub
将来の夢はotpのソースツリーにマージしてもらうことです。これがotpの基本セットに入ってたら気軽に開発できるようになると思うんだよなぁ。
第四回 Erlang 分散システム勉強会の前説と本番に参加して、いろいろ勉強し、私もそこでYatceの話をしてきました。
第四回 Erlang 分散システム勉強会で発表してきたよ - Tokyo Erlang Workshop #4 - amnesiac weekend programmer
→自分で調べたらええやん。
erts_debug:flat_size(Term).
Nabble - Erlang Questions - proplists vs. dicts memory usage