Search posterous

Search all posts and users. Type a name, type a favorite song title, whatever! See what comes up.
  

More posterous blogs











More recommended blogs »

Here are posterous posts filed under erlang...

IRR says...

http://bitbucket.org/will/epgsql/overview/

http://glozer.net/src/epgsql_pool/
(http://www.erlangatwork.com/2009/01/erlang-and-postgresql-redux.html)

Filed under: erlang

wk says...

Click here to download:
zeez2.erl (0 KB)

พิมพ์ตัว Z ออกมาเฉยๆ
-module(zeez2).
-export([main/1]).

main([A]) ->
	L = list_to_integer(atom_to_list(A)),
	zeez( true ,L, L).
zeez(true, 0, N) ->
	io:format("~p~n", [zeez(z, N)]),
	init:stop();
zeez(false, M, N) ->
	io:format("~p~n", [zeez(space, M)]),
	zeez(M-1 rem N =:= 0, M-1, N );
zeez(true, M, N) ->
	io:format("~p~n", [zeez(z, M)]), 
	zeez(M-1 rem N =:= 0, M-1 , N ).
zeez(space, 0) ->
	"Z";
zeez(space, N) ->
	"-" ++ zeez(space, N-1);
zeez(z,0) ->
	"Z";
zeez(z, N) ->
	"Z" ++ zeez(z, N-1).
wk# erlc zeez2.erl
wk# erl -noshell -s zeez2 main 10
"ZZZZZZZZZZZ"
"---------Z"
"--------Z"
"-------Z"
"------Z"
"-----Z"
"----Z"
"---Z"
"--Z"
"-Z"
"ZZZZZZZZZZZ"
wk# 

Filed under: erlang

wk says...

Click here to download:
cal.erl (0 KB)
พิมพ์วันทั้งหมดที่มีในปีนี้

-module(cal).
-export([main/0]).

main() ->
	StartSec = calendar:datetime_to_gregorian_seconds({{2009,1,1},{0,0,0}}),
	EndSec = calendar:datetime_to_gregorian_seconds({{2009,12,31},{0,0,0}}),
	run_calendar(StartSec,EndSec).

run_calendar(CurSec, EndSec) -> 
	{Date,_Time} = calendar:gregorian_seconds_to_datetime(CurSec),
	io:format("~p~n", [Date]),
	NewSec = CurSec + 60*60*24,
	if NewSec =< EndSec -> init:stop() end,
	run_calendar(NewSec, EndSec).
wk# erlc cal.erl
wk# erl -noshell -s cal main
{2009,1,1}
{2009,1,2}
{2009,1,3}
---
{2009,12,29}
{2009,12,30}
{2009,12,31}

Filed under: erlang

IRR says...

Some highlights:

  • NIFs, write your own functions in C

  • Builds and runs on Windows 7

  • dialyzer can warn for some race conditions, and has a wx gui

  • The -on_load() directive can be used to run a function when a module is loaded.

  • Emacs erlang-mode improvements.

More: http://erlang.org/download/otp_src_R13B03.readme

Filed under: erlang

IRR says...

Materials from the Erlang User Conference 2009 and Tutorials Workshop at the EUC2009 are now available on our website:

- The presentation slides from the EUC2009 are available (http://www.erlang-factory.com/conference/ErlangUserConference2009/talks)
- The tutorial slides can be found (http://www.erlang-factory.com/conference/testingtutorialworkshop/talks)
- The photos taken at the EUC2009 are (http://www.erlang-factory.com/conference/ErlangUserConference2009#euc2009)
- The photos taken at the Tutorials Workshop are (http://www.erlang-factory.com/conference/testingtutorialworkshop#photos)

If you want to see more photos from the EUC2009 and previous Erlang User Conferences, they are all available on Flickr:  http://www.flickr.com/photos/erlang-consulting/

Filed under: erlang

IRR says...

http://bitbucket.org/adroll/erldis/

Filed under: erlang

IRR says...

http://www.davispj.com/2009/11/23/erlang-nif-test.html

Filed under: erlang

wk says...

Click here to download:
pythag2.erl (0 KB)

คำถาม

A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
a^2 + b^2 = c^2

For example, 3^2 + 4^2 = 9 + 16 = 25 = 52.

There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc

คำตอบ

wk# erlc pythag2.erl 
wk# erl -noshell -s pythag2 main 1000
Pythag 1000 = [{200,375,425}]
Product [{200,375,425}] = 31875000

Filed under: erlang

wk says...

1> Pythag = fun(N) -> [ {A,B,C} ||
   A <- lists:seq(1,N),
   B <- lists:seq(1,N),
   C <- lists:seq(1,N),
   A= Pythag(100).


[{3,4,5}, {5,12,13}, {6,8,10},
 {7,24,25},{8,15,17}, {9,12,15},
 {9,40,41}, {10,24,26}, {12,16,20},
 {12,35,37}, {15,20,25}, {15,36,39},
 {16,30,34}, {18,24,30}, {20,21,29},
 {21,28,35}, {24,32,40}] 


http://en.wikipedia.org/wiki/Pythagorean_theorem

Filed under: erlang

wk says...

ฟังก์ชันสำหรับสร้าง Anagram

 Foo = fun(X) -> Fun = fun([],F) -> [[]]; (L,F) -> [[H|T] || H <- L, T <- F(L--[H],F)] end, Fun(X, Fun) end.


ทดสอบ

wearetherock# erl
Erlang (BEAM) emulator version 5.6.5 [source] [smp:2] [async-threads:0] [kernel-poll:false]
Eshell V5.6.5  (abort with ^G)
1> Foo = fun(X) -> Fun = fun([],F) -> [[]]; (L,F) -> [[H|T] || H <- L, T <- F(L--[H],F)] end, Fun(X, Fun) end.
#Fun<erl_eval.6.13229925>
2> Foo("mary").
["mary","mayr","mray","mrya","myar","myra","amry","amyr",
 "army","arym","aymr","ayrm","rmay","rmya","ramy","raym",
 "ryma","ryam","ymar","ymra","yamr","yarm","yrma","yram"]
3> Foo("cat").
["cat","cta","act","atc","tca","tac"]
4> Foo("orchestra").
["orchestra","orchestar","orchesrta","orchesrat",
 "orchesatr","orchesart","orchetsra","orchetsar","orchetrsa",
 "orchetras","orchetasr","orchetars","orchersta","orchersat",
 "orchertsa","orchertas","orcherast","orcherats","orcheastr",
 "orcheasrt","orcheatsr","orcheatrs","orchearst","orchearts",
 "orchsetra","orchsetar","orchserta","orchserat",
 [...]|...]

Filed under: erlang