Comment detail

与えられた数字のケタ数 (Nested Flatten)
文字上の桁数を数えています。
Prologの人気のなさに絶望した。
ところで、0は一桁、でいいんでしょうかね。
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
val(X,_,X).

figure(N,(K,X)):-
        atom_chars(N,N1),
        length(N1,K),
        maplist(val('0'),N1,[_|N2]),
        atom_chars(X,['1'|N2]).

:-maplist(figure,[1234,1,0],X),writeln(X).
% 実行結果
% [ (4, 1000), (1, 1), (1, 1)]

Index

Feed

Other

Link

Pathtraq

loading...