bloop
This commit is contained in:
parent
835eeefc0a
commit
7797aa4002
4 changed files with 70 additions and 59 deletions
17
aoc.m
17
aoc.m
|
@ -6,31 +6,28 @@
|
|||
|
||||
:- implementation.
|
||||
:- import_module basics.
|
||||
:- import_module die.
|
||||
:- import_module string.
|
||||
:- import_module list.
|
||||
:- import_module exception.
|
||||
|
||||
main(!IO) :- wrap_main(main2, !IO).
|
||||
|
||||
:- pred main2(io::di, io::uo) is cc_multi.
|
||||
:- pragma no_determinism_warning(main2/2).
|
||||
:- pred main2(io::di, io::uo) is det.
|
||||
main2(!IO) :-
|
||||
command_line_arguments(Args, !IO),
|
||||
(if (Args = [DayS, PartS | Rest],
|
||||
to_int(DayS, Day),
|
||||
part(PartS, Part))
|
||||
then
|
||||
(if Args = [DayS, PartS | Rest],
|
||||
to_int(DayS, Day),
|
||||
part(PartS, Part) then
|
||||
run(Day, Part, Rest, !IO)
|
||||
else if Args = [D, P | _] then
|
||||
die("expected a day and a part, got ""%s"" ""%s""", [s(D), s(P)])
|
||||
else
|
||||
die("expected at least two args")).
|
||||
|
||||
:- type solution == (pred(part, list(string), io, io)).
|
||||
:- inst solution == (pred(in, in, di, uo) is det).
|
||||
:- type sol == (pred(part, list(string), io, io)).
|
||||
:- inst sol == (pred(in, in, di, uo) is det).
|
||||
|
||||
:- pred solution(int::in, solution::out(solution)) is semidet.
|
||||
:- pred solution(int::in, sol::out(sol)) is semidet.
|
||||
:- import_module day1.
|
||||
solution(1, day1.run).
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue