Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View 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).

View 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").