Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readln never returns end_of_file atom. #28

Open
noahmartinwilliams opened this issue Mar 31, 2024 · 0 comments
Open

readln never returns end_of_file atom. #28

noahmartinwilliams opened this issue Mar 31, 2024 · 0 comments

Comments

@noahmartinwilliams
Copy link
Contributor

No matter what I do, when readln reaches the end of the input it just returns an empty list.
Here's the current version of the script I'm trying to write:

#! /usr/bin/swipl -q

:- initialization(main).
:- dynamic(asserted/1).

assert_stuff(List):- assert_stuff_intern(List).

assert_stuff_intern([]):- !.
assert_stuff_intern([end_of_file]):-
        findall(X, asserted(X), Y),
        writer_intern(Y),
        halt(0).
assert_stuff_intern([X|Rest]):-
        \+ asserted(X),
        asserta(asserted(X)),
        assert_stuff_intern(Rest), !.
assert_stuff_intern([_|Rest]):-
        assert_stuff_intern(Rest), !.

writer_intern([]).
writer_intern([X|Rest]):-
        writeln(X),
        writer_intern(Rest).

main:- prompt1(''), repeat, readln(X), assert_stuff(X), false.

When I feed it an input file it just hangs forever. The documentation says it's supposed to return end_of_file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant