PageRenderTime 224ms CodeModel.GetById 168ms app.highlight 2ms RepoModel.GetById 53ms app.codeStats 0ms

/core/engine/tools.erl

http://erlbattle.googlecode.com/
Erlang | 31 lines | 20 code | 8 blank | 3 comment | 3 complexity | 4524ddfe958bdc10bb28941831963165 MD5 | raw file
 1-module(tools).
 2-export([sleep/1,getLongDate/0,keyfind/3,for/3]).
 3
 4%% Sleep ????
 5sleep(Sleep) ->
 6	receive
 7	
 8	after Sleep -> true
 9    
10	end.
11	
12getLongDate() ->
13	{MegaSecs, Secs, MicroSecs} = now(),
14	Seed = 1000 * 1000,
15	(MegaSecs * Seed + Secs) *Seed + MicroSecs.
16	
17%% ????
18keyfind(Key, N, List) ->
19	
20	case lists:keysearch(Key, N, List) of
21		
22		false -> false;
23		{_Val, Result} -> Result;
24		_ELSE -> false
25	end.
26
27%% ????for ????
28for(I, I, Fun) -> Fun(I);	
29for(I, N, Fun) ->
30	Fun(I),
31	for(I+1, N, Fun).