users-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to convert the SWI code to gprolog ?


From: z_axis
Subject: How to convert the SWI code to gprolog ?
Date: Tue, 02 Jul 2013 09:21:28 +0800
User-agent: Opera Mail/11.62 (FreeBSD)

$ head foo.dat
14 18 20 22 26 27 13
7 10 19 29 31 32 9
...

open('foo.dat', read, H), file_ints(H,Ns), close(H), ! ,
...

file_ints(S, L) :-
    read_line_to_codes(S, Cs),
    (   Cs == end_of_file
    ->  L = []
    ;   phrase(ints(Is), Cs),
        file_ints(S, R),
        L = [Is|R]
    ).

read_ints(F, L) :-
    open(F, read, S),
    file_ints(S, L),
    close(S).

ints(L) --> blanks, (integer(I), ints(Is), {L = [I|Is]} ; {L = []}).

...

It seems there arenot read_line_to_codes and blanks in gprolog ?

Sincerely !




reply via email to

[Prev in Thread] Current Thread [Next in Thread]