Writing in file | Swi-Prolog | Windows

后端 未结 2 1038
借酒劲吻你
借酒劲吻你 2021-01-19 12:41

Some script is working successful by swi-prolog 5.11.11 on linux-system, but not so well on windows-system by Swi-Prolog 5.6.48

main :-
    open(\'output.txt         


        
2条回答
  •  借酒劲吻你
    2021-01-19 12:45

    I'm assuming this was meant to be a failure-driven loop. It doesn't work because the close/1 call, as @hardmath says, is never reached since it is preceded by a fail/1 in the same clause. In effect, the output file is apparently not flushed. This failure-driven loop should be written as:

    main :-
        open('output.txt', write, OS),
        main(OS).
    
    main(OS) :-
        elements(Points),
        get_set(Eq, Points),
        alpha_isotone(Eq, Points),
        write(OS,Eq), nl(OS),
        false.
    main(OS) :- close(OS).
    

提交回复
热议问题