Add tags

Add tags to the following comment

UTF-8 で保存して実行.splitぐらい標準であればいいのに...

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
splitLine(S, L) :- append(S1, [10|S2], S),
    splitLine(S1, L1), splitLine(S2, L2), append(L1, L2, L), !.
splitLine(S, [S]).

find(_, [], _, _, _, _).
find(Text, [C|S], DX, DY, X, Y) :- nth0(Y, Text, Line), nth0(X, Line, C),
    X1 is X + DX, Y1 is Y + DY, find(Text, S, DX, DY, X1, Y1).

find8(Text, Word) :-
    splitLine(Text, Lines),
    forall((member([DX, DY, S],
    [[0, -1, '上'], [ 1, -1, '右上'], [ 1, 0, '右'], [ 1,  1, '右下'],
     [0,  1, '下'], [-1,  1, '左下'], [-1, 0, '左'], [-1, -1, '左上']]),
    find(Lines, Word,  DX, DY, X, Y)), format('(~d, ~d), ~p~n', [X, Y, S])).

:- find8("リオウウリウ
ウオリウオリ
オリリオリウ
リリオオウオ", "ウオリ").

Add tags

The input will be splited to tags with space.

Index

Feed

Other

Link

Pathtraq

loading...