kgbu #7035(2008/08/07 04:02 GMT) [ Erlang ] Rating1/1=1.00
大元になる日付のリストは素直に1日ごとのものを生成しています。 escript ファイル名 として実行します。 実行結果例(2008/8/7に実行) [{2009,2,13}, {2009,3,13}, {2009,11,13}, {2010,8,13}, {2011,5,13}, {2012,1,13}, {2012,4,13}, {2012,7,13}, {2013,9,13}, {2013,12,13}] 10 days
1 2 3 4 5 6 7 8
main(_) -> L=a(date(),{2013,12,31}), M=[{X,Y,13} || {X,Y,13} <- L, calendar:day_of_the_week({X,Y,13}) =:= 5], io:format("~p~n~p days~n", [M, length(M)]). a(X,X) -> [X]; a(X,Y) -> [X] ++ a(calendar:gregorian_days_to_date( calendar:date_to_gregorian_days(X)+1),Y).
Rating1/1=1.00-0+
1 reply [ reply ]
kgbu #7035() [ Erlang ] Rating1/1=1.00
大元になる日付のリストは素直に1日ごとのものを生成しています。 escript ファイル名 として実行します。 実行結果例(2008/8/7に実行) [{2009,2,13}, {2009,3,13}, {2009,11,13}, {2010,8,13}, {2011,5,13}, {2012,1,13}, {2012,4,13}, {2012,7,13}, {2013,9,13}, {2013,12,13}] 10 daysmain(_) -> L=a(date(),{2013,12,31}), M=[{X,Y,13} || {X,Y,13} <- L, calendar:day_of_the_week({X,Y,13}) =:= 5], io:format("~p~n~p days~n", [M, length(M)]). a(X,X) -> [X]; a(X,Y) -> [X] ++ a(calendar:gregorian_days_to_date( calendar:date_to_gregorian_days(X)+1),Y).Rating1/1=1.00-0+
1 reply [ reply ]