Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
25
Task/Amb/Mercury/amb-1.mercury
Normal file
25
Task/Amb/Mercury/amb-1.mercury
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
:- module amb.
|
||||
:- interface.
|
||||
:- import_module io.
|
||||
:- pred main(io::di, io::uo) is cc_multi.
|
||||
:- implementation.
|
||||
:- import_module list, string, char, int.
|
||||
|
||||
main(!IO) :-
|
||||
( solution(S) -> io.write_string(S, !IO), io.nl(!IO)
|
||||
; io.write_string("No solutions found :-(\n", !IO) ).
|
||||
|
||||
:- pred solution(string::out) is nondet.
|
||||
solution(S) :-
|
||||
member(A, ["the", "that", "a"]),
|
||||
member(N, ["frog", "elephant", "thing"]),
|
||||
member(V, ["walked", "treaded", "grows"]),
|
||||
member(E, ["slowly", "quickly"]),
|
||||
S = join_list(" ", [A, N, V, E]),
|
||||
rule1(A, N), rule1(N, V), rule1(V, E).
|
||||
|
||||
:- pred rule1(string::in, string::in) is semidet.
|
||||
rule1(A, B) :- last_char(A) = C, first_char(B, C, _).
|
||||
|
||||
:- func last_char(string::in) = (char::out) is semidet.
|
||||
last_char(S) = C :- index(S, length(S) - 1, C).
|
||||
6
Task/Amb/Mercury/amb-2.mercury
Normal file
6
Task/Amb/Mercury/amb-2.mercury
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
:- pred noun(string).
|
||||
:- mode noun(out) is multi. % provide any one noun.
|
||||
:- mode noun(in) is semidet. % fail if given string isn't a known noun.
|
||||
noun("frog").
|
||||
noun("elephant").
|
||||
noun("thing").
|
||||
Loading…
Add table
Add a link
Reference in a new issue