File: abc.prolog

package info (click to toggle)
haskell-skylighting-core 0.14.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,440 kB
  • sloc: xml: 118,808; haskell: 3,117; cs: 72; ada: 67; java: 37; ansic: 32; cpp: 31; php: 25; tcl: 19; lisp: 14; perl: 11; makefile: 5
file content (23 lines) | stat: -rw-r--r-- 672 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
abc_problem :-
        maplist(abc_problem, ['', 'A', bark, bOOk, treAT, 'COmmon', sQuaD, 'CONFUSE']).


abc_problem(Word) :-
        L = [[b,o],[x,k],[d,q],[c,p],[n,a],[g,t],[r,e],[t,g],[q,d],[f,s],
             [j,w],[h,u],[v,i],[a,n],[o,b],[e,r],[f,s],[l,y],[p,c],[z,m]],

        (   abc_problem(L, Word)
        ->  format('~w OK~n', [Word])
        ;   format('~w KO~n', [Word])).

abc_problem(L, Word) :-
        atom_chars(Word, C_Words),
        maplist(downcase_atom, C_Words, D_Words),
        can_makeword(L, D_Words).

can_makeword(_L, []).

can_makeword(L, [H | T]) :-
        (   select([H, _], L, L1); select([_, H], L, L1)),
        can_makeword(L1, T).