Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/Comma-quibbling/Prolog/comma-quibbling-1.pro
Normal file
18
Task/Comma-quibbling/Prolog/comma-quibbling-1.pro
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
words_series(Words, Bracketed) :-
|
||||
words_serialized(Words, Serialized),
|
||||
atomics_to_string(["{",Serialized,"}"], Bracketed).
|
||||
|
||||
words_serialized([], "").
|
||||
words_serialized([Word], Word) :- !.
|
||||
words_serialized(Words, Serialized) :-
|
||||
append(Rest, [Last], Words), %% Splits the list of *Words* into the *Last* word and the *Rest*
|
||||
atomics_to_string(Rest, ", ", WithCommas),
|
||||
atomics_to_string([WithCommas, " and ", Last], Serialized).
|
||||
|
||||
|
||||
|
||||
test :-
|
||||
forall( member(Words, [[], ["ABC"], ["ABC", "DEF"], ["ABC", "DEF", "G", "H"]]),
|
||||
( words_series(Words, Series),
|
||||
format('~w ~15|=> ~w~n', [Words, Series]))
|
||||
).
|
||||
6
Task/Comma-quibbling/Prolog/comma-quibbling-2.pro
Normal file
6
Task/Comma-quibbling/Prolog/comma-quibbling-2.pro
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
?- test.
|
||||
[] => {}
|
||||
[ABC] => {ABC}
|
||||
[ABC,DEF] => {ABC and DEF}
|
||||
[ABC,DEF,G,H] => {ABC, DEF, G and H}
|
||||
true.
|
||||
Loading…
Add table
Add a link
Reference in a new issue