Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
34
Task/ABC-problem/Logtalk/abc-problem-1.logtalk
Normal file
34
Task/ABC-problem/Logtalk/abc-problem-1.logtalk
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
:- object(blocks(_Block_Set_)).
|
||||
|
||||
:- public(can_spell/1).
|
||||
:- public(spell_no_spell/3).
|
||||
|
||||
:- uses(character, [lower_upper/2, is_upper_case/1]).
|
||||
|
||||
% public interface
|
||||
|
||||
can_spell(Atom) :-
|
||||
atom_chars(Atom, Chars),
|
||||
to_lower(Chars, Lower),
|
||||
can_spell(_Block_Set_, Lower).
|
||||
|
||||
spell_no_spell(Words, Spellable, Unspellable) :-
|
||||
meta::partition(can_spell, Words, Spellable, Unspellable).
|
||||
|
||||
% local helper predicates
|
||||
|
||||
can_spell(_, []).
|
||||
can_spell(Blocks0, [H|T]) :-
|
||||
( list::selectchk(b(H,_), Blocks0, Blocks1)
|
||||
; list::selectchk(b(_,H), Blocks0, Blocks1)
|
||||
),
|
||||
can_spell(Blocks1, T).
|
||||
|
||||
to_lower(Chars, Lower) :-
|
||||
meta::map(
|
||||
[C,L] >> (is_upper_case(C) -> lower_upper(L, C); C = L),
|
||||
Chars,
|
||||
Lower
|
||||
).
|
||||
|
||||
:- end_object.
|
||||
23
Task/ABC-problem/Logtalk/abc-problem-2.logtalk
Normal file
23
Task/ABC-problem/Logtalk/abc-problem-2.logtalk
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
:- object(blocks_test).
|
||||
|
||||
:- public(run/0).
|
||||
|
||||
:- uses(logtalk, [print_message(information, blocks, Message) as print(Message)]).
|
||||
|
||||
run :-
|
||||
block_set(BlockSet),
|
||||
word_list(WordList),
|
||||
blocks(BlockSet)::spell_no_spell(WordList, S, U),
|
||||
print('The following words can be spelled by this block set'::S),
|
||||
print('The following words cannot be spelled by this block set'::U).
|
||||
|
||||
% test configuration data
|
||||
|
||||
block_set([b(b,o), b(x,k), b(d,q), b(c,p), b(n,a),
|
||||
b(g,t), b(r,e), b(t,g), b(q,d), b(f,s),
|
||||
b(j,w), b(h,u), b(v,i), b(a,n), b(o,b),
|
||||
b(e,r), b(f,s), b(l,y), b(p,c), b(z,m)]).
|
||||
|
||||
word_list(['', 'A', 'bark', 'bOOk', 'treAT', 'COmmon', 'sQuaD', 'CONFUSE']).
|
||||
|
||||
:- end_object.
|
||||
7
Task/ABC-problem/Logtalk/abc-problem-3.logtalk
Normal file
7
Task/ABC-problem/Logtalk/abc-problem-3.logtalk
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
:- initialization((
|
||||
% libraries
|
||||
logtalk_load(meta(loader)),
|
||||
logtalk_load(types(loader)),
|
||||
% application
|
||||
logtalk_load([blocks, blocks_test])
|
||||
)).
|
||||
Loading…
Add table
Add a link
Reference in a new issue