PE: Starting ch4 exercises.
This commit is contained in:
parent
6220e18137
commit
e05f92d764
|
@ -1,5 +1,5 @@
|
||||||
-module(chapter4).
|
-module(chapter4).
|
||||||
-export([t2l/1, timeit/1]).
|
-export([t2l/1, timeit/1, date_string/0]).
|
||||||
% 2. The BIF tuple_to_list(T) converts the elements of the tuple T to
|
% 2. The BIF tuple_to_list(T) converts the elements of the tuple T to
|
||||||
% a list. Write a function called my_tuple_to_list(T) that does the
|
% a list. Write a function called my_tuple_to_list(T) that does the
|
||||||
% same thing only not using the BIF that does this.
|
% same thing only not using the BIF that does this.
|
||||||
|
@ -25,6 +25,12 @@ timeit(F) ->
|
||||||
F(),
|
F(),
|
||||||
{erlang:system_time(microsecond) - Started, microsecond}.
|
{erlang:system_time(microsecond) - Started, microsecond}.
|
||||||
|
|
||||||
|
date_string() ->
|
||||||
|
{Hour, Minute, Second} = erlang:time(),
|
||||||
|
{Year, Month, Day} = erlang:date(),
|
||||||
|
io:format("~w-~2..0w-~2..0w ~2..0w:~2..0w:~2..0w",
|
||||||
|
[Year, Month, Day, Hour, Minute, Second]).
|
||||||
|
|
||||||
% 4. Advanced: Look up the manual pages for the Python datetime
|
% 4. Advanced: Look up the manual pages for the Python datetime
|
||||||
% module. Find out how many of methods in the Python datetime class
|
% module. Find out how many of methods in the Python datetime class
|
||||||
% can be implemented using the time-related BIFs in the erlang
|
% can be implemented using the time-related BIFs in the erlang
|
||||||
|
|
Loading…
Reference in New Issue